ajout info historique propositions

This commit is contained in:
Tykayn 2025-08-31 12:27:38 +02:00 committed by tykayn
parent 9bd1fddd8a
commit f7f953efdd
2 changed files with 33 additions and 509 deletions

View file

@ -605,15 +605,33 @@ def main():
[{'username': k, **v} for k, v in voter_counts.items()],
key=lambda x: x['total'],
reverse=True
)[:100] # Top 20 voters
)[:100] # Top 100 voters
# Count proposals by status
status_counts = {}
for p in new_proposals:
status = p.get('status')
if status:
status_counts[status] = status_counts.get(status, 0) + 1
else:
status_counts['Unknown'] = status_counts.get('Unknown', 0) + 1
# Calculate average vote duration
proposals_with_duration = [p for p in new_proposals if 'votes' in p and 'duration_days' in p['votes']]
avg_vote_duration = 0
if proposals_with_duration:
total_duration = sum(p['votes']['duration_days'] for p in proposals_with_duration)
avg_vote_duration = round(total_duration / len(proposals_with_duration), 1)
# Add statistics to the data
data['statistics'] = {
'total_proposals': total_proposals,
'total_votes': total_votes,
'avg_votes_per_proposal': avg_votes_per_proposal,
'avg_vote_duration_days': avg_vote_duration,
'unique_voters': len(all_voters),
'top_voters': top_voters
'top_voters': top_voters,
'status_distribution': status_counts
}
# Save the data