From 8acabd95b54888d162f46b8af067f94b604ce1ba Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 3 May 2026 19:55:10 +0200 Subject: [PATCH] Updated stats page --- RNS/Utilities/rngit/pages.py | 2 +- RNS/Utilities/rngit/server.py | 36 +++++++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/RNS/Utilities/rngit/pages.py b/RNS/Utilities/rngit/pages.py index 7bbf232f..0114352f 100644 --- a/RNS/Utilities/rngit/pages.py +++ b/RNS/Utilities/rngit/pages.py @@ -1053,7 +1053,7 @@ class NomadNetworkNode(): content_parts.append(f"`F0a0Fetches`f : {f_total:>5} total {self.CLR_DIM}(peak: {f_peak:>3})\n`f") content_parts.append(f"`Faa0Pushes`f : {p_total:>5} total {self.CLR_DIM}(peak: {p_peak:>3})\n`f") content_parts.append(f"`F0aaActivity`f : {stats['activity_score']:>5} points\n\n") - content_parts.append(f"{act_color}{act_label}`f over the last {stats['lookback_days']} days ({stats['date_range']})\n\n") + content_parts.append(f"{act_color}{act_label}`f over the last {stats['actual_days']} days ({stats['date_range']})\n\n") if v_total > 0: content_parts.append(self.m_heading(f"Views", 2)) diff --git a/RNS/Utilities/rngit/server.py b/RNS/Utilities/rngit/server.py index e2cca377..7ac70d41 100644 --- a/RNS/Utilities/rngit/server.py +++ b/RNS/Utilities/rngit/server.py @@ -827,17 +827,37 @@ class ReticulumGitNode(): repo_stats["pushes"]["peak"] = count repo_stats["pushes"]["peak_day"] = day - total_score = ( repo_stats["views"]["total"] * 0.25 + + total_score = ( repo_stats["views"]["total"] * 0.2 + repo_stats["fetches"]["total"] * 2 + - repo_stats["pushes"]["total"] * 4 ) + repo_stats["pushes"]["total"] * 5 ) repo_stats["activity_score"] = int(total_score) - - if total_score == 0: repo_stats["activity_level"] = "inactive" - elif total_score < lookback_days * 2: repo_stats["activity_level"] = "low" - elif total_score < lookback_days * 5: repo_stats["activity_level"] = "moderate" - else: repo_stats["activity_level"] = "high" - + + actual_days = lookback_days + all_activity_days = set() + + for stats_dict in (view_stats, fetch_stats, push_stats): + for day, count in stats_dict.items(): + if count > 0: all_activity_days.add(day) + + if all_activity_days: + earliest_day = min(all_activity_days) + try: + earliest_ts = time.mktime(time.strptime(earliest_day, "%Y-%m-%d")) + span_seconds = now - earliest_ts + actual_days = max(1, int(span_seconds // day_seconds) + 1) + + except (ValueError, TypeError): pass + + if actual_days > lookback_days: actual_days = lookback_days + daily_score = total_score / actual_days if actual_days > 0 else 0 + repo_stats["actual_days"] = actual_days + + if daily_score == 0: repo_stats["activity_level"] = "inactive" + elif daily_score < 3: repo_stats["activity_level"] = "low" + elif daily_score < 10: repo_stats["activity_level"] = "moderate" + else: repo_stats["activity_level"] = "high" + return repo_stats def view_succeeded(self, group_name, repository_name, remote_identity):