Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
Dessa Simpson | dd423bdb34 | |
Dessa Simpson | ac953b0bb5 | |
Dessa Simpson | 90f672b288 |
|
@ -8,4 +8,4 @@ CREATE OR REPLACE FUNCTION get_version() RETURNS VARCHAR
|
||||||
AS $$SELECT major || '.' || minor FROM version $$
|
AS $$SELECT major || '.' || minor FROM version $$
|
||||||
LANGUAGE SQL;
|
LANGUAGE SQL;
|
||||||
|
|
||||||
INSERT INTO version (major,minor) VALUES (0,7);
|
INSERT INTO version (major,minor) VALUES (0,8);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
|
UPDATE version SET minor = 8;
|
||||||
|
|
||||||
ALTER TABLE config
|
ALTER TABLE config
|
||||||
ALTER COLUMN normaluservotepoints SET DEFAULT 10,
|
ALTER COLUMN normaluservotepoints SET DEFAULT 10,
|
||||||
ALTER COLUMN followervotepoints SET DEFAULT 50,
|
ALTER COLUMN followervotepoints SET DEFAULT 50,
|
||||||
|
@ -30,5 +32,4 @@ CREATE OR REPLACE VIEW ratelimit_vw AS
|
||||||
)) AS ratelimit(reqcount);
|
)) AS ratelimit(reqcount);
|
||||||
|
|
||||||
|
|
||||||
ROLLBACK;
|
COMMIT;
|
||||||
--COMMIT;
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ export async function processBans(streamer: twitch.StreamerUserIdTokenPair) {
|
||||||
await dbconn.query("DELETE FROM bans");
|
await dbconn.query("DELETE FROM bans");
|
||||||
var response = await twitch.streamerApiRequest(streamer,
|
var response = await twitch.streamerApiRequest(streamer,
|
||||||
`/moderation/banned?broadcaster_id=${streamer.userid}&first=100`);
|
`/moderation/banned?broadcaster_id=${streamer.userid}&first=100`);
|
||||||
//log(LogLevel.DEBUG,"Ban API response:")
|
log(LogLevel.DEBUG,"Ban API response:")
|
||||||
//log(LogLevel.DEBUG,JSON.stringify(response,null,2));
|
log(LogLevel.DEBUG,JSON.stringify(response,null,2));
|
||||||
while (true) {
|
while (true) {
|
||||||
var insertBanQuery = "INSERT INTO bans (userid) VALUES ";
|
var insertBanQuery = "INSERT INTO bans (userid) VALUES ";
|
||||||
var banRow = 0; // Used for $1, $2, etc. in parameterized query
|
var banRow = 0; // Used for $1, $2, etc. in parameterized query
|
||||||
|
@ -37,8 +37,8 @@ export async function processBans(streamer: twitch.StreamerUserIdTokenPair) {
|
||||||
var oldFirstUserid = response.data[0].user_id;
|
var oldFirstUserid = response.data[0].user_id;
|
||||||
response = await twitch.streamerApiRequest(streamer,
|
response = await twitch.streamerApiRequest(streamer,
|
||||||
`/moderation/banned?broadcaster_id=${streamer.userid}&after=${response.pagination.cursor}&first=100`);
|
`/moderation/banned?broadcaster_id=${streamer.userid}&after=${response.pagination.cursor}&first=100`);
|
||||||
//log(LogLevel.DEBUG,"Ban API response:");
|
log(LogLevel.DEBUG,"Ban API response:");
|
||||||
//log(LogLevel.DEBUG,JSON.stringify(response,null,2));
|
log(LogLevel.DEBUG,JSON.stringify(response,null,2));
|
||||||
// Work around broken api endpoint giving a cursor referring to the
|
// Work around broken api endpoint giving a cursor referring to the
|
||||||
// current page, causing an infinite loop
|
// current page, causing an infinite loop
|
||||||
if (oldFirstUserid == response.data[0].user_id) break;
|
if (oldFirstUserid == response.data[0].user_id) break;
|
||||||
|
|
|
@ -9,8 +9,8 @@ export async function processSubscriptions(streamer: twitch.StreamerUserIdTokenP
|
||||||
await dbconn.query("DELETE FROM subscriptions");
|
await dbconn.query("DELETE FROM subscriptions");
|
||||||
var response = await twitch.streamerApiRequest(streamer,
|
var response = await twitch.streamerApiRequest(streamer,
|
||||||
`/subscriptions?broadcaster_id=${streamer.userid}&first=100`);
|
`/subscriptions?broadcaster_id=${streamer.userid}&first=100`);
|
||||||
//log(LogLevel.DEBUG,"Subscriptions API response:")
|
log(LogLevel.DEBUG,"Subscriptions API response:")
|
||||||
//log(LogLevel.DEBUG,JSON.stringify(response,null,2));
|
log(LogLevel.DEBUG,JSON.stringify(response,null,2));
|
||||||
while (true) {
|
while (true) {
|
||||||
var insertSubscriptionQuery = "INSERT INTO subscriptions (userid) VALUES ";
|
var insertSubscriptionQuery = "INSERT INTO subscriptions (userid) VALUES ";
|
||||||
var subscriptionRow = 0; // Used for $1, $2, etc. in parameterized query
|
var subscriptionRow = 0; // Used for $1, $2, etc. in parameterized query
|
||||||
|
@ -35,9 +35,9 @@ export async function processSubscriptions(streamer: twitch.StreamerUserIdTokenP
|
||||||
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));
|
if (response.data.length === 0 || oldFirstUserid === response.data[0].user_id) break;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ export async function processSubscriptions(streamer: twitch.StreamerUserIdTokenP
|
||||||
await dbconn.query("CALL update_scores()");
|
await dbconn.query("CALL update_scores()");
|
||||||
await dbconn.query('COMMIT');
|
await dbconn.query('COMMIT');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
log(LogLevel.ERROR,"cronjobs.processSubscriptions: Exception: " + e);
|
||||||
log(LogLevel.ERROR,"cronjobs.processSubscriptions: Exception thrown; rolling back");
|
log(LogLevel.ERROR,"cronjobs.processSubscriptions: Exception thrown; rolling back");
|
||||||
await dbconn.query('ROLLBACK');
|
await dbconn.query('ROLLBACK');
|
||||||
throw(e);
|
throw(e);
|
||||||
|
|
|
@ -53,6 +53,7 @@ export async function apiRequest(tokens: TokenPair, endpoint: string): Promise <
|
||||||
return fetch("https://api.twitch.tv/helix" + endpoint, { headers: headers })
|
return fetch("https://api.twitch.tv/helix" + endpoint, { headers: headers })
|
||||||
.then(async (res: FetchResponse) => {
|
.then(async (res: FetchResponse) => {
|
||||||
if (res.status == 200) {
|
if (res.status == 200) {
|
||||||
|
log(LogLevel.DEBUG,"twitch.apiRequest: Request returned 200 for " + endpoint);
|
||||||
return res.json();
|
return res.json();
|
||||||
} else {
|
} else {
|
||||||
log(LogLevel.WARNING,"twitch.apiRequest: Failed API request (pre-refresh):");
|
log(LogLevel.WARNING,"twitch.apiRequest: Failed API request (pre-refresh):");
|
||||||
|
|
|
@ -5,7 +5,7 @@ import pg from "pg";
|
||||||
import db from "./db";
|
import db from "./db";
|
||||||
|
|
||||||
var versionMajor = 0;
|
var versionMajor = 0;
|
||||||
var versionMinor = 7;
|
var versionMinor = 8;
|
||||||
var versionPatch = 0;
|
var versionPatch = 0;
|
||||||
|
|
||||||
export function getVersion() {
|
export function getVersion() {
|
||||||
|
|
Loading…
Reference in New Issue