all repos — stealth-developers @ c17ac1a822fd9ea6899e13ebefde048635ef2a33

apps/migration/src/fetch-missing-users.ts (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
import type { UserResponse } from "@purrkit/types";

import { RateLimitManager } from "@purrkit/ratelimit";
import { RESTClient } from "@purrkit/rest";

const limiter = new RateLimitManager({});

const TOKEN = process.env.TOKEN!;

const rest = RESTClient({
	token: TOKEN,
	fetch: limiter.fetch,
});

const missingUserIds: string[] = [
	"1782593884",
	"795061786255687711",
	"904144997559975937",
	"578420334110179333",
	"1413504630586998997",
	"1437781069779832954",
	"1029008522588987443",
	"835909579497799691",
	"1223644746896117791",
	"493127296270467072",
	"1329636666763116628",
	"1324912280890118174",
	"1350148294151503984",
	"1258548326912098477",
	"1475011243722018968",
	"466382971251982357",
	"1048430495094022205",
	"1400279059765657630",
	"717297081215352872",
	"1431735081705275506",
	"550840432997957633",
	"504437490711527424",
	"1281578414951632928",
	"1438881999338213457",
	"1243327172714958861",
	"1455011612472643667",
	"835703930091864094",
	"786644500030029835",
	"1069335764166524978",
	"1365420920423841873",
	"1319940559506378763",
	"709796139611979879",
	"1252497096129642506",
	"872560135258669100",
	"926198568715436063",
	"1388237404376269016",
	"733250938378125374",
	"1346451794557009972",
	"1457403097008832512",
	"1387565913041010688",
	"1338023988181467267",
	"1482884859872673813",
	"1484755143378473101",
	"908069295337111572",
	"1104329197742194739",
	"836829335628414997",
	"772837851255275530",
	"805911623968489492",
	"1307061098159013971",
	"211104933028560896",
	"1162930129954144256",
	"993513174408114176",
	"840586677516369951",
	"1482060412076949597",
	"1111315394406387765",
	"866852794443366411",
	"345391810472050689",
	"722126325048934522",
	"602335935543115776",
	"1037074050100506634",
	"573585328288563213",
	"957637851569356902",
	"988651720756301824",
	"1298713042330062879",
	"796477858037366784",
	"496036367151661066",
	"1471423782983041074",
	"1091124167736299551",
	"1115003796595163216",
	"1130254575551664341",
	"1069248360114028544",
	"1388100438326378498",
	"723208823765991490",
	"1497641855343530198",
	"1012951474629783614",
	"1509220340637761556",
	"792016188338077747",
	"1073360202583253075",
	"164569267243712512",
	"525936042012835841",
	"1343299975291080734",
	"1386813477318037665",
	"1213514366910074900",
	"1265039531132850247",
	"1162445027826475089",
	"1120382975591338004",
	"1241411863829549221",
	"768001665054801930",
];
// const users: UserResponse[] = [];
const out: { users: UserResponse[]; errors: any[] } = {
	users: [],
	errors: [],
};

for (const userId of missingUserIds) {
	const user = await rest.users(userId).get();
	if (user.ok) {
		out.users.push(user.data);
		console.log(`Fetched user ${userId}`);
	} else {
		console.error(`Failed to fetch user ${userId}:`, user.status, user.data);
		out.errors.push({ userId, status: user.status, data: user.data });
	}
}

console.log(JSON.stringify(out, null, 2));