additional overview stats
[ckanext-dga-stats.git] / ckanext / dga_stats / templates / ckanext / stats / index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
{% extends "page.html" %}
 
{% block breadcrumb_content %}
  <li class="active">{{ 'Statistics' }}</li>
{% endblock %}
 
{% block primary_content %}
  <article class="module">
    <section id="summary" class="module-content tab-content">
      <h2>{{ _('Summary') }}</h2>
      {% if c.summary_stats %}
        <table class="table table-chunky table-bordered table-striped">
          <thead>
            <tr>
              <th>{{ _('Measure') }}</th>
              <th class="metric">{{ _('Value') }}</th>
            </tr>
          </thead>
          <tbody>
            {% for measure,value in c.summary_stats %}
              <tr>
                <td>{{measure}}</td>
                <td class="metric">{{ value }}</td>
              </tr>
            {% endfor %}
          </tbody>
        </table>
      {% else %}
        <p class="empty">{{ _('No groups') }}</p>
      {% endif %}
    </section>
    <section id="activity-counts" class="module-content tab-content">
      <h2>{{ _('Site Activity Log') }}</h2>
      {% if c.activity_counts %}
        <table class="table table-chunky table-bordered table-striped">
          <thead>
            <tr>
              <th>{{ _('Month') }}</th>
              <th>{{ _('Activity Type') }}</th>
              <th class="metric">{{ _('Count') }}</th>
            </tr>
          </thead>
          <tbody>
            {% for month, type, count in c.activity_counts %}
              <tr>
                <td>{{ month }}</td>
                <td>{{ type }}</td>
                <td class="metric">{{ count }}</td>
              </tr>
            {% endfor %}
          </tbody>
        </table>
      {% else %}
        <p class="empty">{{ _('No groups') }}</p>
      {% endif %}
    </section>
    <section id="recent-datasets" class="module-content tab-content">
      <h2>{{ _('Recent Datasets') }}</h2>
      {% if c.recent_datasets %}
        <table class="table table-chunky table-bordered table-striped">
          <thead>
            <tr>
              <th>{{ _('Date') }}</th>
              <th>{{ _('Dataset') }}</th>
              <th>{{ _('New/Modified') }}</th>
            </tr>
          </thead>
          <tbody>
            {% for date,package,newmodified in c.recent_datasets %}
              <tr>
                <td>{{ date }}</td>
                <td>{{ h.link_to(package.title or package.name, h.url_for(controller='package', action='read', id=package.name)) }}</td>
                <td>{{ newmodified }}</td>
              </tr>
            {% endfor %}
          </tbody>
        </table>
      {% else %}
        <p class="empty">{{ _('No groups') }}</p>
      {% endif %}
    </section>
{% if h.check_access('sysadmin') %}
    <section id="user-access-list" class="module-content tab-content">
      <h2>{{ _('User Access List') }}</h2>
      {% if c.user_access_list %}
        <table class="table table-chunky table-bordered table-striped">
          <thead>
            <tr>
              <th>{{ _('Username') }}</th>
              <th>{{ _('Sysadmin') }}</th>
              <th class="metric">{{ _('Organisational Role') }}</th>
            </tr>
          </thead>
          <tbody>
            {% for username,sysadmin,role in c.user_access_list %}
              <tr>
                <td>{{ username }}</td>
                <td>{{ sysadmin }}</td>
                <td>{{ role }}</td>
              </tr>
            {% endfor %}
          </tbody>
        </table>
      {% else %}
        <p class="empty">{{ _('No groups') }}</p>
      {% endif %}
    </section>
{% endif %}
    <section id="stats-total-datasets" class="module-content tab-content active">
      <h2>{{ _('Total number of Datasets') }}</h2>
 
      {% set xaxis = {'mode': 'time', 'timeformat': '%y-%b'} %}
      {% set yaxis = {'min': 0} %}
      <table class="table table-chunky table-bordered table-striped" data-module="plot" data-module-xaxis="{{ h.dump_json(xaxis) }}" data-module-yaxis="{{ h.dump_json(yaxis) }}">
        <thead>
          <tr>
            <th>{{ _("Date") }}</th>
            <th>{{ _("Total datasets") }}</th>
          </tr>
        </thead>
        <tbody>
          {% for row in c.raw_packages_by_week %}
            <tr>
              <th data-type="date" data-value="{{ row.date.strftime("%s") }}"><time datetime="{{ row.date.isoformat() }}">{{ h.render_datetime(row.date) }}</time></th>
              <td>{{ row.total_packages }}</td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    </section>
 
    <section id="stats-dataset-revisions" class="module-content tab-content">
      <h2>{{ _('Dataset Revisions per Week') }}</h2>
 
      {% set xaxis = {'mode': 'time', 'timeformat': '%y-%b'} %}
      {% set lines = {'fill': 1} %}
      <table class="table table-chunky table-bordered table-striped" data-module="plot" data-module-xaxis="{{ h.dump_json(xaxis) }}" data-module-lines="{{ h.dump_json(lines) }}">
        <thead>
          <tr>
            <th>{{ _("Date") }}</th>
            <th>{{ _("All dataset revisions") }}</th>
            <th>{{ _("New datasets") }}</th>
          </tr>
        </thead>
        <tbody>
          {% for row in c.raw_all_package_revisions %}
            <tr>
              <th data-type="date" data-value="{{ row.date.strftime("%s") }}"><time datetime="{{ row.date.isoformat() }}">{{ h.render_datetime(row.date) }}</time></th>
              <td>{{ row.total_revisions }}</td>
              <td>{{ c.raw_new_datasets[loop.index0].new_packages }}</td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    </section>
 
    <section id="stats-top-rated" class="module-content tab-content">
      <h2>{{ _('Top Rated Datasets') }}</h2>
      {% if c.top_rated_packages %}
        <table class="table table-chunky table-bordered table-striped">
          <thead>
            <tr>
              <th>Dataset</th>
              <th class="metric">{{ _('Average rating') }}</th>
              <th class="metric">{{ _('Number of ratings') }}</th>
            </tr>
          </thead>
          <tbody>
            {% for package, rating, num_ratings in c.top_rated_packages %}
              <tr>
                <th>{{ h.link_to(package.title or package.name, h.url_for(controller='package', action='read', id=package.name)) }}</th>
                <td class="metric">{{ rating }}</td>
                <td class="metric">{{ num_ratings }}</td>
              </tr>
            {% endfor %}
          </tbody>
        </table>
      {% else %}
        <p class="empty">{{ _('No ratings') }}</p>
      {% endif %}
    </section>
 
    <section id="stats-most-edited" class="module-content tab-content">
      <h2>{{ _('Most Edited Datasets') }}</h2>
      {% if c.most_edited_packages %}
        <table class="table table-chunky table-bordered table-striped">
          <thead>
            <tr>
              <th>{{ _('Dataset') }}</th>
              <th class="metric">{{ _('Number of edits') }}</th>
            </tr>
          </thead>
          <tbody>
            {% for package, edits in c.most_edited_packages %}
              <tr py:for="package, edits in c.most_edited_packages">
                <td>{{ h.link_to(package.title or package.name, h.url_for(controller='package', action='read', id=package.name)) }}</td>
                <td class="metric">{{ edits }}</td>
              </tr>
            {% endfor %}
          </tbody>
        </table>
      {% else %}
        <p class="empty">{{ _('No edited datasets') }}</p>
      {% endif %}
    </section>
 
    <section id="stats-largest-groups" class="module-content tab-content">
      <h2>{{ _('Largest Groups') }}</h2>
      {% if c.largest_groups %}
        <table class="table table-chunky table-bordered table-striped">
          <thead>
            <tr>
              <th>{{ _('Group') }}</th>
              <th class="metric">{{ _('Number of datasets') }}</th>
            </tr>
          </thead>
         <tbody>
            {% for group, num_packages in c.largest_groups %}
              <tr>
                <td>{{ h.link_to(group.title or group.name, h.url_for(controller='group', action='read', id=group.name)) }}</td>
                <td class="metric">{{ num_packages }}</td>
              </tr>
            {% endfor %}
          </tbody>
        </table>
      {% else %}
       <p class="empty">{{ _('No groups') }}</p>
      {% endif %}
    </section>
 
    <section id="stats-top-tags" class="module-content tab-content">
      <h2>{{ _('Top Tags') }}</h2>
      <table class="table table-chunky table-bordered table-striped">
        <thead>
          <tr>
            <th>{{ _('Tag Name') }}</th>
            <th class="metric">{{ _('Number of Datasets') }}</th>
          </tr>
        </thead>
        <tbody>
          {% for tag, num_packages in c.top_tags %}
            <tr>
              <td>{{ h.link_to(tag.name, h.url_for(controller='package', action='search', tags=tag.name)) }}</td>
              <td class="metric">{{ num_packages }}</td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    </section>
 
    <section id="stats-most-owned" class="module-content tab-content">
      <h2>{{ _('Users Owning Most Datasets') }}</h2>
      <table class="table table-chunky table-bordered table-striped">
        <thead>
          <tr>
            <th>{{ _('User') }}</th>
            <th class="metric">{{ _('Number of Datasets') }}</th>
          </tr>
        </thead>
        <tbody>
          {% for user, num_packages in c.top_package_owners %}
            <tr>
              <td class="media">{{ h.linked_user(user) }}</td>
              <td class="metric">{{ num_packages }}</td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    </section>
    <section id