Skip to content

Commit

Permalink
Don't use team_id = 1 and service_id = 1, because we may not exist. C…
Browse files Browse the repository at this point in the history
…alculate graph cell width according to the rounds count
  • Loading branch information
andgein committed Jul 22, 2023
1 parent 0cb948f commit c447276
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
4 changes: 2 additions & 2 deletions scoreboard/src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class Controller extends EventEmitter {
}
}).then((allScoreboards: History) => {
this.model!.setScoreboards(allScoreboards.map((s) => s));
this.model!.getSlaPeriods("1", "1");
this.model!.getSlaPeriodsForSomeServiceOfSomeTeam()
this.emit('history');
});
}
Expand Down Expand Up @@ -77,7 +77,7 @@ export default class Controller extends EventEmitter {

processState(state: StateEventData) {
this.model!.setScoreboard(state);
this.model!.getSlaPeriods("1", "1");
this.model!.getSlaPeriodsForSomeServiceOfSomeTeam()
this.emit('updateScoreboard');
}
}
26 changes: 21 additions & 5 deletions scoreboard/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ export class GameModel {
this.roundsCount = 1280; // TODO: set actual rounds count
this.roundsPerGraphColumn = 20;
this.roundsPerGraphBorder = 60;
if (this.roundsCount > 600) {
this.roundsPerGraphColumn *= 2;
this.roundsPerGraphBorder *= 2;
}
if (this.roundsCount > 1200) {

let _roundsCount = this.roundsCount;
while (_roundsCount > 600) {
this.roundsPerGraphColumn *= 2;
this.roundsPerGraphBorder *= 2;
_roundsCount /= 2;
}

this.selectedTeam = null;
this.slalineWidth = 80;
this.slaPeriodLength = Math.ceil(this.roundsCount / this.slalineWidth);
Expand Down Expand Up @@ -182,6 +182,22 @@ export class GameModel {
return this.allRoundsSla[team_id][service_id];
}

getSlaPeriodsForSomeServiceOfSomeTeam() {
let team_ids = Object.keys(this.allRoundsSla);
if (team_ids.length == 0)
return [];

let team_id = team_ids[0];

let service_ids = Object.keys(this.allRoundsSla[team_id]);
if (service_ids.length == 0)
return [];

let service_id = service_ids[0];

return this.getSlaPeriods(team_id, service_id);
}

fillAllRoundsSlaForScoreboard(scoreboard: Scoreboard | HistoricalScoreboard) {
for (let t = 0; t < scoreboard.length; t++) {
const team = scoreboard[t];
Expand Down
10 changes: 5 additions & 5 deletions scoreboard/src/setupProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ const proxy = require('http-proxy-middleware');
*/

module.exports = function (app) {
app.use(proxy('/logo.png', {target: 'http://10.10.10.10:8080/', ws: true, changeOrigin: true}));
app.use(proxy('/api/events', {target: 'http://10.10.10.10:8080/', ws: true, changeOrigin: true}));
app.use(proxy('/api', {target: 'http://10.10.10.10:8080/', changeOrigin: true}));
app.use(proxy('/history', {target: 'http://10.10.10.10:8080/', changeOrigin: true}));
app.use(proxy('/data', {target: 'http://10.10.10.10:8080/', changeOrigin: true}));
app.use(proxy('/logo.png', {target: 'https://training.ctf.hitb.org/', ws: true, changeOrigin: true}));
app.use(proxy('/api/events', {target: 'https://training.ctf.hitb.org/', ws: true, changeOrigin: true}));
app.use(proxy('/api', {target: 'https://training.ctf.hitb.org/', changeOrigin: true}));
app.use(proxy('/history', {target: 'https://training.ctf.hitb.org/', changeOrigin: true}));
app.use(proxy('/data', {target: 'https://training.ctf.hitb.org/', changeOrigin: true}));
};

0 comments on commit c447276

Please sign in to comment.