|
1
|
{% extends "base.html" %} |
|
2
|
{% load fossil_filters %} |
|
3
|
{% block title %}Statistics — {{ project.name }} — Fossilrepo{% endblock %} |
|
4
|
|
|
5
|
{% block extra_head %} |
|
6
|
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.umd.min.js"></script> |
|
7
|
{% endblock %} |
|
8
|
|
|
9
|
{% block content %} |
|
10
|
<h1 class="text-2xl font-bold text-gray-100 mb-2">{{ project.name }}</h1> |
|
11
|
{% include "fossil/_project_nav.html" %} |
|
12
|
|
|
13
|
<div class="grid grid-cols-2 gap-4 sm:grid-cols-4 mb-6"> |
|
14
|
<div class="rounded-lg bg-gray-800 border border-gray-700 p-4"> |
|
15
|
<div class="text-2xl font-bold text-gray-100">{{ stats.checkin_count|default:"0" }}</div> |
|
16
|
<div class="text-xs text-gray-500 mt-1">Checkins</div> |
|
17
|
</div> |
|
18
|
<div class="rounded-lg bg-gray-800 border border-gray-700 p-4"> |
|
19
|
<div class="text-2xl font-bold text-gray-100">{{ stats.contributors|default:"0" }}</div> |
|
20
|
<div class="text-xs text-gray-500 mt-1">Contributors</div> |
|
21
|
</div> |
|
22
|
<div class="rounded-lg bg-gray-800 border border-gray-700 p-4"> |
|
23
|
<div class="text-2xl font-bold text-gray-100">{{ stats.total_artifacts|default:"0" }}</div> |
|
24
|
<div class="text-xs text-gray-500 mt-1">Artifacts</div> |
|
25
|
</div> |
|
26
|
<div class="rounded-lg bg-gray-800 border border-gray-700 p-4"> |
|
27
|
<div class="text-2xl font-bold text-gray-100">{{ stats.db_size_mb|default:"0" }} MB</div> |
|
28
|
<div class="text-xs text-gray-500 mt-1">Repository Size</div> |
|
29
|
</div> |
|
30
|
</div> |
|
31
|
|
|
32
|
{% if activity_json %} |
|
33
|
<div class="rounded-lg bg-gray-800 border border-gray-700 p-4 mb-6"> |
|
34
|
<h3 class="text-sm font-medium text-gray-300 mb-3">Commit Activity (52 weeks)</h3> |
|
35
|
<div style="height: 160px;"> |
|
36
|
<canvas id="statsChart"></canvas> |
|
37
|
</div> |
|
38
|
</div> |
|
39
|
{% endif %} |
|
40
|
|
|
41
|
<div class="grid grid-cols-1 gap-6 lg:grid-cols-2"> |
|
42
|
<!-- Event breakdown --> |
|
43
|
<div class="rounded-lg bg-gray-800 border border-gray-700 p-4"> |
|
44
|
<h3 class="text-sm font-medium text-gray-300 mb-3">Event Breakdown</h3> |
|
45
|
<div class="space-y-2"> |
|
46
|
<div class="flex items-center justify-between"> |
|
47
|
<span class="text-sm text-gray-400">Checkins</span> |
|
48
|
<span class="text-sm font-medium text-gray-200">{{ stats.checkin_count|default:"0" }}</span> |
|
49
|
</div> |
|
50
|
<div class="flex items-center justify-between"> |
|
51
|
<span class="text-sm text-gray-400">Wiki edits</span> |
|
52
|
<span class="text-sm font-medium text-gray-200">{{ stats.wiki_events|default:"0" }}</span> |
|
53
|
</div> |
|
54
|
<div class="flex items-center justify-between"> |
|
55
|
<span class="text-sm text-gray-400">Ticket changes</span> |
|
56
|
<span class="text-sm font-medium text-gray-200">{{ stats.ticket_events|default:"0" }}</span> |
|
57
|
</div> |
|
58
|
<div class="flex items-center justify-between"> |
|
59
|
<span class="text-sm text-gray-400">Forum posts</span> |
|
60
|
<span class="text-sm font-medium text-gray-200">{{ stats.forum_events|default:"0" }}</span> |
|
61
|
</div> |
|
62
|
{% if stats.first_checkin %} |
|
63
|
<div class="flex items-center justify-between pt-2 border-t border-gray-700"> |
|
64
|
<span class="text-sm text-gray-500">First checkin</span> |
|
65
|
<span class="text-sm text-gray-400">{{ stats.first_checkin|date:"Y-m-d" }}</span> |
|
66
|
</div> |
|
67
|
{% endif %} |
|
68
|
{% if stats.last_checkin %} |
|
69
|
<div class="flex items-center justify-between"> |
|
70
|
<span class="text-sm text-gray-500">Last checkin</span> |
|
71
|
<span class="text-sm text-gray-400">{{ stats.last_checkin|date:"Y-m-d" }}</span> |
|
72
|
</div> |
|
73
|
{% endif %} |
|
74
|
</div> |
|
75
|
</div> |
|
76
|
|
|
77
|
<!-- Top contributors --> |
|
78
|
<div class="rounded-lg bg-gray-800 border border-gray-700 p-4"> |
|
79
|
<h3 class="text-sm font-medium text-gray-300 mb-3">Top Contributors</h3> |
|
80
|
<div class="space-y-1"> |
|
81
|
{% for c in top_contributors %} |
|
82
|
<a href="{% url 'fossil:user_activity' slug=project.slug username=c.user %}" class="flex items-center justify-between rounded-md px-2 py-1.5 hover:bg-gray-700/50"> |
|
83
|
<span class="text-sm text-gray-300">{{ c.user|display_user }}</span> |
|
84
|
<div class="flex items-center gap-2"> |
|
85
|
<div class="w-24 bg-gray-700 rounded-full h-1.5"> |
|
86
|
<div class="bg-brand rounded-full h-1.5" style="width: {% widthratio c.count top_contributors.0.count 100 %}%"></div> |
|
87
|
</div> |
|
88
|
<span class="text-xs text-gray-500 w-16 text-right">{{ c.count }}</span> |
|
89
|
</div> |
|
90
|
</a> |
|
91
|
{% endfor %} |
|
92
|
</div> |
|
93
|
</div> |
|
94
|
</div> |
|
95
|
|
|
96
|
{% if activity_json %} |
|
97
|
<script> |
|
98
|
new Chart(document.getElementById('statsChart').getContext('2d'), { |
|
99
|
type: 'bar', |
|
100
|
data: { |
|
101
|
labels: {{ activity_json|safe }}.map((_, i) => ''), |
|
102
|
datasets: [{ |
|
103
|
data: {{ activity_json|safe }}, |
|
104
|
backgroundColor: '#DC394C', |
|
105
|
borderRadius: 2, |
|
106
|
barPercentage: 0.8, |
|
107
|
categoryPercentage: 0.9, |
|
108
|
}] |
|
109
|
}, |
|
110
|
options: { |
|
111
|
responsive: true, |
|
112
|
maintainAspectRatio: false, |
|
113
|
plugins: { legend: { display: false }, tooltip: { |
|
114
|
callbacks: { title: (items) => { const w = 51 - items[0].dataIndex; return w === 0 ? 'This week' : w + ' week' + (w > 1 ? 's' : '') + ' ago'; } } |
|
115
|
}}, |
|
116
|
scales: { |
|
117
|
x: { display: false, grid: { display: false } }, |
|
118
|
y: { display: false, grid: { display: false }, beginAtZero: true } |
|
119
|
} |
|
120
|
} |
|
121
|
}); |
|
122
|
</script> |
|
123
|
{% endif %} |
|
124
|
{% endblock %} |
|
125
|
|