Skip to content
This repository was archived by the owner on Dec 11, 2018. It is now read-only.

Commit 1109ab2

Browse files
committed
Wikitext export report
1 parent 63a7fe2 commit 1109ab2

File tree

8 files changed

+174
-0
lines changed

8 files changed

+174
-0
lines changed

data/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"nav-proposals-search": "Search",
1919
"nav-reports": "Reports",
2020
"nav-reports-aggregated": "Aggregated scores",
21+
"nav-reports-wikitext": "Wikitext export",
2122
"nav-admin": "Admin",
2223
"nav-users": "Manage users",
2324
"nav-account": "My Account",

data/i18n/qqq.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
"nav-proposals-queue": "Navigation menu label for grant proposals review queue.",
5454
"nav-proposals-search": "Navigation menu label for grant proposal search.",
5555
"nav-reports": "Navigation menu label for list of report pages.\n{{Identical|Report}}",
56+
"nav-reports-aggregated": "Navigation menu label for aggregate results report.",
57+
"nav-reports-wikitext": "Navigation menu label for wikitext export report.",
5658
"nav-users": "Navigation menu label, links to user list page",
5759
"new-account-email": "Email body. Parameters:\n* $1 - Account username\n* $2 - Acocunt password\n* $3 - URL to login page of application\n* $4 - URL to password change page of application",
5860
"new-account-subject": "Email subject",

data/templates/nav_user.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ 'nav-reports'|message }} <b class="caret"></b></a>
1919
<ul class="dropdown-menu">
2020
<li><a href="{{ urlFor( 'reports_aggregated' ) }}">{{ 'nav-reports-aggregated'|message }}</a></li>
21+
<li><a href="{{ urlFor( 'reports_wikitext' ) }}">{{ 'nav-reports-wikitext'|message }}</a></li>
2122
</ul>
2223
</li>
2324
{% endif %}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{% extends 'reports/base.html' %}
2+
3+
{% block subtitle %}{{ 'nav-reports-wikitext'|message }}{% endblock %}
4+
5+
{% block content %}
6+
{% spaceless %}
7+
<ol class="breadcrumb">
8+
<li>{{ 'nav-reports'|message }}</li>
9+
<li><a href="{{ urlFor( 'reports_wikitext' ) }}">{{ 'nav-reports-wikitext'|message }}</a></li>
10+
</ol>
11+
12+
<div class="panel-group" id="accordion">
13+
{% for row in report.rows %}
14+
<div class="panel panel-default">
15+
<div class="panel-heading">
16+
<h4 class="panel-title">
17+
<a class="accordion-toggle collapsed block" data-toggle="collapse" data-parent="#accordion" href="#proposal{{ row.id }}">
18+
{{ row.title }}
19+
<small>
20+
{{ row.pcnt|number_format(2) }}%
21+
({{ row.recommend }}/{{ row.rcnt }}){{ row.conditional }}
22+
</small>
23+
</a>
24+
</h4>
25+
</div>
26+
<div id="proposal{{ row.id }}" class="panel-collapse collapse">
27+
<div class="panel-body form-group">
28+
<a href="{{ row.url|raw }}" target="_blank">{{ row.title }}</a>
29+
<textarea class="form-control" rows="10" readonly>
30+
{{ '{{' }}IEG/Committee/Review/Score/2
31+
| A score={{ row.impact|number_format(1) }}
32+
| B score={{ row.innovation|number_format(1) }}
33+
| C score={{ row.ability|number_format(1) }}
34+
| D score={{ row.engagement|number_format(1) }}
35+
| comments=
36+
{% for comment in row.comments %}
37+
* {{ comment|replace( { "\n":' ' } ) }}
38+
{% endfor %}
39+
{{ '}}' }}
40+
</textarea>
41+
</div>
42+
</div>
43+
</div>
44+
{% endfor %}
45+
</div>
46+
47+
{% endspaceless %}
48+
{% endblock content %}

public/css/main.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ a:visited {
9999

100100
a.accordion-toggle {
101101
text-decoration:none;
102+
color:inherit;
102103
}
103104

104105
a.sortable {
@@ -117,3 +118,7 @@ a.sortable.sorted-asc {
117118
a.sortable.sorted-desc {
118119
background-image: url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7);
119120
}
121+
122+
.block {
123+
display:block;
124+
}

src/App.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,12 @@ function () use ( $slim, $middleware ) {
447447
$page->setDao( $slim->reportsDao );
448448
$page();
449449
} )->name( 'reports_aggregated' );
450+
451+
$slim->get( 'wikitext', function () use ( $slim ) {
452+
$page = new Controllers\Reports\Wikitext( $slim );
453+
$page->setDao( $slim->reportsDao );
454+
$page();
455+
} )->name( 'reports_wikitext' );
450456
} );
451457

452458
$slim->group( '/admin/',
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* @section LICENSE
4+
* This file is part of Wikimedia IEG Grant Review application.
5+
*
6+
* Wikimedia IEG Grant Review application is free software: you can
7+
* redistribute it and/or modify it under the terms of the GNU General Public
8+
* License as published by the Free Software Foundation, either version 3 of
9+
* the License, or (at your option) any later version.
10+
*
11+
* Wikimedia IEG Grant Review application is distributed in the hope that it
12+
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13+
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License along
17+
* with Wikimedia IEG Grant Review application. If not, see
18+
* <http://www.gnu.org/licenses/>.
19+
*
20+
* @file
21+
* @copyright © 2014 Bryan Davis, Wikimedia Foundation and contributors.
22+
*/
23+
24+
namespace Wikimedia\IEGReview\Controllers\Reports;
25+
26+
use Wikimedia\IEGReview\Controller;
27+
28+
/**
29+
* Wikitext export of review status.
30+
*
31+
* @author Bryan Davis <bd808@wikimedia.org>
32+
* @copyright © 2014 Bryan Davis, Wikimedia Foundation and contributors.
33+
*/
34+
class Wikitext extends Controller {
35+
36+
protected function handleGet() {
37+
$this->view->setData( 'report', $this->dao->export() );
38+
$this->render( 'reports/wikitext.html' );
39+
}
40+
}

src/Dao/Reports.php

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ public function aggregatedScores( array $params ) {
7474
$params['sort'] : $defaults['sort'];
7575
$order = $params['order'] === 'desc' ? 'DESC' : 'ASC';
7676

77+
$crit = array();
78+
7779
if ( $params['items'] == 'all' ) {
7880
$limit = '';
7981
$offset = '';
@@ -112,4 +114,73 @@ public function aggregatedScores( array $params ) {
112114
);
113115
return $this->fetchAllWithFound( $sql, $crit );
114116
}
117+
118+
public function export() {
119+
$sql = self::concat(
120+
'SELECT p.id, p.title,',
121+
'r.impact,',
122+
'r.innovation,',
123+
'r.ability,',
124+
'r.engagement,',
125+
'r.recommend,',
126+
'IF(r.conditional >0, \'*\', \'\') AS conditional,',
127+
'r.cnt AS rcnt,',
128+
'ROUND((r.recommend / r.cnt) * 100, 2) AS pcnt',
129+
'FROM proposals p',
130+
'INNER JOIN (',
131+
'SELECT COUNT(*) AS cnt,',
132+
'AVG(impact) AS impact,',
133+
'AVG(innovation) AS innovation,',
134+
'AVG(ability) AS ability,',
135+
'AVG(engagement) AS engagement,',
136+
'SUM(IF(recommendation > 0, 1, 0)) AS recommend,',
137+
'SUM(IF(recommendation = 1, 1, 0)) AS conditional,',
138+
'proposal',
139+
'FROM reviews',
140+
'GROUP BY proposal',
141+
') r ON p.id = r.proposal',
142+
"ORDER BY pcnt DESC, id DESC"
143+
);
144+
$results = $this->fetchAllWithFound( $sql );
145+
146+
$commentsSql = self::concat(
147+
'SELECT proposal,',
148+
'impact_note,',
149+
'innovation_note,',
150+
'ability_note,',
151+
'engagement_note,',
152+
'comments',
153+
'FROM reviews'
154+
);
155+
156+
$comments = array();
157+
foreach ( $this->fetchAll( $commentsSql ) as $row ) {
158+
if ( !isset( $comments[ $row['proposal'] ] ) ) {
159+
$comments[ $row['proposal'] ] = array();
160+
}
161+
if ( $row['impact_note'] ) {
162+
$comments[$row['proposal']][] = $row['impact_note'];
163+
}
164+
if ( $row['innovation_note'] ) {
165+
$comments[$row['proposal']][] = $row['innovation_note'];
166+
}
167+
if ( $row['ability_note'] ) {
168+
$comments[$row['proposal']][] = $row['ability_note'];
169+
}
170+
if ( $row['engagement_note'] ) {
171+
$comments[$row['proposal']][] = $row['engagement_note'];
172+
}
173+
if ( $row['comments'] ) {
174+
$comments[$row['proposal']][] = $row['comments'];
175+
}
176+
}
177+
178+
foreach ( $results->rows as &$row ) {
179+
if ( isset( $comments[$row['id']] ) ) {
180+
$row['comments'] = $comments[$row['id']];
181+
}
182+
}
183+
184+
return $results;
185+
}
115186
}

0 commit comments

Comments
 (0)