Skip to content

Commit

Permalink
Add 'current' and 'last-week' URL shortcuts for the date range
Browse files Browse the repository at this point in the history
  • Loading branch information
MusikAnimal committed Jun 19, 2018
1 parent edeea19 commit f22b8d3
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 34 deletions.
5 changes: 4 additions & 1 deletion javascripts/shared/pv.js
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,10 @@ class Pv extends PvConfig {
startDate = moment(this.config.maxDatePagecounts).subtract(this.config.daysAgo, 'days');
} else {
Object.keys(this.config.specialRanges).forEach(key => {
if (key === 'latest') return; // this is a function, not meant to be in the list of special ranges
// These are functions or otherwise not meant to be in the list of special ranges.
if (['latest', 'current', 'last-week'].includes(key)) {
return;
}
ranges[$.i18n(key)] = this.config.specialRanges[key];
});
startDate = moment().subtract(this.config.daysAgo, 'days');
Expand Down
2 changes: 2 additions & 0 deletions javascripts/shared/pv_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ class PvConfig {
maxDatePagecounts,
maxMonthPagecounts,
specialRanges: {
'current': [maxDate, maxDate],
'this-week': [moment().startOf('week'), moment().startOf('week').isAfter(maxDate) ? moment().startOf('week') : maxDate],
'last-week': [moment().subtract(1, 'week').startOf('isoweek'), moment().subtract(1, 'week').endOf('isoweek')],
'this-month': [moment().startOf('month'), moment().startOf('month').isAfter(maxDate) ? moment().startOf('month') : maxDate],
'last-month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
Expand Down
2 changes: 2 additions & 0 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@
"target": "target",
"th": "Th",
"this-month": "This month",
"this-week": "This week",
"this-year": "This year",
"title": "Pageviews Analysis",
"tool-labs": "Toolforge",
Expand All @@ -345,6 +346,7 @@
"url-structure-agent": "One of $1 (human viewer, default), $2 (search engine crawlers), $3 (WMF bots) or $4 ($1, $2 and $3)",
"url-structure-agent-no-bots": "One of $1 (human viewer, default), $2 (search engine crawlers), or $3 ($1 and $2)",
"url-structure-autolog": "Set to $1 to disable automatically setting the $2 option",
"url-structure-current": "The latest available day.",
"url-structure-end-date": "End date in the format $1, defaults to previous day.",
"url-structure-end-month": "Using the format $1 will be treated as the end month, and show monthly data instead of daily.",
"url-structure-example": "To get the latest data on a given page on your wiki, with default options, use:\n$1\nreplacing $2 with a valid $3. $4 will resolve to the page the link is placed on",
Expand Down
6 changes: 4 additions & 2 deletions messages/qqq.json
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,9 @@
"subpages": "Label for the 'Subpages' input field on the Massviews tool. See the wikidata item for 'Project:Subpages' for possible translations: https://www.wikidata.org/wiki/Q4592255\n{{Identical|Subpage}}",
"target": "In the Redirect Views app, a page of all redirects to a given page are shown. This 'Target' text is shown next to the given page, which is the target of all the other redirects. This text should be lowercased, if possible.\n{{Identical|Target}}",
"th": "Abbreviation for Thursday, a day of the week.",
"this-month": "Link to set the date range to the current month\n{{Identical|This month}}",
"this-year": "Link to set the date range to the current year\n{{Identical|This year}}",
"this-month": "Link to set the date range to the current month",
"this-week": "Link to set the date range to the current week",
"this-year": "Link to set the date range to the current year",
"title": "The title of the tool. This is shown as a header at the top of the page.",
"tool-labs": "The name of the hosting service. See https://wikitech.wikimedia.org/wiki/Portal:Tool_Labs for more information.",
"topviews": "Abbreviated name of the Topviews application. This is used in the inter-app links in the header",
Expand All @@ -359,6 +360,7 @@
"url-structure-agent": "States the 'agent' parameter can have one of the values 'user' ($1), 'spider' ($2), 'bot' ($3), or 'all-agents' ($4). Each of these will be in a <code> tag. All the words in the message can be translated.",
"url-structure-agent-no-bots": "Same as the 'url-structure-agent' message except 'bots' are not one the values. This explains the 'agent' parameter for Siteviews, which can have one of the values 'user' ($1), 'spider' ($2) or 'all-agents' ($3). Each of these will be in a <code> tag.",
"url-structure-autolog": "Documentation for the 'autolog' parameter. $1 is the only valid value for this parameter, and $2 is the i18n message 'logarithmic-scale'.",
"url-structure-current": "Documentation for the 'current' parameter, which evaluates to the most recent day.",
"url-structure-end-date": "Documentation for the 'end' parameter, stating it defaults to the previous day. $1 is the date format used.",
"url-structure-end-month": "Documentation for the 'end' parameter when targeting a specific month instead of a day. $1 is the format used.",
"url-structure-example": "Example of how to link to Pageviews Analysis on a wiki. $1 is the example link, $2 is the example project, $3 is the link to the site matrix, $4 is {{FULLPAGENAMEE}}",
Expand Down
22 changes: 11 additions & 11 deletions public_html/langviews/application.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public_html/massviews/application.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions public_html/mediaviews/application.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions public_html/metaviews/application.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions public_html/metaviews/application.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public_html/pageviews/application.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions public_html/redirectviews/application.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions public_html/siteviews/application.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions public_html/topviews/application.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions public_html/url_parts/_date_ranges.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
<code>latest-<i>N</i></code>
<?php echo $I18N->msg( 'url-structure-special-range-latest-n' ); ?>
</li>
<li>
<code>current</code>
<?php echo $I18N->msg( 'url-structure-current' ); ?>
</li>
<li>
<code>this-week</code>
<?php echo $defaultRange === 'this-week' ? $defaultMsg : ''; ?>
<?php echo $I18N->msg( 'this-week' ); ?>
</li>
<li>
<code>last-week</code>
<?php echo $defaultRange === 'last-week' ? $defaultMsg : ''; ?>
Expand Down
4 changes: 2 additions & 2 deletions public_html/userviews/application.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions views/url_parts/_date_ranges.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
%li
%code latest-<i>N</i>
= $I18N->msg( 'url-structure-special-range-latest-n' )
%li
%code current
= $I18N->msg( 'url-structure-current' )
%li
%code this-week
= $defaultRange === 'this-week' ? $defaultMsg : ''
= $I18N->msg( 'this-week' )
%li
%code last-week
= $defaultRange === 'last-week' ? $defaultMsg : ''
Expand Down

0 comments on commit f22b8d3

Please sign in to comment.