Skip to content

Add analytics pageview module, spec, and tests#350

Merged
d00rman merged 14 commits intowikimedia:masterfrom
milimetric:master
Oct 2, 2015
Merged

Add analytics pageview module, spec, and tests#350
d00rman merged 14 commits intowikimedia:masterfrom
milimetric:master

Conversation

@milimetric
Copy link
Copy Markdown
Contributor

This commit just adds the backend necessary to serve analytics
data. We will add any code needed to configure a front-end in a later
pull request.

Bug: T107053

@Pchelolo
Copy link
Copy Markdown
Contributor

@milimetric Hm, the PRs seem to to get duplicated (#343) Can I close the first one?

Comment thread specs/analytics_v1_pageviews.yaml Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The source of your problem is indentation here. Should be:

x-request-handler:
  - get_from_backend:
      # Note how `request` is one-tab more indented than it your code.
      request:
        uri: ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

oops. I noticed the error was about a syntax problem, but I didn't know how to go from there to where the problem was. Do you all use a linter or just know what problems to look for?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@milimetric The error message was indeed not too descriptive, I would've get confused if I didn't know what's going on. We should make an error message more self-explanatory

@Pchelolo
Copy link
Copy Markdown
Contributor

I think after fixing errors I've pointed the tests should pass. I'll take one more closer look after that, but in general this all looks good. The only big think left is bike shedding on spec's naming.

@gwicke
Copy link
Copy Markdown
Member

gwicke commented Sep 22, 2015

This kind of brings up the question of whether RESTBase should eventually contain and test a union of all possible RESTBase configs. Right now we bundle the Wikimedia sub-specs & test them along with RESTBase-the-framework, but at some point we might want to separate the config from the code.

Comment thread specs/test.yaml Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should become /{module:pageviews}/insert-top/{project}/{access}/{year}/{month}/{day}/{data} and everything will go well

@Pchelolo
Copy link
Copy Markdown
Contributor

Except for two tiny nits this all looks good to me. (given that we didn't finish choosing the spec directory structure vs plain files, but that could be added/fixed separately.

Comment thread mods/pageviews.js Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation for the whole function.

Comment thread mods/pageviews.js Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dot in .org should be escaped. Also, I think a cleaner way of doing the would be rp.project.replace(/\.org$/, ''), but it's up to you.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to both.

Comment thread mods/pageviews.js Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A sanity check for values would be good for all three blocks here (as in, I can put in only digits, but that's not enough for the date to be valid).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to add a note, maybe I should have. The only way to fully validate the dates would be to include another library, because basic checking still wouldn't consider leap years, leap seconds, etc. Given that, I just do basic validation and assume a 404 is good enough for when people send invalid dates. If you'd like to see another library here, that's cool with me, I just didn't want to add to the dependency tree.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have validateTimestamp we should make it work for this case too, i.e. supply it rp.year, rp.month and rp.day and see if the date is valid.

@d00rman
Copy link
Copy Markdown
Contributor

d00rman commented Sep 29, 2015

Modulo some minor comments and nits, LGTM. @wikimedia/services thoughts?

@milimetric
Copy link
Copy Markdown
Contributor Author

Thanks Marko, I think I patched everything except the date construction
suggestion. That needs to use the weird string concat so we can specify
'UTC', otherwise this validation won't work when it runs in different time
zones. Even though all our servers use UTC (thank deity), testing would be
affected.

On Tue, Sep 29, 2015 at 5:23 PM, Marko Obrovac notifications@github.com
wrote:

Modulo some minor comments and nits, LGTM. @wikimedia/services
https://github.com/orgs/wikimedia/teams/services thoughts?


Reply to this email directly or view it on GitHub
#350 (comment).

Comment thread mods/pageviews.js Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we need to provide such level of detail here. For 2014-01-49 all 3 errors would happen, while year and month are valid. I think just returning smth like 'Invalid timestamp' would be enough

@Pchelolo
Copy link
Copy Markdown
Contributor

LGTM 👍

Comment thread mods/pageviews.js Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: should probably be queryResponder (sorry, my OCD doesn't allow me to ignore this) :P

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:) Sorry for the pun. It's not quite a responder because it's not responding to queries, it's just fixing the response. I'll name it accordingly.

@d00rman
Copy link
Copy Markdown
Contributor

d00rman commented Sep 30, 2015

LGTM too 👍

@d00rman
Copy link
Copy Markdown
Contributor

d00rman commented Oct 1, 2015

@milimetric just rebase on top of master and we're GTG!

marcelrf and others added 14 commits October 1, 2015 09:49
NOTE: this commit just adds the backend necessary to serve analytics
data.  We will add any code needed to configure a front-end in a later
pull request.

Bug: T107053
* Bad parameters - throw 400 error, some tests check this
* No data found - let 404 bubble up, no tests, part of framework, but I
                  removed the logic that was changing 404s into 200s
d00rman pushed a commit that referenced this pull request Oct 2, 2015
Add analytics pageview module, spec, and tests
@d00rman d00rman merged commit 176eebd into wikimedia:master Oct 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants