Skip to content

Commit

Permalink
feat: #1055 (endpoint) cache target leagues map;
Browse files Browse the repository at this point in the history
  • Loading branch information
migbash committed Feb 28, 2023
1 parent ca16aff commit f9349f1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/routes/api/hasura/home/livescores-v2/+server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { json } from '@sveltejs/kit';

import { initGrapQLClient } from '$lib/graphql/init_graphQL';
import { generate_historic_fixtures_day_group_map, generate_leagues_map, get_target_date_fixtures, get_target_leagues } from '@betarena/scores-lib/dist/functions/func.livescores-v2.js';
import { generate_historic_fixtures_day_group_map, generate_leagues_map, generate_tournaments_map, get_target_date_fixtures, get_target_leagues } from '@betarena/scores-lib/dist/functions/func.livescores-v2.js';
import type { B_LS2_D, LS2_C_FixtureDateGroup } from '@betarena/scores-lib/types/livescores-v2';

// [ℹ] debug info
Expand Down Expand Up @@ -69,13 +69,22 @@ async function main(

// eslint-disable-next-line prefer-const
let leagues_ids_arr: number[] = current_week_fixtures?.historic_fixtures?.map(a => a.league_id)
const leagues_data = await get_target_leagues(
const [leagues_data, tournaments_data] = await get_target_leagues(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
graphQlInstance,
leagues_ids_arr
)
const league_map = await generate_leagues_map(leagues_data)
const tournaments_map = await generate_tournaments_map(tournaments_data)

for await (const [id, league] of league_map) {
league.urls =
tournaments_map.has(league?.id) == true
? tournaments_map.get(league?.id)?.urls
: null
;
}

/**
* [ℹ] cache (data) persist
Expand Down

0 comments on commit f9349f1

Please sign in to comment.