Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update apps projects leaderboard query #227

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions backends/toncenter_cpp/apps_v2_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,17 @@ def _do_calculate(self, config: SeasonConfig, dry_run: bool = False):
SQL = f"""
with project_names as (
{PROJECTS_NAMES}
), apps_users_stats as (
select * from tol.apps_users_stats_{config.safe_season_name()}
), eligible as (
select address, 1 as eligible from tol.apps_users_stats_{config.safe_season_name()} auss
select address, 1 as eligible from apps_users_stats auss
join tol.enrollment_{config.safe_season_name()} es using(address)
group by address having count(1) > 1
group by address having count(1) > 1
)
select project, url, count(distinct address) as total_uaw, coalesce(sum(eligible), 0) as enrolled_wallets,
coalesce(cast(sum(points) / sum(eligible) as int), 0) as average_score, coalesce(sum(points), 0) as total_points
from project_names
left join tol.apps_users_stats_{config.safe_season_name()} using(project)
left join apps_users_stats using(project)
left join eligible using(address)
left join tol.apps_points_{config.safe_season_name()} using(address)
group by 1, 2
Expand Down
Loading