-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add setting dates range for Page History #149
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome! I left a few comments. This is not a complete review. I unfortunately might be away much of the day, but I'll definitely get to this as soon as possible.
@@ -121,13 +121,22 @@ public function gadgetAction(Request $request) | |||
|
|||
/** | |||
* Display the results. | |||
* @Route("/articleinfo/{project}/{article}", name="ArticleInfoResult", requirements={"article"=".+"}) | |||
* @Route( | |||
* "/articleinfo/{project}/{start}/{end}/{article}", name="ArticleInfoResult", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This routing change will be a problem :( ArticleInfo is very popular and there are a lot of links to it. As optional parameters it'd be better if the start/end dates are at the end, but I suppose there's the caveat that "My article/2017-01-23/2018-01-23" is a valid page title.
Maybe we should use query string parameters instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we could use some trickery to handle the "My article/2017-01-23/2018-01-23" edge case, or perhaps we don't care... Interested to hear your thoughts.
src/Xtools/ArticleInfo.php
Outdated
/** @var false|int From what date to obtain records. */ | ||
protected $startDate; | ||
|
||
/** @var false|string To what date to obtain records. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string
or int
?
src/Xtools/ArticleInfo.php
Outdated
} | ||
|
||
list($start, $end) = $this->translateDatesToYYYYMMDD($this->startDate, $this->endDate); | ||
list($start, $end) = $this->applyDatesDefaults($start, $end, $latest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused why we're using $latest
in this case. The pageviews should be for the same date as what was requested. So if they only gave an end date, it'd use the date of the first revision to the specified end date.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was what I meant when I told you on IRC that I have minor logical-thinking problems :D
src/Xtools/ArticleInfoRepository.php
Outdated
* @param string $field | ||
* @return string | ||
*/ | ||
public static function createDatesConditions($start, $end, $tableAlias = '', $field = 'rev_timestamp') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we moved this to Repository
? Then it's accessible in PageRepository, ArticleInfoRepository, etc., and it doesn't have to be static.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I second that
Now that I'm finally home, I'm able to do a more thorough review. A few more issues, I'm afraid:
Some things simply need to be hidden when there is a date range:
If you need/want help with ANY of this please feel free to ask. I was worried this task was a bit too big, so don't feel like you have to do everything! |
I localized issue of having all months to be here: xtools/src/Xtools/ArticleInfo.php Lines 851 to 867 in d0838b9
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking really good!! Just a few more minor complaints :) Thanks so much, I know this is a lot of work!
web/static/css/application.scss
Outdated
@include center('vertical'); | ||
right: 0; | ||
font-size: 70%; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor complaint: We could use some mobile-friendliness here, something like:
@media (max-width: $bootstrap-sm) {
.date-range {
display: block;
position: relative;
top: 0;
transform: none;
}
}
@@ -42,7 +57,7 @@ | |||
{% if ai.assessments and not (page.isMainPage) %} | |||
{% set sections = sections|merge(['assessments']) %} | |||
{% endif %} | |||
{% if ai.numBugs > 0 %} | |||
{% if ai.numBugs > 0 and not (ai.hasDateRange) %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do not (ai.hasDateRange)
first, because ai.numBugs
will run the queries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need the not (ai.hasDateRange)
check on line 57
@@ -92,7 +107,7 @@ | |||
</td> | |||
<td>{{ ai.numEditors|num_format }}</td> | |||
</tr> | |||
{% if ai.assessments and not (page.isMainPage) %} | |||
{% if ai.assessments and not (page.isMainPage) and not (page.hasDateRange) %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ai.hasDateRange
(not page
), and again I'd put this check before ai.assessments
@@ -260,22 +277,22 @@ | |||
<td>{{ msg('links-external') }}</td> | |||
<td>{{ ai.linksExtCount|num_format }}</td> | |||
</tr> | |||
{% if page.watchers is not empty %} | |||
{% if page.watchers is not empty and not (ai.hasDateRange) %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not (ai.hasDateRange)
first. Here I think Page::getPageInfo()
has already been ran, but good to be consistent with the placement of the hasDateRange check.
<td> | ||
{{ wiki.pageviewsLink(page, ai.pageviews(pageviewsOffset)|num_format, 'range=latest-' ~ pageviewsOffset) }} | ||
</td> | ||
</tr> | ||
{% endif %} | ||
|
||
{% if ai.numBugs > 0 %} | ||
{% if ai.numBugs > 0 and not (ai.hasDateRange) %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not (ai.hasDateRange)
first
@@ -753,7 +770,7 @@ | |||
{% endif %} | |||
|
|||
{# ======================== ASSESSMENTS ======================== #} | |||
{% if ai.assessments and not (page.isMainPage) %} | |||
{% if ai.assessments and not (page.isMainPage) and not (ai.hasDateRange) %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not (ai.hasDateRange)
first
@@ -792,7 +809,7 @@ | |||
{% endif %} | |||
|
|||
{# ======================== BUGS ======================== #} | |||
{% if ai.numBugs > 0 %} | |||
{% if ai.numBugs > 0 and not (ai.hasDateRange) %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not (ai.hasDateRange)
first
)}} · {{ extLink( | ||
'https://tools.wmflabs.org/redirectviews?project=' ~ page.project.domain ~ '&page=' ~ page.title, | ||
msg('redirects') | ||
msg('redirects') ~ start is not null ? ('&start=' ~ start) : '' ~ end is not null ? ('&end=' ~ end) : '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the ~ start ...
is next to the link text and not in the URL.
@@ -217,17 +217,17 @@ | |||
{{ extLink(url, msg('pageviews'), label) }} | |||
{% endspaceless %}{% endmacro %} | |||
|
|||
{% macro pageviewsLinks(page) %}{% spaceless %} | |||
{% macro pageviewsLinks(page, start, end) %}{% spaceless %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might consider setting the defaults start = null, end = null
, then we don't need the null checks at https://github.com/x-tools/xtools/pull/149/files#diff-fefe304fbb1893557366c352e22673cfR42
$article = $matches[1]; | ||
$start = $matches[2]; | ||
$end = $matches[3]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
Bug: T181694
Bug: T181694