Skip to content

Conversation

@kainacrow
Copy link

@kainacrow kainacrow commented Jul 9, 2024

Models:

  • Created models for each
    • flag - belongs to user and story
    • story - has many flags, has many flagged_by_users
    • update user model - has many flags, flagged_stories

Controllers:

  • created controllers for
    • Flags

      • create: if story data can be found, creates a story in the db and creates a flag for the current logged in user for the story they choose to flag
      • destroy: if story is unflagged, the flag will be deleted from the current user. only the flag will be deleted, the story will still exist if others have also favorited the story
    • Stories

      • load_stories - fetches the top news stories using the service (set to 20)
      • flagged_stories - fetches the stories that have been flagged

Service

  • created service HackerNewsService
    • fetch_top_stories: fetches top stories - limit set to 20
    • fetch_story: fetches story by story_id (hackernews id)
    • fetch_story_ids: fetches top story ids from TOP_STORIES_URL

Views
app/views/layouts/application.html.erb

  • added sign in and sign out link
  • added link to latest news stories
  • added link to team favorites

app/views/stories/_story.html.erb partial for use within app/views/stories/index.html.erb each story gets passed through here to be rendered

app/views/stories/flagged_stories.html.erb

  • view for flagged stories, very similar to the latest news stories page but this time it shows only the stories that others have favorited, link to stories and names of who flagged them

other stuff:

  • included some updates to get specs to work

specs

  • included factories for flags, users, stories
  • controller specs for methods in controllers
  • model specs for flag and story

@kainacrow kainacrow changed the title top news feed + favorites list kaina - topnews take home Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant