Enhancement: Move reporting metrics to postgres (#606)

This commit is contained in:
Subin T P
2020-03-18 16:53:35 +05:30
committed by GitHub
parent f69eb7e542
commit 8f6f07177d
27 changed files with 575 additions and 2 deletions

View File

@@ -0,0 +1,39 @@
class Api::V2::Accounts::ReportsController < Api::BaseController
def account
builder = V2::ReportBuilder.new(current_account, account_report_params)
data = builder.build
render json: data
end
def account_summary
render json: account_summary_metrics
end
private
def current_account
current_user.account
end
def account_summary_params
{
type: :account,
since: params[:since],
until: params[:until]
}
end
def account_report_params
{
metric: params[:metric],
type: :account,
since: params[:since],
until: params[:until]
}
end
def account_summary_metrics
builder = V2::ReportBuilder.new(current_account, account_summary_params)
builder.summary
end
end