@@ -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 ) , 10000 ) ;
47
+ this . ctx . interval ( ( ) => this . cron ( ) . catch ( this . logger . error ) , 15000 ) ;
48
48
}
49
49
50
50
async cron ( ) {
@@ -205,8 +205,10 @@ class HydroFetcher extends BasicFetcher {
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
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 ) } } ) ;
208
+ const baloons = body . bdocs . map ( ( b ) => ( { ...b , time : mongoId ( b . _id ) . timestamp * 1000 } ) ) . sort ( ( a , b ) => a . time - b . time ) ;
209
+ for ( const balloon of baloons ) {
210
+ balloon . time = mongoId ( balloon . _id ) . timestamp * 1000 ;
211
+ const teamTotal = await this . ctx . db . balloon . find ( { teamid : balloon . uid , time : { $lt : balloon . time } } ) ;
210
212
const encourage = teamTotal . length < ( config . freezeEncourage ?? 0 ) ;
211
213
const totalDict = { } ;
212
214
for ( const t of teamTotal ) {
@@ -215,16 +217,17 @@ class HydroFetcher extends BasicFetcher {
215
217
const shouldPrint = this . contest . info . freeze_time ? ( balloon . time * 1000 ) < this . contest . info . freeze_time || encourage : true ;
216
218
if ( ! shouldPrint && ! balloon . sent ) await this . setBalloonDone ( balloon . balloonid ) ;
217
219
const contestproblem = {
218
- id : String . fromCharCode ( this . contest . info . pids . indexOf ( balloon . pid ) + 65 ) ,
220
+ id : balloon . pid . toString ( ) ,
221
+ short_name : String . fromCharCode ( this . contest . info . pids . indexOf ( balloon . pid ) + 65 ) ,
219
222
name : body . pdict [ balloon . pid ] . title ,
220
223
rgb : this . contest . info . balloon [ balloon . pid ] . color ,
221
224
color : this . contest . info . balloon [ balloon . pid ] . name ,
222
225
} ;
223
- await this . ctx . db . balloon . update ( { balloonid : balloon . _id } , {
226
+ await this . ctx . db . balloon . update ( { balloonid : balloon . _id . substring ( 0 , 8 ) } , {
224
227
$set : {
225
- balloonid : balloon . _id ,
226
- time : mongoId ( balloon . _id ) . timestamp ,
227
- problem : contestproblem . id ,
228
+ balloonid : balloon . _id . substring ( 0 , 8 ) ,
229
+ time : balloon . time ,
230
+ problem : contestproblem . short_name ,
228
231
contestproblem,
229
232
team : body . udict [ balloon . uid ] . displayName ,
230
233
teamid : balloon . uid ,
0 commit comments