Skip to content

Commit 4eff081

Browse files
authored
Merge pull request #235 from mapswipe/hotfixes
use onCreate for counter function #234
2 parents 09de692 + dc55b71 commit 4eff081

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

firebase/functions/index.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,9 @@ admin.initializeApp()
88
// Increments or Decrements various counter
99
//
1010
// Gets triggered when new results of the group are written to the database.
11-
exports.counter = functions.database.ref('/v2/results/{projectId}/{groupId}/{userId}/').onWrite((snapshot, context) => {
12-
// if result ref does not contain any data
13-
// (e.g. when deletion during transfer_results() occured)
14-
// do nothing
15-
if (!snapshot.after.exists()) {
16-
return null
17-
}
18-
11+
exports.counter = functions.database.ref('/v2/results/{projectId}/{groupId}/{userId}/').onCreate((snapshot, context) => {
1912
const promises = []
20-
const result = snapshot.after.val()
13+
const result = snapshot.val()
2114

2215
// if result ref does not contain all required attributes we don't updated counters
2316
// e.g. due to some error when uploading from client

0 commit comments

Comments
 (0)