File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -131,16 +131,23 @@ exports.counter = functions.database.ref('/v2/results/{projectId}/{groupId}/{use
131131
132132
133133exports . counter_2 = functions . database . ref ( '/v2/users/{userId}/contributions/{projectId}/' ) . onCreate ( ( snapshot , context ) => {
134+ const promises = [ ]
135+
134136 // Firebase Realtime Database references
135137 const contributorCountRef = admin . database ( ) . ref ( '/v2/projects/' + context . params . projectId + '/contributorCount' )
136138 const projectContributionCountRef = admin . database ( ) . ref ( '/v2/users/' + context . params . userId + '/projectContributionCount' )
137139
138- projectContributionCountRef . transaction ( ( currentCount ) => {
140+ const projectContributionCount = projectContributionCountRef . transaction ( ( currentCount ) => {
139141 return currentCount + 1
140142 } )
141- contributorCountRef . transaction ( ( currentCount ) => {
143+ promises . push ( projectContributionCount )
144+
145+ const contributorCount = contributorCountRef . transaction ( ( currentCount ) => {
142146 return currentCount + 1
143147 } )
148+ promises . push ( contributorCount )
149+
150+ return Promise . all ( promises )
144151} )
145152
146153
You can’t perform that action at this time.
0 commit comments