Skip to content

Commit efc193c

Browse files
authored
Merge pull request #1 from PChild/official-events
Added official events logic and optional parameter
2 parents 7456cd1 + 8aed410 commit efc193c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

TBA.gs

+14-4
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,24 @@ function TBATeamEventQualRank(team, event) {
299299
*
300300
* @param {number} team A team number
301301
* @param {number} year A year
302+
* @param {boolean} opt_official Optionally fetch only official events
302303
* @return An 1-by-x array of event keys
303304
* @customfunction
304305
*/
305-
function TBATeamYearEvents(team, year) {
306+
function TBATeamYearEvents(team, year, opt_official) {
306307
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.") }
310320
}
311321
/**
312322
* Returns the color of the winning alliance for the match.

0 commit comments

Comments
 (0)