@@ -41,29 +41,33 @@ const saveData = async (file: string, data: unknown) => {
41
41
await fs . writeFile ( dest , JSON . stringify ( data , null , 2 ) )
42
42
}
43
43
44
+ const updateData = async ( year : number , conference : string ) => {
45
+ console . log ( `[${ conference } ${ year } ] Fetching data` )
46
+ const conferenceData = await fetchConferenceData ( year , conference )
47
+
48
+ console . log ( `[${ conference } ${ year } ] Calculating circle of suck` )
49
+ const { teams, games } = conferenceData
50
+ const circleOfSuck = findCircleOfSuck ( teams , games )
51
+
52
+ console . log ( `[${ conference } ${ year } ] Saving data` )
53
+ await saveData (
54
+ getConferenceDataFileName ( year , conference ) ,
55
+ conferenceData
56
+ )
57
+ await saveData (
58
+ getCircleOfSuckDataFileName ( year , conference ) ,
59
+ circleOfSuck
60
+ )
61
+
62
+ console . log ( `[${ conference } ${ year } ] Done` )
63
+ }
64
+
44
65
const main = async ( ) => {
45
66
const year = new Date ( ) . getFullYear ( )
46
67
const conferences = [ 'PAC' ]
47
68
48
69
for ( const conference of conferences ) {
49
- console . log ( `[${ conference } ${ year } ] Fetching data` )
50
- const conferenceData = await fetchConferenceData ( year , conference )
51
-
52
- console . log ( `[${ conference } ${ year } ] Calculating circle of suck` )
53
- const { teams, games } = conferenceData
54
- const circleOfSuck = findCircleOfSuck ( teams , games )
55
-
56
- console . log ( `[${ conference } ${ year } ] Saving data` )
57
- await saveData (
58
- getConferenceDataFileName ( year , conference ) ,
59
- conferenceData
60
- )
61
- await saveData (
62
- getCircleOfSuckDataFileName ( year , conference ) ,
63
- circleOfSuck
64
- )
65
-
66
- console . log ( `[${ conference } ${ year } ] Done` )
70
+ await updateData ( year , conference )
67
71
}
68
72
}
69
73
0 commit comments