This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type UserInGroup = Pick<DipUser, "timezone" | "telegramUsername" | "groupIds"> | |
| /** | |
| * Gets the users from the DB using their groupId | |
| */ | |
| export async function getUsersInGroup( | |
| telegramGroupId: number | |
| ): Promise<UserInGroup[] | undefined> { | |
| const groupId = UPCOMING_GROUPS.find( | |
| (group) => group.telegramGroupId === telegramGroupId | |
| )?.id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createClient } from "@supabase/supabase-js" | |
| export const supabaseClient = createClient( | |
| process.env.NEXT_PUBLIC_SUPABASE_URL || "", | |
| process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || "" | |
| ) | |
| export const supabaseServer = createClient( | |
| process.env.NEXT_PUBLIC_SUPABASE_URL || "", | |
| process.env.SUPABASE_SERVER_KEY || "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function getStreaks() { | |
| // Initialize google spreadsheet | |
| const doc = await initializeGoogleSpreadsheet("updates") | |
| const sheetTitle = "Test Group" | |
| const sheet = doc.sheetsByTitle[sheetTitle] | |
| // NOTE@jsjoeio - this is hardcoded to the test group | |
| const groupId = -514638766 | |
| const groupStartDate = getGroupStartDate(groupId) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { NextApiRequest, NextApiResponse } from "next" | |
| // ---------------------------------------------------------------------------- | |
| // To test this from the command line, run: | |
| // curl --request POST \ | |
| // --url 'http://localhost:3000/api/<endpoint>' \ | |
| // --header 'Authorization: Bearer API_SECRET_KEY' \ | |
| export default async function handler( | |
| req: NextApiRequest, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { | |
| fromUnixTime, | |
| format, | |
| } from "date-fns" | |
| /** | |
| * Checks if a timezone string is valid or not | |
| * | |
| * We do this to catch typos. | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export type User = { | |
| /** Unix timestamp - created at time of write */ | |
| timestamp: number | |
| /** ID of the user - created at time of write */ | |
| id: string | |
| telegramUsername: string | |
| telegramUserId: string | |
| /** Like a nickname */ | |
| preferredName: string | |
| firstName: string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** @OnlyCurrentDoc */ | |
| const startDate = new Date("2021-06-16") | |
| // so the first one is D2:K2 | |
| function MarkEmptyCellsInYesterdayRowWithHyphen() { | |
| const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Group 2 - B"); | |
| // Activates the sheet | |
| SpreadsheetApp.setActiveSheet(sheet); | |
| const today = new Date() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| declare const _date: unique symbol | |
| export type DateInTimezone = Date & { readonly [_date]: Date } | |
| /** | |
| * Checks if the date is between 12am and 4am | |
| * of the day | |
| * | |
| * Returns true if it is, false otherwise | |
| **/ | |
| export function isBetween12amAnd4am(date: DateInTimezone) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { GoogleSpreadsheet } = require('google-spreadsheet') | |
| ;(async function () { | |
| // Initialize the sheet - doc ID is the long id in the sheets URL | |
| const doc = new GoogleSpreadsheet('<the sheet ID from the url>') | |
| // Initialize Auth - see more available options at https://theoephraim.github.io/node-google-spreadsheet/#/getting-started/authentication | |
| await doc.useServiceAccountAuth({ | |
| client_email: process.env.GOOGLE_SERVICE_ACCOUNT_EMAIL, | |
| private_key: process.env.GOOGLE_PRIVATE_KEY, | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| gh pr create --title "title here" --draft --assignee "@me" --milestone "3.11.0" --label "security" |