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

calculate user visit count and save to redis #333

Merged
merged 6 commits into from
Nov 29, 2021

Conversation

tingyuchang
Copy link
Collaborator

這個 PR 的目的 / Purpose of this PR

  1. create collection user_visit
  2. save user visit record when api check login
  3. add cron job: calculate user visit each 10 mins and set to redis

相關的 issue / Related Issues

#263

TODO:

  1. get user visit count from go-pttbbs
  2. provide api return go-pttbbs + go-openbbsmiddleware user visit count
  3. add prometheus

@codecov-commenter
Copy link

codecov-commenter commented Nov 28, 2021

Codecov Report

Merging #333 (70e920c) into main (2fbb088) will decrease coverage by 0.17%.
The diff coverage is 35.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #333      +/-   ##
==========================================
- Coverage   65.76%   65.59%   -0.18%     
==========================================
  Files         142      145       +3     
  Lines        6926     6966      +40     
==========================================
+ Hits         4555     4569      +14     
- Misses       1644     1667      +23     
- Partials      727      730       +3     
Impacted Files Coverage Δ
api/api_login_required_path.go 0.00% <0.00%> (ø)
cron/calculate_user_visit.go 0.00% <0.00%> (ø)
main.go 0.00% <0.00%> (ø)
schema/user_visit_count.go 0.00% <0.00%> (ø)
schema/init.go 65.74% <66.66%> (+0.03%) ⬆️
schema/user_visit.go 71.42% <71.42%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2fbb088...70e920c. Read the comment docs.

Copy link
Collaborator

@chhsiao1981 chhsiao1981 left a comment

Choose a reason for hiding this comment

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

  1. Can you change schema/redis.go to schema/user_visit_count.go (like schema/lock.go)?
  2. Can you have TIME_CALC_ALL_USER_VISIT_COUNTS = -10 * time.Minute in schema/const.go?

schema/user_visit.go Outdated Show resolved Hide resolved
schema/redis.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@chhsiao1981 chhsiao1981 left a comment

Choose a reason for hiding this comment

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

/lgtm

@chhsiao1981 chhsiao1981 merged commit 474c2c5 into Ptt-official-app:main Nov 29, 2021
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.

3 participants