Nuria has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/405398 )
Change subject: [WIP] Simplyfing HTML for WikiSelector menu options
......................................................................
[WIP] Simplyfing HTML for WikiSelector menu options
The menu options can be as high as 500,
with that many it seems that Vue has trouble with property access
but also a DOM insertion of so many nodes is costly. We simplyfy HTML
and remove some of vuew accessors
Also, small caching is added so clearing of search text in selector
doesn't repeat computations
Bug: T185334
Change-Id: Ia81a7445c3715064518026ccc1f149ff230770f0
---
M src/components/WikiSelector.vue
M src/components/widgets/SearchResults.vue
2 files changed, 49 insertions(+), 28 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/analytics/wikistats2
refs/changes/98/405398/1
diff --git a/src/components/WikiSelector.vue b/src/components/WikiSelector.vue
index dffc351..4353af1 100644
--- a/src/components/WikiSelector.vue
+++ b/src/components/WikiSelector.vue
@@ -53,6 +53,10 @@
subtitle: 'name'
};
+
+let sitematrixData = null;
+
+
export default {
name: 'wiki-selector',
@@ -71,6 +75,7 @@
},
mounted () {
+
this.initWithCurrentWiki();
this.initTextWidthMeasurer();
},
@@ -231,26 +236,41 @@
},
getAllSearchData () {
- return Promise.all([
- sitematrix.getWikiGroups(searchDataFormat),
- sitematrix.getProjectFamilies(null, searchDataFormat),
- sitematrix.getLanguages(null, searchDataFormat),
- sitematrix.getSpecialWikis({
- type: true,
- code: 'hostname',
- title: 'name',
- subtitle: 'hostname'
- }),
- sitematrix.getRegularWikis({
- type: true,
- code: 'hostname',
- title: 'hostname',
- subtitle: 'dbname'
- })
- ]).then(values => {
- const [groups, projectFamilies, languages, specials, wikis] =
values;
- return _.concat(groups, projectFamilies, languages, specials,
wikis);
- });
+ // no need to go through all the promise parsing code more than
once
+ // this saves about ~10 ms of execution time (profiled with
console.time)
+ // we probably we can benefit
+ // from this pattern of locally caching data rather that
re-resolve the chain
+ // of promises elsewhere
+
+ if (sitematrixData){
+ return Promise.resolve(sitematrixData);
+ } else {
+
+ return Promise.all([
+ sitematrix.getWikiGroups(searchDataFormat),
+ sitematrix.getProjectFamilies(null, searchDataFormat),
+ sitematrix.getLanguages(null, searchDataFormat),
+ sitematrix.getSpecialWikis({
+ type: true,
+ code: 'hostname',
+ title: 'name',
+ subtitle: 'hostname'
+ }),
+ sitematrix.getRegularWikis({
+ type: true,
+ code: 'hostname',
+ title: 'hostname',
+ subtitle: 'dbname'
+ })
+
+ ]).then(values => {
+ const [groups, projectFamilies, languages, specials,
wikis] = values;
+
+ sitematrixData = _.concat(groups, projectFamilies,
languages, specials, wikis)
+ return sitematrixData;
+ });
+
+ }
},
navigateSearchResults (offset) {
diff --git a/src/components/widgets/SearchResults.vue
b/src/components/widgets/SearchResults.vue
index fcb81f5..2919b54 100644
--- a/src/components/widgets/SearchResults.vue
+++ b/src/components/widgets/SearchResults.vue
@@ -7,11 +7,8 @@
@mouseenter="highlightResult(r)"
@click="select(r)"
:class="{ highlighted: highlightedResult === r }">
+ {{r[title || 'title']}}
- <span>{{r[title || 'title']}}</span>
- <span class="subtitle" v-if="subtitle && r[title] !== r[subtitle]">
- {{r[subtitle]}}
- </span>
</li>
</ul>
</div>
@@ -140,6 +137,7 @@
computed: {
results: function () {
+ console.time('start-computed')
const {
search,
data = [],
@@ -149,12 +147,12 @@
} = this.$props;
- if (!search) { return _.take(data, maxResults); }
+ if (!search || search == 'All wikis') { return _.take(data,
maxResults); }
const s = makeRegex(search);
// For some reason, lodash's _.chain() method would throw errors
when
// trying to chain filter operations to it. Super-ugly, but...
- return _.take(
+ var lola = _.take(
_.sortBy(
_.filter(
_.map(
@@ -174,6 +172,10 @@
),
maxResults
);
+
+ console.timeEnd('end-computed')
+ return lola;
+
}
}
}
@@ -196,8 +198,7 @@
max-height: 400px;
overflow-y: auto;
- border-radius: 4px;
- box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.14);
+
border: solid 1px #dededf;
}
--
To view, visit https://gerrit.wikimedia.org/r/405398
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia81a7445c3715064518026ccc1f149ff230770f0
Gerrit-PatchSet: 1
Gerrit-Project: analytics/wikistats2
Gerrit-Branch: master
Gerrit-Owner: Nuria <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits