Fix station preferences mapping

This commit is contained in:
Conor McNamara
2023-03-16 10:30:04 +00:00
parent f3ea627bab
commit b4733d07e8
5 changed files with 48 additions and 74 deletions

View File

@ -49,8 +49,8 @@ exports.postStationData = functions.https.onRequest((request, response) => {
cors(request, response, () => {
var batchWrite = db.batch();
jsonData.forEach((doc) => {
// append if the dartCodes hashset is empty or the current station is not present
if (dartCodes.size == 0 || !dartCodes.has(doc["StationCode"][0])) {
// append if the dartCodes hashset is empty or the current station is not present, and ignoring positions of zero
if ((dartCodes.size == 0 || !dartCodes.has(doc["StationCode"][0])) && !(doc["StationLongitude"] == 0 || doc["StationLatitude"] == 0)) {
doc["StationType"] = [stationTypeCode]
var docID = db.collection('stations').doc(doc["StationCode"][0])
batchWrite.set(docID, doc);