Skip to content

Commit

Permalink
Fix database name for sat.wikipedia
Browse files Browse the repository at this point in the history
use Main Page if 'Cat' and 'Dog' don't exist
  • Loading branch information
MusikAnimal committed Aug 9, 2018
1 parent bcd3411 commit 56872cc
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 27 deletions.
23 changes: 15 additions & 8 deletions javascripts/pageviews/pageviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ class PageViews extends mix(Pv).with(ChartHelpers) {
this.setInitialChartType(pages.length);
getPageInfoAndSetDefaults(pages);
}).fail(() => {
// manually hide spinny since we aren't drawing the chart,
// again using setTimeout to let everything catch up
setTimeout(this.stopSpinny.bind(this));
this.resetView();
this.setInitialChartType();
// leave Select2 empty and put focus on it so they can type in pages
this.focusSelect2();
Expand All @@ -167,6 +165,12 @@ class PageViews extends mix(Pv).with(ChartHelpers) {
getDefaultPages() {
const dfd = $.Deferred();

const getMainPage = () => {
this.fetchSiteInfo(this.project).done(siteInfo => {
dfd.resolve([siteInfo[this.project].general.mainpage]);
}).fail(dfd.reject);
};

// only set default of Cat and Dog for enwiki
if (this.project === 'en.wikipedia') {
dfd.resolve(['Cat', 'Dog']);
Expand All @@ -182,16 +186,19 @@ class PageViews extends mix(Pv).with(ChartHelpers) {

const dbName = Object.keys(siteMap).find(key => siteMap[key] === `${this.project}.org`);
const pages = Object.keys(data.entities).map(key => {
return data.entities[key].sitelinks[dbName].title;
});
return data.entities[key].sitelinks[dbName] ? data.entities[key].sitelinks[dbName].title : null;
}).filter(Boolean);

// 'Cat' and 'Dog' do not exist, so use the Main Page.
if (!pages.length) {
return getMainPage();
}

dfd.resolve(pages);
});
} else {
// get mainpage from siteinfo
this.fetchSiteInfo(this.project).done(siteInfo => {
dfd.resolve([siteInfo[this.project].general.mainpage]);
}).fail(dfd.reject);
getMainPage();
}

return dfd;
Expand Down
2 changes: 1 addition & 1 deletion javascripts/shared/site_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ const siteMap = {
'rwwiktionary': 'rw.wiktionary.org',
'sahwiki': 'sah.wikipedia.org',
'sahwikisource': 'sah.wikisource.org',
'satwikipedia': 'sat.wikipedia.org',
'satwiki': 'sat.wikipedia.org',
'sawiki': 'sa.wikipedia.org',
'sawikibooks': 'sa.wikibooks.org',
'sawikiquote': 'sa.wikiquote.org',
Expand Down
2 changes: 1 addition & 1 deletion public_html/langviews/application.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public_html/massviews/application.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 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.

2 changes: 1 addition & 1 deletion public_html/metaviews/application.js

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions public_html/pageviews/application.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public_html/redirectviews/application.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public_html/siteviews/application.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public_html/topviews/application.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public_html/userviews/application.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion site_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@
"sa.wiktionary.org": "sawiktionary",
"sah.wikipedia.org": "sahwiki",
"sah.wikisource.org": "sahwikisource",
"sat.wikipedia.org": "satwikipedia",
"sat.wikipedia.org": "satwiki",
"sc.wikipedia.org": "scwiki",
"sc.wiktionary.org": "scwiktionary",
"scn.wikipedia.org": "scnwiki",
Expand Down

0 comments on commit 56872cc

Please sign in to comment.