@@ -44,7 +44,7 @@ class BasicFetcher extends Service implements IBasicFetcher {
44
44
}
45
45
46
46
[ Service . init ] ( ) {
47
- this . ctx . interval ( ( ) => this . cron ( ) . catch ( this . logger . error ) , 20000 ) ;
47
+ this . ctx . interval ( ( ) => this . cron ( ) . catch ( this . logger . error ) , 10000 ) ;
48
48
}
49
49
50
50
async cron ( ) {
@@ -204,22 +204,21 @@ class HydroFetcher extends BasicFetcher {
204
204
async balloonInfo ( all ) {
205
205
if ( all ) this . logger . info ( 'Sync all balloons...' ) ;
206
206
const { body } = await fetch ( `/d/${ this . contest . domainId } /contest/${ this . contest . id } /balloon?todo=${ all ? 'false' : 'true' } ` ) ;
207
- if ( ! body || ! body . length ) return ;
208
- const balloons = body ;
209
- for ( const balloon of balloons ) {
210
- const teamTotal = await this . ctx . db . balloon . find ( { teamid : balloon . teamid , time : { $lt : ( balloon . time * 1000 ) . toFixed ( 0 ) } } ) ;
207
+ if ( ! body ?. bdocs ?. length ) return ;
208
+ for ( const balloon of body . bdocs ) {
209
+ const teamTotal = await this . ctx . db . balloon . find ( { teamid : balloon . uid , time : { $lt : ( balloon . time * 1000 ) . toFixed ( 0 ) } } ) ;
211
210
const encourage = teamTotal . length < ( config . freezeEncourage ?? 0 ) ;
212
211
const totalDict = { } ;
213
212
for ( const t of teamTotal ) {
214
213
totalDict [ t . problem ] = t . contestproblem ;
215
214
}
216
215
const shouldPrint = this . contest . info . freeze_time ? ( balloon . time * 1000 ) < this . contest . info . freeze_time || encourage : true ;
217
- if ( ! shouldPrint && ! balloon . done ) await this . setBalloonDone ( balloon . balloonid ) ;
216
+ if ( ! shouldPrint && ! balloon . sent ) await this . setBalloonDone ( balloon . balloonid ) ;
218
217
const contestproblem = {
219
- id : String . fromCharCode ( this . contest . pids . indexOf ( balloon . pid ) + 65 ) ,
218
+ id : String . fromCharCode ( this . contest . info . pids . indexOf ( balloon . pid ) + 65 ) ,
220
219
name : body . pdict [ balloon . pid ] . title ,
221
- rgb : this . contest . balloon [ balloon . pid ] . color ,
222
- color : this . contest . balloon [ balloon . pid ] . name ,
220
+ rgb : this . contest . info . balloon [ balloon . pid ] . color ,
221
+ color : this . contest . info . balloon [ balloon . pid ] . name ,
223
222
} ;
224
223
await this . ctx . db . balloon . update ( { balloonid : balloon . balloonid } , {
225
224
$set : {
@@ -237,13 +236,13 @@ class HydroFetcher extends BasicFetcher {
237
236
) ,
238
237
done : balloon . sent ,
239
238
total : totalDict ,
240
- printDone : balloon . done ? 1 : 0 ,
239
+ printDone : balloon . sent ? 1 : 0 ,
241
240
shouldPrint,
242
241
} ,
243
242
} , { upsert : true } ) ;
244
243
}
245
- await this . ctx . parallel ( 'balloon/newTask' , balloons . length ) ;
246
- this . logger . debug ( `Found ${ balloons . length } balloons` ) ;
244
+ await this . ctx . parallel ( 'balloon/newTask' , body . bdocs . length ) ;
245
+ this . logger . debug ( `Found ${ body . bdocs . length } balloons` ) ;
247
246
}
248
247
249
248
async setBalloonDone ( bid ) {
0 commit comments