data endpoint for entity 90008 (aka. a website)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: separate update tasks into two for updating at different intervals

dusk 31ad0287 ff59fcc4

+25 -14
+25 -14
src/hooks.server.ts
··· 20 20 import { error } from '@sveltejs/kit'; 21 21 import { _fetchEntries } from './routes/(site)/guestbook/+page.server'; 22 22 23 - const update = async () => { 23 + const updateNowPlaying = async () => { 24 24 try { 25 - await Promise.all([ 26 - steamUpdateNowPlaying(), 27 - updateNowPlayingTrack(), 28 - updateLastPosts(), 29 - _fetchEntries(), 30 - updateCommits(), 31 - sendAllMetrics() 32 - ]); 25 + await Promise.all([steamUpdateNowPlaying(), updateNowPlayingTrack()]); 26 + } catch (err) { 27 + console.log(`error while updating: ${err}`); 28 + } 29 + }; 30 + const refreshContent = async () => { 31 + try { 32 + await Promise.all([updateLastPosts(), _fetchEntries(), updateCommits(), sendAllMetrics()]); 33 33 } catch (err) { 34 34 console.log(`error while updating: ${err}`); 35 35 } 36 36 }; 37 37 38 - await update(); 38 + await Promise.all([updateNowPlaying(), refreshContent()]); 39 39 40 40 const scheduler = new ToadScheduler(); 41 - const task = new AsyncTask('update task', update, (err) => 42 - console.log(`error while updating: ${err}`) 41 + scheduler.addSimpleIntervalJob( 42 + new SimpleIntervalJob( 43 + { seconds: 5 }, 44 + new AsyncTask('updateNowPlaying task', updateNowPlaying, (err) => 45 + console.log(`error while updateNowPlaying: ${err}`) 46 + ) 47 + ) 48 + ); 49 + scheduler.addSimpleIntervalJob( 50 + new SimpleIntervalJob( 51 + { seconds: 30 }, 52 + new AsyncTask('refreshContent task', refreshContent, (err) => 53 + console.log(`error while refreshContent: ${err}`) 54 + ) 55 + ) 43 56 ); 44 - const job = new SimpleIntervalJob({ seconds: 5 }, task); 45 - scheduler.addSimpleIntervalJob(job); 46 57 47 58 export const handle = async ({ event, resolve }) => { 48 59 notifyDarkVisitors(event.url, event.request); // no await so it doesnt block