File tree 1 file changed +14
-4
lines changed
1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -299,14 +299,24 @@ function TBATeamEventQualRank(team, event) {
299
299
*
300
300
* @param {number } team A team number
301
301
* @param {number } year A year
302
+ * @param {boolean } opt_official Optionally fetch only official events
302
303
* @return An 1-by-x array of event keys
303
304
* @customfunction
304
305
*/
305
- function TBATeamYearEvents ( team , year ) {
306
+ function TBATeamYearEvents ( team , year , opt_official ) {
306
307
try {
307
- var x = JSON . parse ( TBAQuery ( 'team/frc' + team + '/events/' + year + '/keys' ) )
308
- return x
309
- } catch ( err ) { return ( "There was an error retrieving the data." ) }
308
+ var eventKeys = JSON . parse ( TBAQuery ( 'team/frc' + team + '/events/' + year + '/keys' ) )
309
+ if ( opt_official ) {
310
+ var eventData = JSON . parse ( TBAQuery ( 'team/frc' + team + '/events/' + year ) )
311
+ eventData . forEach ( function ( event ) {
312
+ if ( event [ 'event_type' ] === 99 ) {
313
+ eventKeys . splice ( eventKeys . indexOf ( event [ 'key' ] ) , 1 )
314
+ }
315
+ } )
316
+ }
317
+
318
+ return eventKeys
319
+ } catch ( err ) { return ( "There was an error retrieving the data." ) }
310
320
}
311
321
/**
312
322
* Returns the color of the winning alliance for the match.
You can’t perform that action at this time.
0 commit comments