Skip to content

Commit

Permalink
removed extradata stuff from stats call since it has its own call now
Browse files Browse the repository at this point in the history
  • Loading branch information
jgdigitaljedi committed Apr 15, 2022
1 parent 888f9ad commit 9dcf163
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 46 deletions.
43 changes: 2 additions & 41 deletions server/routes/vg/vgCrud/gamesSupp/homeViewStats.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const _cloneDeep = require('lodash/cloneDeep');
const _sortBy = require('lodash/sortBy');
const _uniq = require('lodash/uniq');
const db = require('../../../../db');

const games = db.games.find();
Expand All @@ -9,13 +8,6 @@ const everDrives = require('../../../../extra/everDrive.json');
const accessories = db.gameAcc.find();
const collectibles = db.collectibles.find();
const clones = db.clones.find();
const nesBlackBox = require('../../../../extra/otherData/nesBlackBoxTitles.json');
const genBlackBox = require('../../../../extra/otherData/blackBoxGridGenesisGames.json');
const nesHangTab = require('../../../../extra/otherData/nesHangtabGames.json');

const nesHangTabTotal = nesHangTab.length;
const nesBBTotal = nesBlackBox.length;
const genBBTotal = genBlackBox.length;

let genres = {},
conGames = {},
Expand All @@ -42,10 +34,7 @@ let genres = {},
platformsCount = platforms.length,
accessoriesCount = accessories.length,
collectiblesCount = collectibles.length,
clonesCount = clones.length,
nesHangTabsIds = [],
nesBBIds = [],
genBBIds = [];
clonesCount = clones.length;

function resetAll() {
genres = {};
Expand Down Expand Up @@ -178,31 +167,13 @@ function handleAcqusition(game) {
}
}

function gatherExtraData(extraData, id) {
extraData.forEach(data => {
const detailsString = data?.details?.join(';');
if (/NES hang tab game/gi.test(detailsString)) {
nesHangTabsIds.push(id);
} else if (/Sega Genesis\/Mega Drive black box grid game/gi.test(detailsString)) {
genBBIds.push(id);
}
if (/NES black box game/gi.test(detailsString)) {
nesBBIds.push(id);
}
});
}

function makeConGames() {
_cloneDeep(games).forEach(game => {
if (conGames.hasOwnProperty(game.consoleName)) {
conGames[game.consoleName].push(game);
} else {
conGames[game.consoleName] = [game];
}
const extraData = game.extraDataFull || [];
if (extraData?.length > 0) {
gatherExtraData(extraData, game.id);
}
});
}

Expand Down Expand Up @@ -351,10 +322,6 @@ module.exports.getStats = () => {
consolesByGenSorted[gen] = consolesByGeneration[gen];
});

const nesHangTabUnique = _uniq(nesHangTabsIds);
const nesBBUnique = _uniq(nesBBIds);
const genBBGridUnique = _uniq(genBBIds);

const finalData = {
mostRecentlyAddedGames: mostRecentGameArr,
mostRecentlyAddedPlatforms: mostRecentConsoleArr,
Expand All @@ -377,13 +344,7 @@ module.exports.getStats = () => {
totalCollectibles: collectiblesCount,
totalClones: clonesCount,
gamesByDecade,
everDriveCounts,
nesHangTabsGamesOwned: nesHangTabUnique.length,
nesHangTabTotal,
genesisBBGridOwned: genBBGridUnique.length,
genesisBBGridTotal: genBBTotal,
nesBBOwned: nesBBUnique.length,
nesBBTotal
everDriveCounts
};
resetAll();
return finalData;
Expand Down
1 change: 0 additions & 1 deletion server/routes/vg/vgDb.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const everDrives = require('../../extra/everDrive.json');
const homePageStats = require('./vgCrud/gamesSupp/homeViewStats');
const homePageExtra = require('./vgCrud/gamesSupp/homeViewExtraLists');
const gameStats = require('../../extra/gameStats.json');
const db = require('../../db');
const combined = require('./vgCrud/gamesSupp/combineGames');
const sortBy = require('lodash/sortBy');

Expand Down
4 changes: 0 additions & 4 deletions src/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,6 @@ const Home: FunctionComponent<RouteComponentProps> = () => {
console.log('clicked', clicked);
}, []);

const getPercent = (value: number, total: number): string => {
return ((value / total) * 100).toFixed(2);
};

useEffect(() => {
getData();
getExtra();
Expand Down

0 comments on commit 9dcf163

Please sign in to comment.