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

Retrieve tomatoes counters from user's scores #240

Open
potomak opened this issue Jan 28, 2017 · 1 comment
Open

Retrieve tomatoes counters from user's scores #240

potomak opened this issue Jan 28, 2017 · 1 comment

Comments

@potomak
Copy link
Member

potomak commented Jan 28, 2017

Right now GET / and GET /api/user return three counters that include:

  • current user's number of tomatoes completed today
  • current user's number of tomatoes completed this week
  • current user's number of tomatoes completed this month

These numbers are computed dynamically running a count query on a subset of tomatoes. The method to count current user's tomatoes completed within a period of time is defined as:

def tomatoes_counter(time_period)
  tomatoes.after(Time.zone.now.send("beginning_of_#{time_period}")).count
end

where time_period is included in [:day, :week, :month].

Alternatively we could just rely on score collections to retrieve cached counters. This method would run a query against one of the collections, for instance DailyScore, to find the user's score. The number of queries would be the same, but queries against *Scorecollections would be slightly faster and would alleviate load on the tomatoes collection.

@potomak
Copy link
Member Author

potomak commented Feb 12, 2017

This proposal is blocked by #258.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant