Skip to content

Commit

Permalink
Show statistics broken down by wiki family on event page
Browse files Browse the repository at this point in the history
Remove unused 'event_valid' field from event table.

Add message indicating event is missing required options before
statistics can be generated.

Change font to Roboto, and remove unused font file.

Bug: https://phabricator.wikimedia.org/T192579
  • Loading branch information
MusikAnimal committed Jul 25, 2018
1 parent 92bde74 commit f529e9c
Show file tree
Hide file tree
Showing 17 changed files with 397 additions and 184 deletions.
34 changes: 34 additions & 0 deletions app/DoctrineMigrations/Version20180723164137.php
@@ -0,0 +1,34 @@
<?php

namespace Application\Migrations;

use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;

/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20180723164137 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE event DROP event_valid');
}

/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE event ADD event_valid TINYINT(1) DEFAULT \'1\' NOT NULL');
}
}
4 changes: 2 additions & 2 deletions app/Resources/assets/css/application.scss
@@ -1,5 +1,5 @@
@import 'mixins';
@import url('https://tools-static.wmflabs.org/fontcdn/css?family=Open+Sans');
@import url('https://tools-static.wmflabs.org/fontcdn/css?family=Roboto:400,700');

html {
height: 100%;
Expand All @@ -18,7 +18,7 @@ html {
}

body {
font-family: 'Open Sans', sans-serif !important;
font-family: 'Roboto', sans-serif !important;
min-height: 100%;
position: relative;

Expand Down
34 changes: 34 additions & 0 deletions app/Resources/assets/css/events.scss
Expand Up @@ -28,10 +28,19 @@
}
}

// When there are no statistics to show.
.event-metadata ~ .event-section {
margin-top: 30px;
}

.event-metric-desc {
cursor: help;
}

.event-wiki-stats--empty {
margin: 36px 0;
}

.event-stats,
.event-wiki-stats {
margin: 36px 0;
Expand All @@ -42,6 +51,31 @@
}
}

.event-metadata--grouped {
margin: 25px 0;

th {
padding-right: 20px;
}
}

.event-wiki-stats--grouped {
margin: 0;

th,
td {
border: 0;
}

&:last-of-type {
margin-bottom: 30px;
}
}

.event-wiki-stats--grouped-hr {
margin: 5px;
}

.event-stats {
display: flex;
}
Expand Down
9 changes: 9 additions & 0 deletions app/Resources/assets/js/events.js
Expand Up @@ -117,6 +117,15 @@ $(function () {
});
});

/**
* Link to process event in message shown when stats have not yet been generated.
*/
$('.event-process-link').on('click', function (e) {
$('.event-process-btn').trigger('click');
$('.event-wiki-stats--empty').html('&nbsp;');
e.preventDefault();
});

setupAutocompletion();
setupColumnSorting();

Expand Down
Binary file removed app/Resources/fonts/OpenSans-Regular.ttf
Binary file not shown.
4 changes: 2 additions & 2 deletions app/Resources/views/_attribution.html.twig
Expand Up @@ -21,13 +21,13 @@
{% endif %}
<p>
{% set openSans %}
<a target="_blank" href="https://fonts.google.com/specimen/Open+Sans">Open Sans</a>
<a target="_blank" href="https://fonts.google.com/specimen/Open+Sans">Roboto</a>
{% endset %}
{% set apache %}
<a target="_blank" href="https://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</a>
{% endset %}
{% set steve %}
<a target="_blank" href="https://twitter.com/SteveMatteson1">Steve Matteson</a>.
<a target="_blank" href="https://twitter.com/SteveMatteson1">Christian Robertson</a>.
{% endset %}
{{ msg('attribution-font', [openSans, apache, steve]) }}
</p>
Expand Down
82 changes: 82 additions & 0 deletions app/Resources/views/events/_participants.html.twig
@@ -0,0 +1,82 @@
{% import 'macros/layout.html.twig' as layout %}

{% set content %}
{% if isOrganizer %}
{{ form_errors(form) }}

{# Valid participants should be shown below invalid ones. #}
{% set validParticipants = [] %}

{{ form_start(form, {'method': 'post', 'attr': {'class': 'form-horizontal save-participants-form', 'autocomplete': 'off'}}) }}
{% for participant in form.participants %}
{% set invalidParticipant = false %}
{% if not(participant.vars.valid) %}
{% set invalidParticipant = true %}
{% endif %}

{% set participantRow %}
<div class="form-group participant-row{% if invalidParticipant %} has-error{% endif %}">
<div class="col-sm-4">
{{ form_widget(participant, {'attr': {'class': 'user-input'}}) }}
{% if invalidParticipant %}
<span class="font-awesome invalid-input">&#xf071;</span>
{% else %}
<span class="font-awesome valid-input">&#xf05d;</span>
{% endif %}
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-default remove-participant">
{{ msg('remove') }}
</button>
</div>
</div>
{% endset %}

{##
# If invalid, show immediately, otherwise merge into valid ones that
# will show below the invalid ones.
#}
{% if invalidParticipant %}
{{ participantRow }}
{% else %}
{% set validParticipants = validParticipants|merge([participantRow]) %}
{% endif %}
{% endfor %}

{# Render valid participants. #}
{% for row in validParticipants %}
{{ row }}
{% endfor %}

<div class="col-sm-6 col-sm-offset-6 save-participants-btn">
{{ form_widget(form.submit, {'label': msg('save-participants'), 'attr': {'class': 'btn-primary'}}) }}
</div>

<div class="form-group col-sm-6 event-add-participants">
<label for="form_new_participants">{{ msg('add-more-participants') }}</label>
{{ form_widget(form.new_participants, {'attr': {'class': 'event-new-participants', 'rows': 10}}) }}
</div>
{% if form.participants|length == 0 %}
<div class="col-sm-6">
{{ form_widget(form.submit, {'label': msg('save-participants'), 'attr': {'class': 'btn-primary'}}) }}
</div>
{% endif %}

{{ form_row(form._token) }}
{{ form_end(form, {'render_rest': false}) }}
{% else %}
{% for participant in event.participants %}
<div class="participant-row">
{{ participant.username }}
</div>
{% endfor %}
{% endif %}
{% endset %}

{{
layout.eventAccordion(
'participants',
event.numParticipants ~ ' ' ~ msg('num-participants', [event.numParticipants]),
content
)
}}
56 changes: 56 additions & 0 deletions app/Resources/views/events/_wiki_table.html.twig
@@ -0,0 +1,56 @@
{% set metricOrder = [] %}
<table class="table table-hover gm-table event-wiki-stats event-wiki-stats--grouped">
<thead>
<tr>
<th class="col-lg-3"></th>
{% set sortableMetrics = ['pages-created', 'pages-improved'] %}
{% set columnCount = 1 %}
{% for metric, offset in availableMetrics %}
{% if metric not in commonMetrics and event.statistic(metric) is defined %}
{% set columnCount = columnCount + 1 %}
{% set stat = event.statistic(metric) %}
{% set metricOrder = metricOrder|merge([stat.metric]) %}
{% set hasDesc = msgExists(stat.metric ~ '-desc', [stat.offset]) %}
<th class="col-lg-3">
<div class="{% if stat.metric in sortableMetrics %} sort-link sort-link--{{ stat.metric }}{% endif %}{% if hasDesc %} event-metric-desc{% endif %}" {% if hasDesc %} data-toggle="tooltip" data-placement="top" title="{{ msg(stat.metric ~ '-desc', [stat.offset]) }}"{% endif %} data-column="{{ stat.metric }}">
{{ msg(stat.metric, [stat.offset]) }}
</div>
</th>
{% endif %}
{% endfor %}
{% for i in columnCount..3 %}
<th class="col-lg-3"></th>
{% endfor %}
</tr>
{% if wikis|length > 1 %}
<tr>
<th>{{ msg('totals') }}</th>
{% for metric in metricOrder %}
<th>{{ event.statistic(metric).value|num_format }}</th>
{% endfor %}
</tr>
{% endif %}
</thead>
<tbody>
{% for wiki in wikis %}
<tr>
<td class="sort-entry--domain" data-value="{{ wiki.domain }}">
{{ wiki.domain }}
</td>
{% for metric in metricOrder %}
{% set stat = wiki.statistic(metric) %}
<td class="sort-entry--{{ metric }}" data-value="{{ stat != null ? stat.value : -1 }}">
{% if stat != null %}
{{ stat.value|num_format }}
{% else %}
&mdash;
{% endif %}
</td>
{% endfor %}
{% for i in columnCount..3 %}
<td class="col-lg-3"></td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>

0 comments on commit f529e9c

Please sign in to comment.