Apply api dupe workaround to subscriptions endpoint
parent
e4910f87d1
commit
6782ad2fb4
|
@ -22,6 +22,7 @@ export async function processSubscriptions(streamer: twitch.StreamerUserIdTokenP
|
|||
subscriptionsArray.push(subscription.user_id as number);
|
||||
}
|
||||
insertSubscriptionQuery = insertSubscriptionQuery.slice(0,-2); // Cut last `, ` off of the end
|
||||
insertSubscriptionQuery += " ON CONFLICT DO NOTHING"; // Deal with broken endpoint returning dupes
|
||||
var subscriptionQueryConfig = {
|
||||
text: insertSubscriptionQuery,
|
||||
values: subscriptionsArray
|
||||
|
@ -31,9 +32,10 @@ export async function processSubscriptions(streamer: twitch.StreamerUserIdTokenP
|
|||
await dbconn.query(subscriptionQueryConfig);
|
||||
}
|
||||
if (response.pagination.cursor) {
|
||||
//var oldFirstUserid = response.data[0].user_id;
|
||||
var oldFirstUserid = response.data[0].user_id;
|
||||
response = await twitch.streamerApiRequest(streamer,
|
||||
`/subscriptions?broadcaster_id=${streamer.userid}&after=${response.pagination.cursor}&first=100`);
|
||||
if (oldFirstUserid == response.data[0].user_id) break;
|
||||
//log(LogLevel.DEBUG,"Subscription API response:");
|
||||
//log(LogLevel.DEBUG,JSON.stringify(response,null,2));
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue