Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update initial data #909

Closed
fenbox opened this issue Apr 16, 2024 · 15 comments · Fixed by #918
Closed

Update initial data #909

fenbox opened this issue Apr 16, 2024 · 15 comments · Fixed by #918
Assignees
Labels
enhancement Enhancement request
Milestone

Comments

@fenbox
Copy link
Member

fenbox commented Apr 16, 2024

Current

All data is empty and requires further configuration by the administrator to use.

Expected

Have initial data such as tags, sample Q&A, etc., so users can start using it right away.

After the user fills in the admin account during installation and clicks the Next button, the following initial data will be generated automatically.

image

Initial tag:

- name: support
  description: For general support questions.

Initial post:

- title: What is a tag?
  body: When asking a question, we need to choose tags. What are tags and why should I use them?
  tags:
    - support
  answer: Tags help to organize content and make searching easier. It helps your question get more attention from people interested in that tag. Tags also send notifications. If you are interested in some topic, follow that tag to get updates.

- title: What is reputation and how do I earn them?
  body: I see that each user has reputation points, What is it and how do I earn them?
  tags:
    - support
  answer: Your reputation points show how much the community values your knowledge. You earn points when someone find your question or answer helpful. You also get points when the person who asked the question thinks you did a good job and accepts your answer.

The author is the initial administrator.

@fenbox fenbox added the enhancement Enhancement request label Apr 16, 2024
@fenbox fenbox added this to the v1.3.1 milestone Apr 16, 2024
@zahash
Copy link
Contributor

zahash commented Apr 20, 2024

i'll do it

@zahash
Copy link
Contributor

zahash commented Apr 20, 2024

@fenbox

is it a good idea to add it in the internal/migrations/init.go file? in the InitDB method?
that would require importing the tag_service, question_service, etc... or atleast the tag_repo, question_repo, etc...

because i need to generate unique ID and can't just do m.engine.Context(m.ctx).Insert(...)

@LinkinStars
Copy link
Member

@fenbox Maybe we can clarify the requirements a bit more.

  • Option 1: Do we need an input field in the installation page, where the initial administrator can enter the contents of the initial tag and post, and initialize them along with the initial data?
  • Option 2: The administrator can enter these details in the admin page after installation.
  • Option 3: During installation, it is possible to add a command-line option to specify the location of the initial data configuration file.

I would perfer option 1. Or do you have any other ideas.

@zahash If it is option 1, then you are correct.

@fenbox
Copy link
Member Author

fenbox commented Apr 20, 2024

Like other platforms such as WordPress. There is no need an input field in the installation page.

@zahash
Copy link
Contributor

zahash commented Apr 21, 2024

@fenbox @LinkinStars

i'm sorry i've never used wordpress, how does this feature work?
so which of the three options is it?

@fenbox
Copy link
Member Author

fenbox commented Apr 22, 2024

@zahash I have updated the description.

After users install the program, they will now see two Q&A post and one tag. No other functions.

@LinkinStars
Copy link
Member

is it a good idea to add it in the internal/migrations/init.go file? in the InitDB method?

@zahash Your understanding is correct. This initialization content is fixed, which means that after installation, there is a default tag and Q&A content. Therefore, you can create these contents directly in the InitDB method. BTW, you can put the initial content in init_data.go.

@zahash
Copy link
Contributor

zahash commented Apr 23, 2024

@LinkinStars @fenbox

why is there no AddTag function in tag_repo.go?

@LinkinStars
Copy link
Member

@LinkinStars @fenbox

why is there no AddTag function in tag_repo.go?

@zahash In tag_common_repo.go

@zahash
Copy link
Contributor

zahash commented Apr 23, 2024

@LinkinStars hmmm.. whats the difference? why is it split into two files?

@LinkinStars
Copy link
Member

@LinkinStars hmmm.. whats the difference? why is it split into two files?

@zahash It was supposed to fix the golang circular references at the time.

@zahash
Copy link
Contributor

zahash commented Apr 23, 2024

@LinkinStars @fenbox

i made a pr with a "work in progess" commit. It doesn't compile right now but is this the direction you want to go?
#918

@LinkinStars
Copy link
Member

@LinkinStars @fenbox

i made a pr with a "work in progess" commit. It doesn't compile right now but is this the direction you want to go? #918

@zahash No problem, good job.

@zahash
Copy link
Contributor

zahash commented Apr 23, 2024

@LinkinStars

how do i initialize the UniqueIDRepo in internal/install/install_controller.go InitBaseInfo function?
because migrations.NewMentor( ... ) needs it

@LinkinStars
Copy link
Member

@LinkinStars

how do i initialize the UniqueIDRepo in internal/install/install_controller.go InitBaseInfo function? because migrations.NewMentor( ... ) needs it

Maybe you can use unique.NewUniqueIDRepo(&data.Data{DB: engine}). If you think this way is too troublesome, you also can use the engine *xorm.Engine to Insert directly.

@fenbox fenbox closed this as completed May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants