Skip to content

Commit

Permalink
Disable failing routes and cronjobs. part of #445
Browse files Browse the repository at this point in the history
  • Loading branch information
fcaps committed Nov 11, 2023
1 parent 089a446 commit e95b03c
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 69 deletions.
20 changes: 15 additions & 5 deletions express.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ const appGetRouteArray = [

//Renders every page written above
appGetRouteArray.forEach(page => app.get(`/${page}`, (req, res) => {
// disabled due https://github.com/FAForever/website/issues/445
if (['leaderboards', 'clans'].includes(page)) {
res.status(503).render('errors/503-known-issue')
}
res.render(page);
}));

Expand Down Expand Up @@ -145,17 +149,23 @@ const routes = './routes/views/';

const clansRoutesGet = [
'create', 'manage', 'accept_invite',];
clansRoutesGet.forEach(page => app.get(`/clans/${page}`, loggedIn, require(`${routes}clans/get/${page}`)));
// disabled due https://github.com/FAForever/website/issues/445
// clansRoutesGet.forEach(page => app.get(`/clans/${page}`, loggedIn, require(`${routes}clans/get/${page}`)));
clansRoutesGet.forEach(page => app.get(`/clans/${page}`, loggedIn, (req, res) => res.status(503).render('errors/503-known-issue')));

const clansRoutesPost = [
'create', 'destroy', 'invite', 'kick', 'transfer', 'update', 'leave', 'join',];
clansRoutesPost.forEach(page => app.post(`/clans/${page}`, loggedIn, require(`${routes}clans/post/${page}`)));
// disabled due https://github.com/FAForever/website/issues/445
// clansRoutesPost.forEach(page => app.post(`/clans/${page}`, loggedIn, require(`${routes}clans/post/${page}`)));
clansRoutesPost.forEach(page => app.post(`/clans/${page}`, loggedIn, (req, res) => res.status(503).render('errors/503-known-issue')));


// disabled due https://github.com/FAForever/website/issues/445
//When searching for a specific clan
app.get('/clans/*', (req, res) => {
res.render(`clans/seeClan`);
});
// app.get('/clans/*', (req, res) => {
// res.render(`clans/seeClan`);
// });
app.get('/clans/*', (req, res) => res.status(503).render('errors/503-known-issue'));


// Markdown Routes
Expand Down
4 changes: 3 additions & 1 deletion public/js/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ async function playerCounterJSON() {

playerCounterJSON()
.then((data) => {
document.getElementById('playerCounter').insertAdjacentHTML("afterbegin", data.length);
// disabled due https://github.com/FAForever/website/issues/445
// document.getElementById('playerCounter').insertAdjacentHTML("afterbegin", data.length);
document.getElementById('playerCounter').insertAdjacentHTML("afterbegin", "MANY");
});
103 changes: 54 additions & 49 deletions scripts/extractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,60 +143,65 @@ async function contentCreators() {
}

async function getAllClans() {
try {
let response = await axios.get(`${process.env.API_URL}/data/clan?sort=createTime&include=leader&fields[clan]=name,tag,description,leader,memberships,createTime&fields[player]=login&page[number]=1&page[size]=3000`);

let dataObjectToArray = Object.values(response.data);
let clanLeader = dataObjectToArray[2].map(item => ({
leaderName: item.attributes.login
}));
let clanValues = dataObjectToArray[0].map(item => ({
//id: item.id,
name: item.attributes.name,
tag: item.attributes.tag,
createTime: item.attributes.createTime,
//description: item.attributes.description,
population: item.relationships.memberships.data.length
}));
const combineArrays = (array1, array2) => array1.map((x, i) => [x, array2[i]]);
let clanData = combineArrays(clanLeader, clanValues);
clanData.sort((playerA, playerB) => playerA[1].population - playerB[1].population);
return await clanData;

} catch (e) {
console.log(e);
return null;
}

return [];
//disabled due https://github.com/FAForever/website/issues/445
// try {
// let response = await axios.get(`${process.env.API_URL}/data/clan?sort=createTime&include=leader&fields[clan]=name,tag,description,leader,memberships,createTime&fields[player]=login&page[number]=1&page[size]=3000`);
//
// let dataObjectToArray = Object.values(response.data);
// let clanLeader = dataObjectToArray[2].map(item => ({
// leaderName: item.attributes.login
// }));
// let clanValues = dataObjectToArray[0].map(item => ({
// //id: item.id,
// name: item.attributes.name,
// tag: item.attributes.tag,
// createTime: item.attributes.createTime,
// //description: item.attributes.description,
// population: item.relationships.memberships.data.length
// }));
// const combineArrays = (array1, array2) => array1.map((x, i) => [x, array2[i]]);
// let clanData = combineArrays(clanLeader, clanValues);
// clanData.sort((playerA, playerB) => playerA[1].population - playerB[1].population);
// return await clanData;
//
// } catch (e) {
// console.log(e);
// return null;
// }

}


async function getLeaderboards(leaderboardID) {
try {
let response = await axios.get(`${process.env.API_URL}/data/leaderboardRating?include=player&sort=-rating&filter=leaderboard.id==${leaderboardID};updateTime=ge=${currentDate}&page[size]=9999`);


let dataObjectToArray = await Object.values(response.data);

let playerLogin = dataObjectToArray[2].map(item => ({
label: item.attributes.login
}));
let playerValues = dataObjectToArray[0].map(item => ({
rating: item.attributes.rating,
totalgames: item.attributes.totalGames,
wonGames: item.attributes.wonGames,
date: item.attributes.updateTime,
}));
const combineArrays = (array1, array2) => array1.map((x, i) => [x, array2[i]]);
let leaderboardData = combineArrays(playerLogin, playerValues);
leaderboardData.sort((playerA, playerB) => playerB[1].rating - playerA[1].rating);
return await leaderboardData;

} catch (e) {
console.log(e);
return null;

}
return [];
//disabled due https://github.com/FAForever/website/issues/445
// try {
// let response = await axios.get(`${process.env.API_URL}/data/leaderboardRating?include=player&sort=-rating&filter=leaderboard.id==${leaderboardID};updateTime=ge=${currentDate}&page[size]=9999`);
//
//
// let dataObjectToArray = await Object.values(response.data);
//
// let playerLogin = dataObjectToArray[2].map(item => ({
// label: item.attributes.login
// }));
// let playerValues = dataObjectToArray[0].map(item => ({
// rating: item.attributes.rating,
// totalgames: item.attributes.totalGames,
// wonGames: item.attributes.wonGames,
// date: item.attributes.updateTime,
// }));
// const combineArrays = (array1, array2) => array1.map((x, i) => [x, array2[i]]);
// let leaderboardData = combineArrays(playerLogin, playerValues);
// leaderboardData.sort((playerA, playerB) => playerB[1].rating - playerA[1].rating);
// return await leaderboardData;
//
// } catch (e) {
// console.log(e);
// return null;
//
// }
}

module.exports.run = function run() {
Expand Down
29 changes: 15 additions & 14 deletions scripts/getRecentUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@ let currentDate = new Date(minusTimeFilter).toISOString();

async function getRecentUsers() {

try {
let response = await fetch(`${process.env.API_URL}/data/leaderboardRating?filter=updateTime=gt=${currentDate}&page[size]=5000`);
let fetchData = await response.json();
//Now we get a js array rather than a js object. Otherwise we can't sort it out.
let dataObjectToArray = Object.values(fetchData);
let data = dataObjectToArray[0].map((item)=> ({
playerID: item.id
}));
return await data;
}catch (e) {
console.log(e);
return null;
}

return []
// disabled due https://github.com/FAForever/website/issues/445
// try {
// let response = await fetch(`${process.env.API_URL}/data/leaderboardRating?filter=updateTime=gt=${currentDate}&page[size]=5000`);
// let fetchData = await response.json();
// //Now we get a js array rather than a js object. Otherwise we can't sort it out.
// let dataObjectToArray = Object.values(fetchData);
// let data = dataObjectToArray[0].map((item)=> ({
// playerID: item.id
// }));
// return await data;
// }catch (e) {
// console.log(e);
// return null;
// }
}

module.exports.run = function run() {
Expand Down
8 changes: 8 additions & 0 deletions templates/views/errors/503-known-issue.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
extends ../../layouts/default
block bannerData
- var bannerImage = "tutorial"
- var bannerFirstTitle = "Temporarily Disabled"
- var bannerSecondTitle = ""
- var bannerSubTitle = "Sorry commanders, we failed to build enough pgens and are now in a tech upgrade"
block content

0 comments on commit e95b03c

Please sign in to comment.