terra-money / fcd-classic

Terra ETL + RestFul API Server

Home Page:https://fcd.terra.dev/swagger

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix historical active accounts in /v1/account_growth

hanjukim opened this issue · comments

Description

Fix /v1/account_growth endpoint for querying active accounts within specific period

Changes

Query parameter: count

Description: Number of previous days
For validation, we have to change:
As Is: >= 0
To Be: 0, 7, 14, 30
Why: For query cache

Result

{
   activeAccountCount: `unique account count within selected period`,
   cumulative: [
       { 
          datetime: `unix timestamp`,
          totalAccountCount: `cumulative total accounts`
          activeAccountCount: `cumulative daily active accounts`
       },
       ...
   ],
   periodic: [
       { 
          datetime: `unix timestamp`,
          totalAccountCount: `daly account growth`,
          activeAccountCount: `daily active accounts`
       },
       ...
   ]
}

We need to fix activeAccountCount property for every elements in both cumulative and periodic array.

Notes

To show distinct accounts(activeAccountCount property in the result) within specific period, we have to query database by:

SELECT COUNT(*) FROM (SELECT DISTINCT account FROM account_tx WHERE timestamp >= `daysBefore(count)` AND timestamp < `startOfToday`