Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Graph Update #90

Merged
merged 3 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions workers/tiltify-cache/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,16 @@ export class TiltifyData {

console.log('Alarm Called, fetching latest Tiltify data...');

//Get the current stored data
let data = await this.state.storage.get(DO_CACHE_KEY);

//Fetch the latest Tiltify data and cache it
let startTime = new Date();
let newData = await getLatestData(this.env);
let endTime = new Date();

let dataToStore = newData;

let isLive = newData.event.start <= Date.now() && newData.event.end >= Date.now();

console.log(`Finished Fetching, caching result Tiltify data... (${endTime - startTime}ms)`);

await this.state.storage.put(DO_CACHE_KEY, dataToStore);
await this.state.storage.put(DO_CACHE_KEY, newData);

console.log(`Finished Caching data... (${new Date() - endTime}ms)`);
}
}

Expand Down Expand Up @@ -108,7 +103,7 @@ export class GraphData {

//Start the alarm if it is currently not started
let currentAlarm = await this.storage.getAlarm();
if (currentAlarm == null && this.env.ENABLE_REFRESH) {
if (currentAlarm == null && this.env.ENABLE_GRAPH_REFRESH) {
this.storage.setAlarm(Date.now() + UPDATE_TIME_GRAPH);
}

Expand All @@ -130,7 +125,7 @@ export class GraphData {

async alarm() {
//Enable the alarm again
if (this.env.ENABLE_REFRESH)
if (this.env.ENABLE_GRAPH_REFRESH)
this.storage.setAlarm(Date.now() + UPDATE_TIME_GRAPH);

console.log('Alarm Called, fetching latest graph data...');
Expand Down
2 changes: 2 additions & 0 deletions workers/tiltify-cache/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ YOGSCAST_CAMPAIGN_SLUG="jingle-jam-2023"
YOGSCAST_USERNAME_SLUG="yogscast"
REFRESH_TIME=10
ENABLE_REFRESH=true
ENABLE_GRAPH_REFRESH=false
ENABLE_DEBUG=false


Expand Down Expand Up @@ -60,5 +61,6 @@ YOGSCAST_CAMPAIGN_SLUG="jingle-jam-2023"
YOGSCAST_USERNAME_SLUG="yogscast"
REFRESH_TIME=60
ENABLE_REFRESH=true
ENABLE_GRAPH_REFRESH=false
ENABLE_DEBUG=false