Milimetric has submitted this change and it was merged.
Change subject: cohort upload working well, must add tests though
......................................................................
cohort upload working well, must add tests though
Change-Id: I3253986ad86952de0d864fff6fff164f3514b4c0
---
M wikimetrics/controllers/cohorts.py
1 file changed, 14 insertions(+), 8 deletions(-)
Approvals:
Milimetric: Verified; Looks good to me, approved
diff --git a/wikimetrics/controllers/cohorts.py
b/wikimetrics/controllers/cohorts.py
index 10fe64b..57a395a 100644
--- a/wikimetrics/controllers/cohorts.py
+++ b/wikimetrics/controllers/cohorts.py
@@ -272,15 +272,26 @@
project = default_project
parsed.append({
- 'raw_username': username,
+ 'raw_username': parse_username(username, decode=False),
'username': parse_username(username),
'project': project,
})
return parsed
-def parse_username(raw_username):
- return str(raw_username).decode('utf8').strip()
++def parse_username(raw_username, decode=True):
+ """
+ parses uncapitalized, whitespace-padded, and weird-charactered mediawiki
+ user names into ones that have a chance of being found in the database
+ """
+ username = str(raw_username)
+ if decode:
+ username = username.decode('utf8')
+ stripped = username.strip()
+ # Capitalize the username according to the Mediawiki standard
+ # NOTE: unfortunately .title() or .capitalize() don't work
+ # because 'miliMetric'.capitalize() == 'Milimetric'
+ return stripped[0].upper() + stripped[1:]
def normalize_project(project):
@@ -324,11 +335,6 @@
def normalize_user(user_str, project):
- # Capitalize the username according to the Mediawiki standard
- # NOTE: unfortunately .title() or .capitalize() don't work
- # because 'miliMetric'.capitalize() == 'Milimetric'
- user_str = user_str[0].upper() + user_str[1:]
-
wikiuser = get_wikiuser_by_name(user_str, project)
if wikiuser is not None:
return (wikiuser.user_id, wikiuser.user_name)
--
To view, visit https://gerrit.wikimedia.org/r/74665
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3253986ad86952de0d864fff6fff164f3514b4c0
Gerrit-PatchSet: 1
Gerrit-Project: analytics/wikimetrics
Gerrit-Branch: master
Gerrit-Owner: Milimetric <[email protected]>
Gerrit-Reviewer: Milimetric <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits