GitHub PullRequestEvent at 2014-05-05 08:05:52
Repository: olympia
Actor: magopian
Payload: {"action":"closed","number":18,"pull_request":{"url":"https://api.github.com/repos/mozilla/olympia/pulls/18","id":13834298,"html_url":"https://github.com/mozilla/olympia/pull/18","diff_url":"https://github.com/mozilla/olympia/pull/18.diff","patch_url":"https://github.com/mozilla/olympia/pull/18.patch","issue_url":"https://api.github.com/repos/mozilla/olympia/issues/18","number":18,"state":"closed","title":"Locale priorization for translations (bug 983749)","user":{"login":"magopian","id":167767,"avatar_url":"https://avatars.githubusercontent.com/u/167767?","gravatar_id":"9b35c43d59d44db55b7e4dc8b5e3626b","url":"https://api.github.com/users/magopian","html_url":"https://github.com/magopian","followers_url":"https://api.github.com/users/magopian/followers","following_url":"https://api.github.com/users/magopian/following{/other_user}","gists_url":"https://api.github.com/users/magopian/gists{/gist_id}","starred_url":"https://api.github.com/users/magopian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magopian/subscriptions","organizations_url":"https://api.github.com/users/magopian/orgs","repos_url":"https://api.github.com/users/magopian/repos","events_url":"https://api.github.com/users/magopian/events{/privacy}","received_events_url":"https://api.github.com/users/magopian/received_events","type":"User","site_admin":false},"body":"fix [bug 983749](https://bugzilla.mozilla.org/show_bug.cgi?id=983749)\r\n\r\nThe aim of this PR is to have various fallbacks when requesting a translation,\r\nand not only one as we have at the moment.\r\n\r\nBefore: first get the translation for the active language, and if there's none,\r\ncheck if there's a fallback translation (either in a locale provided via\r\n```model.get_fallback()```, or the ```settings.LANGUAGE_CODE```).\r\n\r\nAfter: Check the following locales in order\r\n1/ the active language\r\n2/ the model fallback provided by the ```get_fallback()``` method (if it exists)\r\n3/ ```settings.LANGUAGE_CODE```\r\n4/ in last resort return just any translation found\r\n\r\nThis PR is quite hairy, as I implemented it in a way to minimize the number of\r\njoins: if the three locales to choose from are all the same, just join twice\r\n(once for the locale, and once for the \"last chance\" fallback returning any\r\ntranslation) instead of four times.\r\n\r\nI've tried to factorize as much code possible between ```translation.query```\r\nand ```translation.transformer.build_query```, but both are using different\r\nAPIs, and for different use cases, so the only bit in common is the\r\n```get_locales``` function.\r\n\r\nI've tried to comment it as thoroughly as possible to ease the review and the\r\nmaintenance, but I aknowledge that it's still a big piece of SQL generation,\r\nand deep django code.\r\nIf you need help understand some pieces of the code, please let me know and\r\nI'll try my best to explain it.","created_at":"2014-03-21T13:01:28Z","updated_at":"2014-05-05T08:05:52Z","closed_at":"2014-05-05T08:05:52Z","merged_at":null,"merge_commit_sha":"8d5e0963da7b9ab27a96c31dbfcec5d05437c51b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/olympia/pulls/18/commits","review_comments_url":"https://api.github.com/repos/mozilla/olympia/pulls/18/comments","review_comment_url":"https://api.github.com/repos/mozilla/olympia/pulls/comments/{number}","comments_url":"https://api.github.com/repos/mozilla/olympia/issues/18/comments","statuses_url":"https://api.github.com/repos/mozilla/olympia/statuses/c7927766b32421e4ee98c90434947a9d3e74f2b4","head":{"label":"magopian:983749-locale-priorization-for-translations","ref":"983749-locale-priorization-for-translations","sha":"c7927766b32421e4ee98c90434947a9d3e74f2b4","user":{"login":"magopian","id":167767,"avatar_url":"https://avatars.githubusercontent.com/u/167767?","gravatar_id":"9b35c43d59d44db55b7e4dc8b5e3626b","url":"https://api.github.com/users/magopian","html_url":"https://github.com/magopian","followers_url":"https://api.github.com/users/magopian/followers","following_url":"https://api.github.com/users/magopian/following{/other_user}","gists_url":"https://api.github.com/users/magopian/gists{/gist_id}","starred_url":"https://api.github.com/users/magopian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magopian/subscriptions","organizations_url":"https://api.github.com/users/magopian/orgs","repos_url":"https://api.github.com/users/magopian/repos","events_url":"https://api.github.com/users/magopian/events{/privacy}","received_events_url":"https://api.github.com/users/magopian/received_events","type":"User","site_admin":false},"repo":{"id":17664164,"name":"olympia","full_name":"magopian/olympia","owner":{"login":"magopian","id":167767,"avatar_url":"https://avatars.githubusercontent.com/u/167767?","gravatar_id":"9b35c43d59d44db55b7e4dc8b5e3626b","url":"https://api.github.com/users/magopian","html_url":"https://github.com/magopian","followers_url":"https://api.github.com/users/magopian/followers","following_url":"https://api.github.com/users/magopian/following{/other_user}","gists_url":"https://api.github.com/users/magopian/gists{/gist_id}","starred_url":"https://api.github.com/users/magopian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magopian/subscriptions","organizations_url":"https://api.github.com/users/magopian/orgs","repos_url":"https://api.github.com/users/magopian/repos","events_url":"https://api.github.com/users/magopian/events{/privacy}","received_events_url":"https://api.github.com/users/magopian/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/magopian/olympia","description":"AMO, reloaded.","fork":true,"url":"https://api.github.com/repos/magopian/olympia","forks_url":"https://api.github.com/repos/magopian/olympia/forks","keys_url":"https://api.github.com/repos/magopian/olympia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/magopian/olympia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/magopian/olympia/teams","hooks_url":"https://api.github.com/repos/magopian/olympia/hooks","issue_events_url":"https://api.github.com/repos/magopian/olympia/issues/events{/number}","events_url":"https://api.github.com/repos/magopian/olympia/events","assignees_url":"https://api.github.com/repos/magopian/olympia/assignees{/user}","branches_url":"https://api.github.com/repos/magopian/olympia/branches{/branch}","tags_url":"https://api.github.com/repos/magopian/olympia/tags","blobs_url":"https://api.github.com/repos/magopian/olympia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/magopian/olympia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/magopian/olympia/git/refs{/sha}","trees_url":"https://api.github.com/repos/magopian/olympia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/magopian/olympia/statuses/{sha}","languages_url":"https://api.github.com/repos/magopian/olympia/languages","stargazers_url":"https://api.github.com/repos/magopian/olympia/stargazers","contributors_url":"https://api.github.com/repos/magopian/olympia/contributors","subscribers_url":"https://api.github.com/repos/magopian/olympia/subscribers","subscription_url":"https://api.github.com/repos/magopian/olympia/subscription","commits_url":"https://api.github.com/repos/magopian/olympia/commits{/sha}","git_commits_url":"https://api.github.com/repos/magopian/olympia/git/commits{/sha}","comments_url":"https://api.github.com/repos/magopian/olympia/comments{/number}","issue_comment_url":"https://api.github.com/repos/magopian/olympia/issues/comments/{number}","contents_url":"https://api.github.com/repos/magopian/olympia/contents/{+path}","compare_url":"https://api.github.com/repos/magopian/olympia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/magopian/olympia/merges","archive_url":"https://api.github.com/repos/magopian/olympia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/magopian/olympia/downloads","issues_url":"https://api.github.com/repos/magopian/olympia/issues{/number}","pulls_url":"https://api.github.com/repos/magopian/olympia/pulls{/number}","milestones_url":"https://api.github.com/repos/magopian/olympia/milestones{/number}","notifications_url":"https://api.github.com/repos/magopian/olympia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/magopian/olympia/labels{/name}","releases_url":"https://api.github.com/repos/magopian/olympia/releases{/id}","created_at":"2014-03-12T11:05:51Z","updated_at":"2014-04-30T14:48:32Z","pushed_at":"2014-04-30T14:48:31Z","git_url":"git://github.com/magopian/olympia.git","ssh_url":"git@github.com:magopian/olympia.git","clone_url":"https://github.com/magopian/olympia.git","svn_url":"https://github.com/magopian/olympia","homepage":"","size":183516,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"8a198cc36438e999e53b5048408405425fcb880f","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?","gravatar_id":"9ba739c8f3288e256b13553e4d257b5e","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":16416867,"name":"olympia","full_name":"mozilla/olympia","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?","gravatar_id":"9ba739c8f3288e256b13553e4d257b5e","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/olympia","description":"addons.mozilla.org, reloaded.","fork":false,"url":"https://api.github.com/repos/mozilla/olympia","forks_url":"https://api.github.com/repos/mozilla/olympia/forks","keys_url":"https://api.github.com/repos/mozilla/olympia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/olympia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/olympia/teams","hooks_url":"https://api.github.com/repos/mozilla/olympia/hooks","issue_events_url":"https://api.github.com/repos/mozilla/olympia/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/olympia/events","assignees_url":"https://api.github.com/repos/mozilla/olympia/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/olympia/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/olympia/tags","blobs_url":"https://api.github.com/repos/mozilla/olympia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/olympia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/olympia/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/olympia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/olympia/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/olympia/languages","stargazers_url":"https://api.github.com/repos/mozilla/olympia/stargazers","contributors_url":"https://api.github.com/repos/mozilla/olympia/contributors","subscribers_url":"https://api.github.com/repos/mozilla/olympia/subscribers","subscription_url":"https://api.github.com/repos/mozilla/olympia/subscription","commits_url":"https://api.github.com/repos/mozilla/olympia/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/olympia/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/olympia/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/olympia/issues/comments/{number}","contents_url":"https://api.github.com/repos/mozilla/olympia/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/olympia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/olympia/merges","archive_url":"https://api.github.com/repos/mozilla/olympia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/olympia/downloads","issues_url":"https://api.github.com/repos/mozilla/olympia/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/olympia/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/olympia/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/olympia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/olympia/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/olympia/releases{/id}","created_at":"2014-01-31T18:44:15Z","updated_at":"2014-05-04T11:08:53Z","pushed_at":"2014-05-04T11:08:52Z","git_url":"git://github.com/mozilla/olympia.git","ssh_url":"git@github.com:mozilla/olympia.git","clone_url":"https://github.com/mozilla/olympia.git","svn_url":"https://github.com/mozilla/olympia","homepage":"https://addons.mozilla.org/","size":206281,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":20,"mirror_url":null,"open_issues_count":13,"forks":20,"open_issues":13,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/olympia/pulls/18"},"html":{"href":"https://github.com/mozilla/olympia/pull/18"},"issue":{"href":"https://api.github.com/repos/mozilla/olympia/issues/18"},"comments":{"href":"https://api.github.com/repos/mozilla/olympia/issues/18/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/olympia/pulls/18/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/olympia/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/mozilla/olympia/pulls/18/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/olympia/statuses/c7927766b32421e4ee98c90434947a9d3e74f2b4"}},"merged":false,"mergeable":false,"mergeable_state":"dirty","merged_by":null,"comments":2,"review_comments":9,"commits":8,"additions":267,"deletions":92,"changed_files":8}}