Skip to content

Commit

Permalink
Add back scoreboard polling (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdHeat authored Aug 27, 2024
1 parent 5e16e96 commit e87f42c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
23 changes: 21 additions & 2 deletions assets/js/scoreboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,51 @@ import { embed } from "./utils/graphs/echarts";
window.Alpine = Alpine;
window.CTFd = CTFd;

// Default scoreboard polling interval to every 5 minutes
const scoreboardUpdateInterval = window.scoreboardUpdateInterval || 300000;

Alpine.data("ScoreboardDetail", () => ({
data: {},
show: true,

async init() {
async update() {
this.data = await CTFd.pages.scoreboard.getScoreboardDetail(10);

let option = getOption(CTFd.config.userMode, this.data);
embed(this.$refs.scoregraph, option);
this.show = Object.keys(this.data).length > 0;
},

async init() {
this.update();

setInterval(() => {
this.update();
}, scoreboardUpdateInterval);
},
}));

Alpine.data("ScoreboardList", () => ({
standings: [],
brackets: [],
activeBracket: null,

async init() {
async update() {
let response = await CTFd.fetch(`/api/v1/brackets?type=${CTFd.config.userMode}`, {
method: "GET",
});
const body = await response.json();
this.brackets = body["data"];
this.standings = await CTFd.pages.scoreboard.getScoreboard();
},

async init() {
this.update();

setInterval(() => {
this.update();
}, scoreboardUpdateInterval);
},
}));

Alpine.start();
1 change: 1 addition & 0 deletions static/assets/scoreboard.4ec57e19.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion static/assets/scoreboard.58978844.js

This file was deleted.

2 changes: 1 addition & 1 deletion static/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
]
},
"assets/js/scoreboard.js": {
"file": "assets/scoreboard.58978844.js",
"file": "assets/scoreboard.4ec57e19.js",
"src": "assets/js/scoreboard.js",
"isEntry": true,
"imports": [
Expand Down

0 comments on commit e87f42c

Please sign in to comment.