- Download and extract this repository.
- Setup environment with Python 3.7.4
- Navigate to root folder and install all dependencies:
pip3 install -r requirements.txt
- Navigate inside the folder
adjust
where you will findmanage.py
file. - Migrate schemas:
./manage.py migrate
. - Insert sample data to DB using management command provided:
./manage.py write_dataset
. - Run the dev server
./manage.py runserver
. - Now you can use the API in the browser using
http://localhost:8000/app-stats/
-
Exposed query params for searching or filtering data:
date_from
- To get data from the date passed.date_to
- To get data upto the date passed.(Use both date_from and date_to to get data between the interval.)date
- To get the data for the exact date matched.- Valid query parms:
os
,channel
,country
,impressions
,clicks
,installs
,spend
,revenue
,cpi
to search for the matched data.
-
Exposed query_parm for sorting.
- All fields exposed for the searching functionality except
date_from
anddate_to
are available for sorting. - To sort the data with required field, You need to follow the pattern:
o=<field_name>
for ascending order,o=-<field_name>
for descending order.
- All fields exposed for the searching functionality except
-
Exposed query_param for grouping the data.
- Use
group_by
query_parm to group data with xone or more valid fields. - Valid fields for grouping:
date
,channel
,country
,os
.- Pattern:
- To group by single field
group_by=<field_name>
. - To group by multiple fields
group_by=<field_name1>&group_by=<field_name2>
.
- To group by single field
- Pattern:
- Use
- Show the number of impressions and clicks that occurred before the 1st of June 2017, broken down by channel and country, sorted by clicks in descending order.
/app-stats/?date_to=2017-06-01&group_by=channel&group_by=country&o=-clicks
- Show the number of installs that occurred in May of 2017 on iOS, broken down by date, sorted by date in ascending order.
/app-stats/?date_from=2017-05-01&date_to=2017-05-31&os=ios&group_by=date&o=date
- Show revenue, earned on June 1, 2017 in US, broken down by operating system and sorted by revenue in descending order.
/app-stats/?date=2017-06-01&country=US&group_by=os&o=-revenue
- Show CPI and spend for Canada (CA) broken down by channel ordered by CPI in descending order.
/app-stats/?country=CA&group_by=channel&o=-cpi