INNER CODE UNIT · TypeScript

oneHourAgo

ekzhang/setwithfriends · functions/src/index.ts:238

  const oneHourAgo = Date.now() - 3600 * 1000;
  const recentGameIds = await getDatabase()
    .ref(`userGames/${userId}`)
    .orderByValue()
    .startAt(oneHourAgo)
    .once("value");

  const recentGames = await Promise.all(
    Object.keys(recentGameIds.val() || {}).map((recentGameId) =>
      getDatabase().ref(`games/${recentGameId}`).once("value"),
    ),
  );

  let unfinishedGames = 0;
  for (const snap of recentGames) {
    if (
      snap.child("host").val() === userId &&
      snap.child("status").val() !== "done" &&

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…