v1.0.1/release
copyright & privacy policy. fix update path bug
This commit is contained in:
+16
-9
@@ -60,11 +60,11 @@ exports.saveResult = functions.https.onCall(async (data, context) => {
|
||||
incrementValue = 1;
|
||||
}
|
||||
if (data.dose) {
|
||||
updateDoc[`${data.dose}.${data.age}.${symptom}`] =
|
||||
updateDoc[`${data.dose}.${data.age}.${symptom.replace("/", "OR")}`] =
|
||||
admin.firestore.FieldValue.increment(incrementValue);
|
||||
}
|
||||
else {
|
||||
updateDoc[`${data.age}.${symptom}`] =
|
||||
updateDoc[`${data.age}.${symptom.replace("/", "OR")}`] =
|
||||
admin.firestore.FieldValue.increment(incrementValue);
|
||||
}
|
||||
});
|
||||
@@ -86,11 +86,11 @@ exports.saveResult = functions.https.onCall(async (data, context) => {
|
||||
symptom !== "age") {
|
||||
if (existingData[symptom] === true) {
|
||||
if (existingData.dose) {
|
||||
undoDoc[`${existingData.dose}.${existingData.age}.${symptom}`] =
|
||||
undoDoc[`${existingData.dose}.${existingData.age}.${symptom.replace("/", "OR")}`] =
|
||||
admin.firestore.FieldValue.increment(-1);
|
||||
}
|
||||
else {
|
||||
undoDoc[`${existingData.age}.${symptom}`] =
|
||||
undoDoc[`${existingData.age}.${symptom.replace("/", "OR")}`] =
|
||||
admin.firestore.FieldValue.increment(-1);
|
||||
}
|
||||
}
|
||||
@@ -115,11 +115,11 @@ exports.saveResult = functions.https.onCall(async (data, context) => {
|
||||
Object.keys(docData).forEach((symptom) => {
|
||||
if (docData[symptom] === true) {
|
||||
if (data.dose) {
|
||||
updateDoc[`${data.dose}.${data.age}.${symptom}`] =
|
||||
updateDoc[`${data.dose}.${data.age}.${symptom.replace("/", "OR")}`] =
|
||||
admin.firestore.FieldValue.increment(1);
|
||||
}
|
||||
else {
|
||||
updateDoc[`${data.age}.${symptom}`] =
|
||||
updateDoc[`${data.age}.${symptom.replace("/", "OR")}`] =
|
||||
admin.firestore.FieldValue.increment(1);
|
||||
}
|
||||
}
|
||||
@@ -145,11 +145,11 @@ exports.saveResult = functions.https.onCall(async (data, context) => {
|
||||
Object.keys(docData).forEach((symptom) => {
|
||||
if (docData[symptom] === true) {
|
||||
if (data.dose) {
|
||||
updateDoc[`${data.dose}.${data.age}.${symptom}`] =
|
||||
updateDoc[`${data.dose}.${data.age}.${symptom.replace("/", "OR")}`] =
|
||||
admin.firestore.FieldValue.increment(1);
|
||||
}
|
||||
else {
|
||||
updateDoc[`${data.age}.${symptom}`] =
|
||||
updateDoc[`${data.age}.${symptom.replace("/", "OR")}`] =
|
||||
admin.firestore.FieldValue.increment(1);
|
||||
}
|
||||
}
|
||||
@@ -165,12 +165,19 @@ exports.saveResult = functions.https.onCall(async (data, context) => {
|
||||
exports.getPastResult = functions.https.onCall(async (data, context) => {
|
||||
if (!!data && !!context) {
|
||||
const { gid } = data;
|
||||
return await admin
|
||||
const existingData = await admin
|
||||
.firestore()
|
||||
.collection("results")
|
||||
.doc(serializeGaId(gid))
|
||||
.get()
|
||||
.then((doc) => doc.data());
|
||||
if (existingData) {
|
||||
if (existingData["NAUSEA / VOMITING"]) {
|
||||
existingData["NAUSEA OR VOMITING"] =
|
||||
existingData["NAUSEA / VOMITING"];
|
||||
}
|
||||
return existingData;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
|
||||
File diff suppressed because one or more lines are too long
+20
-9
@@ -73,10 +73,11 @@ export const saveResult = functions.https.onCall(
|
||||
incrementValue = 1;
|
||||
}
|
||||
if (data.dose) {
|
||||
updateDoc[`${data.dose}.${data.age}.${symptom}`] =
|
||||
updateDoc[
|
||||
`${data.dose}.${data.age}.${symptom.replace("/", "OR")}`] =
|
||||
admin.firestore.FieldValue.increment(incrementValue);
|
||||
} else {
|
||||
updateDoc[`${data.age}.${symptom}`] =
|
||||
updateDoc[`${data.age}.${symptom.replace("/", "OR")}`] =
|
||||
admin.firestore.FieldValue.increment(incrementValue);
|
||||
}
|
||||
});
|
||||
@@ -98,10 +99,11 @@ export const saveResult = functions.https.onCall(
|
||||
if (existingData[symptom] === true) {
|
||||
if (existingData.dose) {
|
||||
undoDoc[
|
||||
`${existingData.dose}.${existingData.age}.${symptom}`] =
|
||||
`${existingData.dose}.${existingData.age}.${
|
||||
symptom.replace("/", "OR")}`] =
|
||||
admin.firestore.FieldValue.increment(-1);
|
||||
} else {
|
||||
undoDoc[`${existingData.age}.${symptom}`] =
|
||||
undoDoc[`${existingData.age}.${symptom.replace("/", "OR")}`] =
|
||||
admin.firestore.FieldValue.increment(-1);
|
||||
}
|
||||
}
|
||||
@@ -126,10 +128,11 @@ export const saveResult = functions.https.onCall(
|
||||
Object.keys(docData).forEach((symptom : string) => {
|
||||
if (docData[symptom] === true) {
|
||||
if (data.dose) {
|
||||
updateDoc[`${data.dose}.${data.age}.${symptom}`] =
|
||||
updateDoc[
|
||||
`${data.dose}.${data.age}.${symptom.replace("/", "OR")}`] =
|
||||
admin.firestore.FieldValue.increment(1);
|
||||
} else {
|
||||
updateDoc[`${data.age}.${symptom}`] =
|
||||
updateDoc[`${data.age}.${symptom.replace("/", "OR")}`] =
|
||||
admin.firestore.FieldValue.increment(1);
|
||||
}
|
||||
}
|
||||
@@ -154,10 +157,11 @@ export const saveResult = functions.https.onCall(
|
||||
Object.keys(docData).forEach((symptom : string) => {
|
||||
if (docData[symptom] === true) {
|
||||
if (data.dose) {
|
||||
updateDoc[`${data.dose}.${data.age}.${symptom}`] =
|
||||
updateDoc[
|
||||
`${data.dose}.${data.age}.${symptom.replace("/", "OR")}`] =
|
||||
admin.firestore.FieldValue.increment(1);
|
||||
} else {
|
||||
updateDoc[`${data.age}.${symptom}`] =
|
||||
updateDoc[`${data.age}.${symptom.replace("/", "OR")}`] =
|
||||
admin.firestore.FieldValue.increment(1);
|
||||
}
|
||||
}
|
||||
@@ -174,12 +178,19 @@ export const saveResult = functions.https.onCall(
|
||||
export const getPastResult = functions.https.onCall(async (data, context) => {
|
||||
if (!!data && !!context) {
|
||||
const {gid} = data;
|
||||
return await admin
|
||||
const existingData : admin.firestore.DocumentData | undefined = await admin
|
||||
.firestore()
|
||||
.collection("results")
|
||||
.doc(serializeGaId(gid))
|
||||
.get()
|
||||
.then((doc) => doc.data());
|
||||
if (existingData) {
|
||||
if (existingData["NAUSEA / VOMITING"]) {
|
||||
existingData["NAUSEA OR VOMITING"] =
|
||||
existingData["NAUSEA / VOMITING"];
|
||||
}
|
||||
return existingData;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user