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