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

[ENHANCEMENT] Add an automated way to populate the website with fake data #13

Closed
20 of 25 tasks
SethCram opened this issue Jan 29, 2023 · 1 comment
Closed
20 of 25 tasks
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@SethCram
Copy link
Owner

SethCram commented Jan 29, 2023

Is your feature request related to a problem? Please describe.

  • Yes, the website looks empty and some aspects can't be tested without additional posts

Describe the solution you'd like

  • Add an automated way to populate the website with fake data

Additional context

  • could possibly use FakerJS
  • shouldn't be done until more model architecture is finalized

Development

  • research FakerJS and other possible solutions

    • decided to use FakerJS and build a separate script for fake data injection
  • get post image to stop changing every refresh and be different

    • tried generated a random image each time
      • but now none of the links work
      • had to pass in dimensions and now it works
  • fix categories not being linked to posts properly

    • had to map each chosen category to a name for insertion
  • "Fake" category shouldn't be injected into DB since only devs should be able to use it

  • Votes should also be injectable into the system or posts should be created with a random reputation score

    • votes could be linked to fake users so they already have basis w/ logged into
      • but would be more difficult to test what would happen at different reputation scores
      • would needa create an insane amt of votes + ensure each one's properly contributed to an appropriate post if a certain score needs reaching for testing
      • but creating votes would allow for testing if user rep increases if they contribute enough votes
      • also, all user votes should be shown somewhere
      • so should prolly do a combination of random rep score along with specified number of votes
  • user linked votes aren't deleted with them

  • create a specified number of votes based on if option

    • to properly model system, should model each vote originating from a user
    • so need as many users as upper bounds of reputation desired by a post
      • which should go all to a little over the highest badge
      • author can't vote on their own post so shouldn't be exact
        • can manufacture more users explicitly to create the votes and not have them author any posts
      • would require
    • tried creating enough votes to put each post into a different badge range
      • realized everytime create a vote, post rep doesnt automatically increase
      • only increased bc of call api does
      • same for why badge updated
    • so could just straightup create new votes with a new user for each
      • wouldn't needa try to get votes allocated properly at all
  • add badges to posts

    • have to rando alloc post rep score
    • then test to see where within badges bounds falls
      • can do same way did in API using sorted list + insertion index
  • add badges to users

    • bu for user badges and bp for post badges?
    • could just pass a "-b" to indicate want there to be badges on everything that can have them
      • no reason to have a limited number of badges i suppose
      • or to just give posts badges and not users
    • add badges by default now, not dependent on option
  • randomize some post scores

  • randomize some user scores based on if option

  • determine why all users and votes not always deleted + fix

    • 1 user and their votes survived it last time
    • happens bc not all users are guaranteed authors of a fake post
      • so they aren't deleted at deletion time
      • happens by random chance
      • could assign each user a random post, then in subsequent posts choose the author randomly
        • would require posts >= users
  • fake publish date of posts

    • adding a "createAt" date to the fake post worked perfectly!
  • allow for entering of options in any order for insertion

    • installed minimalist-lite package instead of using a for-loop
      • parsed cmd line args into a dict for position independent option entering
  • fake post comments

    • structured in the same way as votes
      • since wanted each post to contain comments under it given by each user
    • rolled a random every comment creation to see if a reply to any previous comments would be created
      • rolled another random to decide the comment to be replied to
      • then added the new replied to comment to the root comment's replies
        • in API, only root comment has replies arr added to tho
        • so I had to change it to do the same
    • replyId not being set for some reason
      • or replies array
      • because _id field not init'd till posted to db
      • so need create fake comments, post to db, then create fake replied from those
        • then gonna have to update originally posted comments too since replies field changed
        • due to the complexity of this, just gonna post og comments, create replies, delete og's, then post all of them
        • did this and worked but had to compare object id's in special way
    • haven't been able to verify whether replies to other replies are being faked occasionally
      • seems like they aren't tho
  • make sure replies to other replies are being created

    • everytime not replying to root comment directly, reply not added to root comment replies
      • bc root comment can't be found
      • bc new reply comment not having its replyId set properly
        • should possibly set it as a string??
        • not the problem
    • since reply comment not posted to database yet, doesn't have _id field
      • so, would have to post og comments, post reply comment, then post reply to reply comments
      • shouldn't require any comment deletion
        • wrong since still adding replies to already posted comments
        • so could once again try updating since now only picking comment to reply to from explicit pool
        • could update same way deleting rn i think
      • could also reuse same method for both reply comment creation
  • create realistic fake comment dating

    • bounded it between time of post creation
    • should bound between comment replying to if there is one
      • unfortunately, replies ordered by when they were added in display
      • so this way of adding dates works but doesn't display well
  • delete fake comments

    • delete comments author'd by fake usernames
  • speed up updating of root comments

  • only add up to 2 cats per post

    • since users also assigned this restriction
    • 3rd will be the "Fake" cat
    • only allowed for constant number of cats to be chosen
    • so sliced out first two cats before randomly picking one or both
  • determine why faked images suddenly won't render

    • w/ tried to nav to src url, asked for login
    • happened after fake posts were on website for a day or two
    • problem resolved itself
  • delete all comments replying to comments author'd by fake usernames

    • otherwise they'll just sit in DB without being displayed
  • populate post descriptions with faked html for better visualization

  • figure out why images take so long to load

    • likely due to images being retrieved from HTTP request
    • for test data atleast
  • figure out + fix how urls generated for social media links are dead

    • couldn't figure it out
    • tried passing a suggested format but it didnt work
    • could instead use image urls
      • these dont go anywhere so that failed too
  • figure out why test data images occasionally change + fix them

    • tried using diff functs for generating the pictures
      • food images dont seem to be changing
      • false! they changed eventually
      • so all types of pics eventually change if generated by faker??
        • could potentially download post pics into FS to get them to not change
        • would need to figure out how to download image from url of image in automated fashion
        • then place the images in the proper place + get/gives their names
@SethCram SethCram added the enhancement New feature or request label Jan 29, 2023
@SethCram SethCram self-assigned this Jan 29, 2023
@SethCram SethCram added the help wanted Extra attention is needed label Feb 12, 2023
@SethCram SethCram reopened this Feb 22, 2023
@SethCram
Copy link
Owner Author

fake post comments

@SethCram SethCram reopened this Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
Status: 👀 In review
Development

No branches or pull requests

1 participant