Skip to content

Commit

Permalink
Merge pull request #113 from x-tools/adminstats-refactor
Browse files Browse the repository at this point in the history
AdminStats: major refactoring with Model and Repository, API endpoints
  • Loading branch information
MusikAnimal committed Oct 16, 2017
2 parents cd44b63 + e20cc77 commit 7febf54
Show file tree
Hide file tree
Showing 14 changed files with 936 additions and 213 deletions.
37 changes: 20 additions & 17 deletions app/Resources/views/adminStats/result.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<a target="_blank" href="{{ project.url }}">{{ project.title }}</a>
<small>
&bull;
{{ start_date }}
{{ as.start }}
&mdash;
{{ end_date }}
{{ as.end }}
</small>
</div>
</header>
Expand All @@ -28,27 +28,30 @@
<table class="table"><tbody>
<tr>
<td>{{ msg('start') }}</td>
<td>{{ start_date }}</td>
<td>{{ as.start }}</td>
</tr>
<tr>
<td>{{ msg('end') }}</td>
<td>{{ end_date }} ({{ days|num_format }} {{ msg('num-days', [days]) }})</td>
<td>{{ as.end }} ({{ as.numDays|num_format }} {{ msg('num-days', [as.numDays]) }})</td>
</tr>
<tr>
<td>{{ msg('log-types') }}</td>
<td>delete, block, protect, import, rights</td>
</tr>
<tr>
<td>{{ msg('current-admins') }}</td>
<td>{{ wiki.userGroupLink('sysop', project, adminCount|num_format) }}</td>
<td>{{ wiki.userGroupLink('sysop', project, as.numAdmins|num_format) }}</td>
</tr>
<tr>
<td>{{ msg('admins-without-action') }}</td>
<td>{{ adminsWithoutAction|num_format }} ({{ admins_without_action_pct|percent_format }})</td>
<td>
{{ as.numAdminsWithoutActions|num_format }}
({{ as.numAdminsWithoutActions|percent_format(as.numAdmins) }})
</td>
</tr>
<tr>
<td>{{ msg('non-admins-with-actions') }}</td>
<td>{{ (usersCount - adminCount)|num_format }}</td>
<td>{{ (as.numUsers - as.numAdmins)|num_format }}</td>
</tr>
</tbody></table>
</div>
Expand All @@ -71,7 +74,7 @@
{% endfor %}
</tr></thead>
<tbody>
{% for key,value in users %}
{% for key,value in as.stats %}
{% set username = value.user_name %}
<tr>
<td>{{ loop.index }}.</td>
Expand All @@ -90,15 +93,15 @@
{% endif %}
{{ wiki.userLogLink(username, project, msg('log')|lower) }}
</td>
<td class="sort-entry--total" data-value="{{ value.mtotal }}">{{ value.mtotal|num_format }}</td>
<td class="sort-entry--delete" data-value="{{ value.mdelete }}">{{ value.mdelete|num_format }}</td>
<td class="sort-entry--restore" data-value="{{ value.mrestore }}">{{ value.mrestore|num_format }}</td>
<td class="sort-entry--re-block" data-value="{{ value.mblock }}">{{ value.mblock|num_format }}</td>
<td class="sort-entry--unblock" data-value="{{ value.munblock }}">{{ value.munblock|num_format }}</td>
<td class="sort-entry--re-protect" data-value="{{ value.mprotect }}">{{ value.mprotect|num_format }}</td>
<td class="sort-entry--unprotect" data-value="{{ value.munprotect }}">{{ value.munprotect|num_format }}</td>
<td class="sort-entry--import" data-value="{{ value.mimport }}">{{ value.mimport|num_format }}</td>
<td class="sort-entry--rights" data-value="{{ value.mrights }}">{{ value.mrights|num_format }}</td>
<td class="sort-entry--total" data-value="{{ value.total }}">{{ value.total|num_format }}</td>
<td class="sort-entry--delete" data-value="{{ value.delete }}">{{ value.delete|num_format }}</td>
<td class="sort-entry--restore" data-value="{{ value.restore }}">{{ value.restore|num_format }}</td>
<td class="sort-entry--re-block" data-value="{{ value.block }}">{{ value.block|num_format }}</td>
<td class="sort-entry--unblock" data-value="{{ value.unblock }}">{{ value.unblock|num_format }}</td>
<td class="sort-entry--re-protect" data-value="{{ value.protect }}">{{ value.protect|num_format }}</td>
<td class="sort-entry--unprotect" data-value="{{ value.unprotect }}">{{ value.unprotect|num_format }}</td>
<td class="sort-entry--import" data-value="{{ value.import }}">{{ value.import|num_format }}</td>
<td class="sort-entry--rights" data-value="{{ value.rights }}">{{ value.rights|num_format }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
1 change: 1 addition & 0 deletions app/Resources/views/message.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ msg(key, params) }}
39 changes: 39 additions & 0 deletions docs/api/project.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,42 @@ Get the namespace IDs and names of the German Wikipedia.
https://xtools.wmflabs.org/api/project/namespaces/dewiki
https://xtools.wmflabs.org/api/project/namespaces/de.wikipedia
https://xtools.wmflabs.org/api/project/namespaces/de.wikipedia.org

Admins and user groups
======================
``GET /api/project/admins_groups/{project}``

Get a list of users who are admins, bureaucrats, CheckUsers, Oversighters, or
stewards of the project and list which of these user groups they belong to.

**Parameters:**

* ``project`` (**required**) - Project domain or database name.

**Example:**

Get administrative users of the French Wikipedia:

https://xtools.wmflabs.org/api/project/admins_groups/frwiki
https://xtools.wmflabs.org/api/project/admins_groups/fr.wikipedia.org

Admin statistics
================

``GET /api/project/adminstats/{project}/{days}``

Get users of the project that are capable of making 'admin actions', along with
various stats about the actions they took. Time period is limited to one month.

**Parameters:**

* ``project`` (**required**) - Project domain or database name.
* ``days`` - Number of days before present to fetch data for (default 30, maximum 30).

**Example:**

Get various statistics about actions taken by admins of the French Wikipedia
over the past week:

https://xtools.wmflabs.org/api/project/adminstats/frwiki/7
https://xtools.wmflabs.org/api/project/adminstats/fr.wikipedia.org/7

0 comments on commit 7febf54

Please sign in to comment.