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

feat: update models and add unique viewers endpoint #194

Merged
merged 16 commits into from
Mar 8, 2024

Conversation

ayushtom
Copy link
Contributor

@ayushtom ayushtom commented Mar 3, 2024

In this PR we do the following things -

  • update the models to have a timestamp field
  • add a unique page visit endpoint which will add the user's ip address and the page id if it is is his first visit.

For the first task-

  • The completed_tasks and achieved collection's models are updated with a required timestamp field of type i64 (we save in unix). We also add these changes to the upsert_completed_task and upsert_completed_achievement since these two functions interact with the collections exclusively.
  • I also backfill the old data with timestamp field here https://github.com/starknet-id/upgrade_quest_db/pull/1

For the second task -

  • I add a get request on the /unique_page_visit route which accepts a page_id param. The quest pages are identified by some instructions i added in this
  • I also check for the followiing things in the logic -
    • if the viewer_ip and viewer_page_id already exist then we don't add it to our collection.
      The output looks something like this
Screenshot 2024-03-06 at 5 19 33 PM

@ayushtom ayushtom changed the title feat: update models feat: analytics Mar 6, 2024
@ayushtom ayushtom changed the title feat: analytics feat: update models and add unique viewers endpoint Mar 6, 2024
@ayushtom ayushtom self-assigned this Mar 6, 2024
@ayushtom ayushtom added the 🔥 Ready for review This pull request needs a review label Mar 6, 2024
@ayushtom ayushtom marked this pull request as ready for review March 6, 2024 15:53
@ayushtom ayushtom requested a review from Th0rgal March 6, 2024 16:12
Copy link
Member

@Th0rgal Th0rgal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To check: compatibility with nginx reverse proxy

Please only store the ip address and not the port

@Th0rgal Th0rgal self-requested a review March 8, 2024 17:30
Copy link
Member

@Th0rgal Th0rgal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Th0rgal Th0rgal merged commit ea2a1ce into master Mar 8, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔥 Ready for review This pull request needs a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants