Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions get-sticker-fulfilment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export function decrypt(ciphertext: string) {
return cryptr.decrypt(ciphertext);
}

const tokens = [''];

export async function getUserData(token: string) {
const userDataURL = new URL(`https://auth.hackclub.com/api/v1/me`);
const userDataRes = await fetch(userDataURL, {
Expand All @@ -30,21 +28,29 @@ export async function getUserData(token: string) {
return userDataJSON.identity!;
}

const countries: Record<string, number> = {};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const data: string | any[] = [];

const failed: number[] = [];

console.log(
'First name,Last name,Address Line 1,Address Line 2,City,State,Postcode,Country,Email,Rubber Stamps'
);

for (let i = 0; i < tokens.length; i++) {
for (let i = 0; i < data.length; i++) {
try {
const token = decrypt(tokens[i]);
const token = decrypt(data[i][2]);
const userData = await getUserData(token);
const { addresses } = userData;
const { primary_email, addresses } = userData;
const address = addresses?.find((address: { primary: boolean }) => address.primary);
console.log('Address', i + '/' + tokens.length + ':', address.country);

countries[address.country as string] = (countries[address.country as string] ?? 0) + 1;
console.log(
`${address.first_name},${address.last_name},${address.line_1},${address.line_2},${address.city},${address.state},${address.postal_code},${address.country},${primary_email},#${data[i][0]}`
);
} catch {
console.warn('Failed: user ' + i);
failed.push(data[i][0]);
}
}

console.log('\n');
console.log(countries);
console.log('Skipped:', failed);
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export const actions = {
.select({
maxRecords: 1,
view: 'Grid view',
filterByFormula: '{fldXbtQyDOFpWwGBQ} = ' + locals.user.id
filterByFormula: `{fldXbtQyDOFpWwGBQ} = ${queriedProject.user.id}`
})
.firstPage();

Expand Down
Loading