Fix Favourite Game Genres, Developers and Publishers
This commit is contained in:
parent
0aae697dca
commit
ec4eae07d4
|
@ -106,14 +106,23 @@ async function GetIGDBEntries(array) {
|
||||||
|
|
||||||
async function GetDevelopers() {
|
async function GetDevelopers() {
|
||||||
companies = [];
|
companies = [];
|
||||||
|
const companyIds = new Set();
|
||||||
|
|
||||||
for (let i = 0; i < beatGameIGDBEntries.length; i++) {
|
for (let i = 0; i < beatGameIGDBEntries.length; i++) {
|
||||||
for (let j = 0; j < beatGameIGDBEntries[i].involved_companies.length; j++) {
|
for (let j = 0; j < beatGameIGDBEntries[i].involved_companies.length; j++) {
|
||||||
|
companyIds.add(beatGameIGDBEntries[i].involved_companies[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!companies.find(item => item.id === beatGameIGDBEntries[i].involved_companies[j])) {
|
const ids = [...companyIds];
|
||||||
const company = await getCompanyInfo(beatGameIGDBEntries[i].involved_companies[j]);
|
const tempIds = [];
|
||||||
companies.push(company);
|
|
||||||
}
|
for (let i = 0; i < ids.length; i++) {
|
||||||
|
const company = await getCompanyInfo(ids[i]);
|
||||||
|
|
||||||
|
if (!tempIds.includes(company.id)) {
|
||||||
|
tempIds.push(company.id);
|
||||||
|
companies.push(company);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,12 +264,14 @@ async function GetFavouriteGenres() {
|
||||||
async function GetFavouriteDevelopers() {
|
async function GetFavouriteDevelopers() {
|
||||||
const developers = [];
|
const developers = [];
|
||||||
const counts = [];
|
const counts = [];
|
||||||
for (let i = 0; i < beatGameIGDBEntries.length && i < 5; i++) {
|
|
||||||
for (let j = 0; j < companies.length; j++) {
|
for (let i = 0; i < companies.length; i++) {
|
||||||
if (companies[j].developed) {
|
if (companies[i].developed) {
|
||||||
const developedGames = companies[j].developed;
|
const developedGames = companies[i].developed;
|
||||||
if (developedGames.find(item => item === beatGameIGDBEntries[i].id)) {
|
for (let j = 0; j < beatGameIGDBEntries.length; j++) {
|
||||||
developers.push(companies[j].name);
|
const found = developedGames.find(item => item === beatGameIGDBEntries[j].id);
|
||||||
|
if (found) {
|
||||||
|
developers.push(companies[i].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,7 +286,7 @@ async function GetFavouriteDevelopers() {
|
||||||
const keys = Object.keys(sortedCounts);
|
const keys = Object.keys(sortedCounts);
|
||||||
|
|
||||||
let string = ' ';
|
let string = ' ';
|
||||||
for (let i = 0; i < keys.length; i++) {
|
for (let i = 0; i < keys.length && i < 5; i++) {
|
||||||
const developer = keys[i];
|
const developer = keys[i];
|
||||||
|
|
||||||
if (sortedCounts[developer][1] > 1) {
|
if (sortedCounts[developer][1] > 1) {
|
||||||
|
@ -290,12 +301,15 @@ async function GetFavouriteDevelopers() {
|
||||||
async function GetFavouritePublishers() {
|
async function GetFavouritePublishers() {
|
||||||
const publishers = [];
|
const publishers = [];
|
||||||
const counts = [];
|
const counts = [];
|
||||||
for (let i = 0; i < beatGameIGDBEntries.length; i++) {
|
|
||||||
for (let j = 0; j < companies.length; j++) {
|
for (let i = 0; i < companies.length; i++) {
|
||||||
if (companies[j].published) {
|
if (companies[i].published) {
|
||||||
const developedGames = companies[j].published;
|
const developedGames = companies[i].published;
|
||||||
if (developedGames.find(item => item === beatGameIGDBEntries[i].id)) {
|
for (let j = 0; j < beatGameIGDBEntries.length; j++) {
|
||||||
publishers.push(companies[j].name);
|
const found = developedGames.includes(beatGameIGDBEntries[j].id);
|
||||||
|
|
||||||
|
if (found) {
|
||||||
|
publishers.push(companies[i].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue