-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #683 from CodeForAfrica/feature/write-to-spreadsheet
Add spreadsheet script to update sheet
- Loading branch information
Showing
9 changed files
with
171 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
NEXT_APP_GOOGLE_CREDENTIALS=/path/to/credentials.json | ||
NEXT_APP_GOOGLE_SHEET_ID= | ||
NEXT_APP_GOOGLE_SHEET_RANGE=New Hires!A:Z | ||
NEXT_APP_GOOGLE_SHEET_NAME="New Hires" | ||
NEXT_APP_VPN_API_URL= | ||
SENTRY_AUTH_TOKEN= | ||
SENTRY_DSN= |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { processNewUsers } from "@/vpnmanager/lib/processUsers"; | ||
import { loadEnvConfig } from "@next/env"; | ||
|
||
const projectDir = process.cwd(); | ||
loadEnvConfig(projectDir); | ||
|
||
processNewUsers(); |
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import spreadsheet, { updateSheet } from "@/vpnmanager/lib/data/spreadsheet"; | ||
import { SheetRow } from "@/vpnmanager/types"; | ||
|
||
export async function processUser(item: SheetRow) { | ||
return { | ||
...item, | ||
keySent: "Yes", | ||
}; | ||
} | ||
|
||
export async function processNewUsers() { | ||
const users = await spreadsheet.newUsers(); | ||
const promises = users.map((item) => processUser(item)); | ||
const settled = await Promise.allSettled(promises); | ||
const fulfilled = settled | ||
.filter((item) => item.status === "fulfilled") | ||
.map(({ value }: any) => value); | ||
if (fulfilled.length) { | ||
updateSheet(fulfilled); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import fetchJson from "./fetchJson"; | ||
import toCamelCase from "./wordToCamelCase"; | ||
|
||
export { fetchJson, toCamelCase }; | ||
export { toCamelCase }; |
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.