Skip to content

Commit

Permalink
Merge pull request #159 from ton-society/feature/s6_rounding
Browse files Browse the repository at this point in the history
Optimize S6 apps sorting to avoid rounding issues
  • Loading branch information
shuva10v authored Sep 16, 2024
2 parents d88307e + 8377072 commit b8443e0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions backends/toncenter_cpp/apps_v2_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _do_calculate(self, config: SeasonConfig, dry_run: bool = False):
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(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 eligible using(address)
Expand All @@ -75,7 +75,8 @@ def _do_calculate(self, config: SeasonConfig, dry_run: bool = False):
ProjectStat.URL: row['url'],
ProjectStat.APP_ONCHAIN_UAW: row['total_uaw'],
ProjectStat.APP_ONCHAIN_ENROLLED_UAW: row['enrolled_wallets'],
ProjectStat.APP_AVERAGE_SCORE: row['average_score']
ProjectStat.APP_AVERAGE_SCORE: row['average_score'],
ProjectStat.APP_TOTAL_POINTS: row['total_points']
}
)

Expand Down
1 change: 1 addition & 0 deletions models/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ProjectStat:
APP_ONCHAIN_UAW = 'onchain_uaw'
APP_ONCHAIN_ENROLLED_UAW = 'onchain_enrolled_uaw'
APP_AVERAGE_SCORE = 'average_score'
APP_TOTAL_POINTS = 'total_points'
APP_ONCHAIN_MEDIAN_TX = 'onchain_median_tx'

TOKEN_TVL_CATEGORY = 'token_tvl_category'
Expand Down
2 changes: 1 addition & 1 deletion seasons/app_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ def __init__(self):
super().__init__()

def calculate(self, metrics: List[ProjectStat]):
return sorted(metrics, key=lambda m: m.metrics[ProjectStat.APP_ONCHAIN_ENROLLED_UAW] * m.metrics[ProjectStat.APP_AVERAGE_SCORE], reverse=True)
return sorted(metrics, key=lambda m: m.metrics[ProjectStat.APP_TOTAL_POINTS], reverse=True)

0 comments on commit b8443e0

Please sign in to comment.