Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizing /user/buy/x in 40-50% #14984

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 11 additions & 8 deletions website/common/script/libs/getOfficialPinnedItems.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import toArray from 'lodash/toArray';
import _ from 'lodash';
import content from '../content/index';
import SeasonalShopConfig from './shops-seasonal.config';

const { officialPinnedItems } = content;

const flatGearArray = toArray(content.gear.flat);
const flatGearArray = _.groupBy(content.gear.flat, 'set');

export default function getOfficialPinnedItems (user) {
const officialItemsArray = [...officialPinnedItems];
const { pinnedSets } = SeasonalShopConfig;

if (SeasonalShopConfig.pinnedSets && Boolean(user) && user.stats.class) {
const setToAdd = SeasonalShopConfig.pinnedSets[user.stats.class];
if (pinnedSets && !_.isEmpty(pinnedSets) && Boolean(user) && user.stats.class) {
const setToAdd = pinnedSets[user.stats.class];

// pinnedSets == current seasonal class set are always gold purchaseable
const gearsBySet = flatGearArray[setToAdd];

flatGearArray
.filter(gear => user.items.gear.owned[gear.key] === undefined && gear.set === setToAdd)
.forEach(gear => {
for (let i = 0; i < gearsBySet.length; i += 1) {
const gear = gearsBySet[i];
if (!user.items.gear.owned[gear.key]) {
officialItemsArray.push({
type: 'marketGear',
path: `gear.flat.${gear.key}`,
});
});
}
}
}

return officialItemsArray;
Expand Down
2 changes: 1 addition & 1 deletion website/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ if (CORES !== 0 && cluster.isMaster && (IS_DEV || IS_PROD)) {
logger.info(`[${new Date()}] [master:${process.pid}] worker:${worker.process.pid} disconnect! new worker:${w.process.pid} fork`);
});
} else {
module.exports = require('./server.js');
module.exports = require('./server');
}