mirror of
https://github.com/System-End/hackatime.git
synced 2026-04-20 00:35:22 +00:00
Fix stats controller query for user_id
This commit is contained in:
parent
0f3f423b27
commit
13c1b9f6da
1 changed files with 2 additions and 3 deletions
|
|
@ -8,14 +8,13 @@ class Api::V1::StatsController < ApplicationController
|
|||
end_date = Date.parse(params[:end_date]) if params[:end_date].present?
|
||||
end_date ||= Date.today
|
||||
|
||||
query = Heartbeat
|
||||
query = query.where(time: start_date..end_date)
|
||||
query = Heartbeat.where(time: start_date..end_date)
|
||||
if params[:user_id].present? || params[:user_email].present?
|
||||
user_id = params[:user_id] || find_by_email(params[:user_email])
|
||||
|
||||
return render plain: "User not found", status: :not_found unless user_id.present?
|
||||
|
||||
query = query.where(user_id: params[:user_id]) if params[:user_id].present?
|
||||
query = query.where(user_id: user_id)
|
||||
end
|
||||
|
||||
render plain: query.duration_seconds
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue