pretty keys names in api response

This commit is contained in:
norohind committed 2021-11-21 01:09:54 +03:00
1 parent 56bd4f335b
commit 181f7892de
2 files changed
+23 -1

No files matched your search

+1 -1
View File
@@ -14,7 +14,7 @@ db.row_factory = lambda c, r: dict(zip([col[0] for col in c.description], r))
def get_activity_changes(platform: str, leaderboard_type: str, limit: int, low_timestamp, high_timestamp) -> list:
sql_req: sqlite3.Cursor = db.execute(sql_requests.select_activity, {
sql_req: sqlite3.Cursor = db.execute(sql_requests.select_activity_pretty_names, {
'LB_type': utils.LeaderboardTypes(leaderboard_type.lower()).value,
'platform': utils.Platform(platform.upper()).value,
'limit': limit,
+22
View File
@@ -56,3 +56,25 @@ from (
group by sum_score
order by timestamp desc
limit :limit);"""
select_activity_pretty_names = """select
sum_score as TotalExperience,
timestamp as Timestamp,
action_id as ActionId,
sum_score_old as TotalExperienceOld,
sum_score - sum_score_old as Diff
from
(select sum_score, min(timestamp) as timestamp, action_id, lag (sum_score, 1, 0) over (order by sum_score) sum_score_old
from (
select sum(score) as sum_score, timestamp, action_id
from squads_stats_states
where
leaderboard_type = :LB_type and
platform = :platform and
:high_timestamp >= timestamp and
timestamp >= :low_timestamp
group by action_id
)
group by sum_score
order by timestamp desc
limit :limit);"""