@@ -19,25 +19,27 @@ import "dotenv/config"
19
19
const projectId = Number ( process . env . CROWDIN_PROJECT_ID ) || 363359
20
20
21
21
const dates = {
22
- allTime : {
23
- from : ALL_TIME_START ,
24
- to : new Date ( ) . toISOString ( ) ,
22
+ month : {
23
+ from : getLastMonth ( ) . from ,
24
+ to : getLastMonth ( ) . to ,
25
25
} ,
26
26
quarter : {
27
27
from : getLastQuarter ( ) . from ,
28
28
to : getLastQuarter ( ) . to ,
29
29
} ,
30
- month : {
31
- from : getLastMonth ( ) . from ,
32
- to : getLastMonth ( ) . to ,
30
+ allTime : {
31
+ from : ALL_TIME_START ,
32
+ to : new Date ( ) . toISOString ( ) ,
33
33
} ,
34
34
}
35
35
36
36
const reports = Object . keys ( dates )
37
37
38
38
async function main ( ) {
39
39
// Log calculated dates being used for report generation
40
- console . log ( dates )
40
+ console . table ( dates )
41
+
42
+ const summary = { }
41
43
42
44
for ( const report of reports ) {
43
45
// Generate a report for the given date range
@@ -63,11 +65,29 @@ async function main() {
63
65
const data = parseData ( json )
64
66
65
67
// Write parsed data to file system
66
- fs . writeFileSync (
67
- join ( DATA_SAVE_PATH , report , `${ report } -data.json` ) . toLowerCase ( ) ,
68
- JSON . stringify ( data , null , 2 )
69
- )
68
+ const filePath = join (
69
+ DATA_SAVE_PATH ,
70
+ report ,
71
+ `${ report } -data.json`
72
+ ) . toLowerCase ( )
73
+ fs . writeFileSync ( filePath , JSON . stringify ( data , null , 2 ) )
74
+
75
+ // Add report to summary table
76
+ summary [ report ] = {
77
+ reportId,
78
+ from : dates [ report ] . from ,
79
+ to : dates [ report ] . to ,
80
+ filePath,
81
+ }
70
82
}
83
+
84
+ // Write summary table
85
+ fs . writeFileSync (
86
+ join ( DATA_SAVE_PATH , "leaderboard-import-summary.json" ) ,
87
+ JSON . stringify ( summary , null , 2 )
88
+ )
89
+
90
+ console . table ( summary , [ "filePath" ] )
71
91
}
72
92
73
93
main ( )
0 commit comments