Skip to content

Commit 8356712

Browse files
committed
move firebase batch size to constants file
1 parent e45b281 commit 8356712

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

constants/firebase.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const BATCH_SIZE_IN_CLAUSE = 30;
2+
3+
module.exports = {
4+
BATCH_SIZE_IN_CLAUSE,
5+
};

models/users.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const firestore = require("../utils/firestore");
88
const { fetchWallet, createWallet } = require("../models/wallets");
99
const { arraysHaveCommonItem } = require("../utils/array");
1010
const { ALLOWED_FILTER_PARAMS } = require("../constants/users");
11+
const { BATCH_SIZE_IN_CLAUSE } = require("../constants/firebase");
1112
const userModel = firestore.collection("users");
1213
const joinModel = firestore.collection("applicants");
1314
const itemModel = firestore.collection("itemTags");
@@ -184,9 +185,8 @@ const fetchFilteredUsers = async (usernames = []) => {
184185
const filterdUsersWithDetails = [];
185186

186187
const groups = [];
187-
const batchSize = 30; // since only 30 comparisons are allowed with the 'in' clause
188-
for (let i = 0; i < usernames.length; i += batchSize) {
189-
groups.push(usernames.slice(i, i + batchSize));
188+
for (let i = 0; i < usernames.length; i += BATCH_SIZE_IN_CLAUSE) {
189+
groups.push(usernames.slice(i, i + BATCH_SIZE_IN_CLAUSE));
190190
}
191191

192192
// For each group, write a separate query

0 commit comments

Comments
 (0)