Skip to content

Retrieve tomatoes counters from user's scores #240

@potomak

Description

@potomak

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions