mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-12-29 03:20:46 +08:00
updated cloud function
This commit is contained in:
parent
ef2b3d2d67
commit
1d9faa0216
1 changed files with 2 additions and 4 deletions
|
|
@ -17,17 +17,15 @@ admin.initializeApp({
|
|||
// });
|
||||
|
||||
|
||||
exports.moveResults = functions.https.onCall((request,response) => {
|
||||
exports.moveResults = functions.runWith({timeoutSeconds:540,memory: '2GB'}).https.onCall((request,response) => {
|
||||
|
||||
return admin.firestore().collection('results').get().then(data => {
|
||||
return admin.firestore().collection('results').orderBy('timestamp','desc').limit(1000).get().then(data => {
|
||||
data.docs.forEach(doc => {
|
||||
let result = doc.data();
|
||||
if(result.moved === undefined || result.moved === false){
|
||||
admin.firestore().collection(`results`).doc(doc.id).update({moved:true});
|
||||
admin.firestore().collection(`users/${result.uid}/results`).add(result);
|
||||
console.log(`moving doc ${doc.id}`);
|
||||
}else{
|
||||
console.log(`doc already moved`);
|
||||
}
|
||||
})
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue