up archived calculation
This commit is contained in:
parent
428a9e2f35
commit
277e781fee
4 changed files with 141 additions and 8001 deletions
|
@ -200,6 +200,7 @@
|
|||
<div class="card-body text-center">
|
||||
<div class="stats-value">{{ statistics.avg_votes_per_proposal }}</div>
|
||||
<div class="stats-label">Votes par proposition (moyenne)</div>
|
||||
<div class="small text-muted">Excluant les propositions sans votes</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -213,6 +214,27 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-3">
|
||||
<div class="col-md-3 col-sm-6 mb-3">
|
||||
<div class="card stats-card h-100">
|
||||
<div class="card-body text-center">
|
||||
<div class="stats-value">{{ statistics.median_votes_per_proposal }}</div>
|
||||
<div class="stats-label">Votes par proposition (médiane)</div>
|
||||
<div class="small text-muted">Excluant les propositions sans votes</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3 col-sm-6 mb-3">
|
||||
<div class="card stats-card h-100">
|
||||
<div class="card-body text-center">
|
||||
<div class="stats-value">{{ statistics.std_dev_votes_per_proposal }}</div>
|
||||
<div class="stats-label">Votes par proposition (écart type)</div>
|
||||
<div class="small text-muted">Excluant les propositions sans votes</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if statistics.avg_vote_duration_days is defined %}
|
||||
<div class="row mt-3">
|
||||
<div class="col-md-3 col-sm-6 mb-3">
|
||||
|
|
3
wiki_compare/.gitignore
vendored
3
wiki_compare/.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
*.json
|
||||
.env
|
||||
.env
|
||||
*.png
|
File diff suppressed because it is too large
Load diff
|
@ -581,7 +581,34 @@ def main():
|
|||
# Calculate global statistics
|
||||
total_proposals = len(new_proposals)
|
||||
total_votes = sum(p.get('total_votes', 0) for p in new_proposals)
|
||||
avg_votes_per_proposal = round(total_votes / total_proposals, 1) if total_proposals > 0 else 0
|
||||
|
||||
# Calculate votes per proposal statistics, excluding proposals with 0 votes
|
||||
proposals_with_votes = [p for p in new_proposals if p.get('total_votes', 0) > 0]
|
||||
num_proposals_with_votes = len(proposals_with_votes)
|
||||
|
||||
if num_proposals_with_votes > 0:
|
||||
# Calculate average votes per proposal (excluding proposals with 0 votes)
|
||||
votes_per_proposal = [p.get('total_votes', 0) for p in proposals_with_votes]
|
||||
avg_votes_per_proposal = round(sum(votes_per_proposal) / num_proposals_with_votes, 1)
|
||||
|
||||
# Calculate median votes per proposal
|
||||
votes_per_proposal.sort()
|
||||
if num_proposals_with_votes % 2 == 0:
|
||||
# Even number of proposals, average the middle two
|
||||
median_votes_per_proposal = round((votes_per_proposal[num_proposals_with_votes // 2 - 1] +
|
||||
votes_per_proposal[num_proposals_with_votes // 2]) / 2, 1)
|
||||
else:
|
||||
# Odd number of proposals, take the middle one
|
||||
median_votes_per_proposal = votes_per_proposal[num_proposals_with_votes // 2]
|
||||
|
||||
# Calculate standard deviation of votes per proposal
|
||||
mean = sum(votes_per_proposal) / num_proposals_with_votes
|
||||
variance = sum((x - mean) ** 2 for x in votes_per_proposal) / num_proposals_with_votes
|
||||
std_dev_votes_per_proposal = round((variance ** 0.5), 1)
|
||||
else:
|
||||
avg_votes_per_proposal = 0
|
||||
median_votes_per_proposal = 0
|
||||
std_dev_votes_per_proposal = 0
|
||||
|
||||
# Count unique voters
|
||||
all_voters = set()
|
||||
|
@ -631,6 +658,8 @@ def main():
|
|||
'total_proposals': total_proposals,
|
||||
'total_votes': total_votes,
|
||||
'avg_votes_per_proposal': avg_votes_per_proposal,
|
||||
'median_votes_per_proposal': median_votes_per_proposal,
|
||||
'std_dev_votes_per_proposal': std_dev_votes_per_proposal,
|
||||
'avg_vote_duration_days': avg_vote_duration,
|
||||
'unique_voters': len(all_voters),
|
||||
'top_voters': top_voters,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue