Skip to content

Commit 2aa8927

Browse files
committed
Fix firebase functions eslint nits
Former-commit-id: 68a0f29
1 parent 0375981 commit 2aa8927

File tree

2 files changed

+32
-36
lines changed

2 files changed

+32
-36
lines changed

functions/.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
root: true,
33
env: {
4-
es6: true,
4+
es2017: true,
55
node: true,
66
},
77
extends: [

functions/index.js

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,36 @@ const admin = require("firebase-admin");
44
admin.initializeApp();
55
const db = admin.firestore();
66

7-
// // Create and deploy your first functions
8-
// // https://firebase.google.com/docs/functions/get-started
9-
//
10-
// exports.helloWorld = functions.https.onRequest((request, response) => {
11-
// functions.logger.info("Hello logs!", {structuredData: true});
12-
// response.send("Hello from Firebase!");
13-
// });
14-
157
const resetStreaksAndDeleteTodos = async () => {
168
// get all users
179
const users = await db.collection("users").get();
1810
// loop through all users
19-
return Promise.all(users.docs.map(async (user) => {
20-
// get user data
21-
const userData = user.data();
22-
// if user has a partner
23-
if (userData.partner) {
24-
// if not all todos are verified, reset streak
25-
// get todos subcollection ref
26-
const todosRef = user.ref.collection("todos");
27-
// query todos subcollection for all todos
28-
const todos = await todosRef.get();
29-
// check if all todos are verified
30-
const allTodosVerified = todos.docs.every((todo) => todo.data().verified);
31-
// if not all todos are verified, reset streak
32-
if (!allTodosVerified) {
33-
await user.ref.update({
34-
streak: 0,
35-
});
36-
}
37-
// delete all todos
38-
return Promise.all(todos.docs.map((todo) => todo.ref.delete()));
39-
}
40-
}));
11+
return Promise.all(
12+
users.docs.map(async (user) => {
13+
// get user data
14+
const userData = user.data();
15+
// if user has a partner
16+
if (userData.partner) {
17+
// if not all todos are verified, reset streak
18+
// get todos subcollection ref
19+
const todosRef = user.ref.collection("todos");
20+
// query todos subcollection for all todos
21+
const todos = await todosRef.get();
22+
// check if all todos are verified
23+
const allTodosVerified = todos.docs.every(
24+
(todo) => todo.data().verified,
25+
);
26+
// if not all todos are verified, reset streak
27+
if (!allTodosVerified) {
28+
await user.ref.update({
29+
streak: 0,
30+
});
31+
}
32+
// delete all todos
33+
return Promise.all(todos.docs.map((todo) => todo.ref.delete()));
34+
}
35+
}),
36+
);
4137
};
4238

4339
const deleteImages = async () => {
@@ -48,8 +44,8 @@ const deleteImages = async () => {
4844

4945
// runs every day at 5:00am LA time
5046
exports.dailyReset = functions.pubsub
51-
.schedule("0 5 * * *")
52-
.timeZone("America/Los_Angeles")
53-
.onRun(async (context) => {
54-
await Promise.all([resetStreaksAndDeleteTodos(), deleteImages()]);
55-
});
47+
.schedule("0 5 * * *")
48+
.timeZone("America/Los_Angeles")
49+
.onRun(async (context) => {
50+
await Promise.all([resetStreaksAndDeleteTodos(), deleteImages()]);
51+
});

0 commit comments

Comments
 (0)