remove extra async and extra utils

This commit is contained in:
Michael C
2021-09-22 23:34:46 -04:00
parent 4e50f0ab4b
commit 28d637f620
21 changed files with 52 additions and 75 deletions

View File

@@ -10,6 +10,7 @@ export class Mysql implements IDatabase {
constructor(private config: unknown) {
}
// eslint-disable-next-line require-await
async init(): Promise<void> {
this.connection = new MysqlInterface(this.config);
}

View File

@@ -12,6 +12,7 @@ export class Sqlite implements IDatabase {
{
}
// eslint-disable-next-line require-await
async prepare(type: QueryType, query: string, params: any[] = []): Promise<any[]> {
// Logger.debug(`prepare (sqlite): type: ${type}, query: ${query}, params: ${params}`);
const preparedQuery = this.db.prepare(query);
@@ -30,6 +31,7 @@ export class Sqlite implements IDatabase {
}
}
// eslint-disable-next-line require-await
async init(): Promise<void> {
// Make dirs if required
if (!fs.existsSync(path.join(this.config.dbPath, "../"))) {

View File

@@ -10,7 +10,7 @@ type searchSegmentResponse = {
segments: DBSegment[]
};
async function getSegmentsFromDBByVideoID(videoID: VideoID, service: Service): Promise<DBSegment[]> {
function getSegmentsFromDBByVideoID(videoID: VideoID, service: Service): Promise<DBSegment[]> {
return db.prepare(
"all",
`SELECT "UUID", "timeSubmitted", "startTime", "endTime", "category", "actionType", "votes", "views", "locked", "hidden", "shadowHidden" FROM "sponsorTimes"

View File

@@ -1,7 +1,7 @@
import { hashPrefixTester } from "../utils/hashPrefixTester";
import { getSegmentsByHash } from "./getSkipSegments";
import { Request, Response } from "express";
import { ActionType, Category, SegmentUUID, Service, VideoIDHash } from "../types/segments.model";
import { ActionType, Category, SegmentUUID, VideoIDHash } from "../types/segments.model";
import { getService } from "../utils/getService";
export async function getSkipSegmentsByHash(req: Request, res: Response): Promise<Response> {

View File

@@ -116,7 +116,7 @@ const objSwitch = (cases: cases) => (defaultCase: string) => (key: string) =>
const functionSwitch = (cases: cases) => (defaultCase: string) => (key: string) =>
executeIfFunction(objSwitch(cases)(defaultCase)(key));
const dbGetValue = async (userID: HashedUserID, property: string): Promise<string|SegmentUUID|number> => {
const dbGetValue = (userID: HashedUserID, property: string): Promise<string|SegmentUUID|number> => {
return functionSwitch({
userID,
userName: dbGetUsername(userID),

View File

@@ -1,7 +1,7 @@
import { postSkipSegments } from "./postSkipSegments";
import { Request, Response } from "express";
export async function oldSubmitSponsorTimes(req: Request, res: Response): Promise<Response> {
export function oldSubmitSponsorTimes(req: Request, res: Response): Promise<Response> {
req.query.category = "sponsor";
return postSkipSegments(req, res);
}

View File

@@ -274,7 +274,7 @@ async function autoModerateSubmission(apiVideoInfo: APIVideoInfo,
}
}
async function getYouTubeVideoInfo(videoID: VideoID, ignoreCache = false): Promise<APIVideoInfo> {
function getYouTubeVideoInfo(videoID: VideoID, ignoreCache = false): Promise<APIVideoInfo> {
if (config.newLeafURLs !== null) {
return YouTubeAPI.listVideos(videoID, ignoreCache);
} else {

View File

@@ -4,7 +4,7 @@ import { db, privateDB } from "../databases/databases";
import { getHash } from "../utils/getHash";
import { Request, Response } from "express";
async function logUserNameChange(userID: string, newUserName: string, oldUserName: string, updatedByAdmin: boolean): Promise<Response> {
function logUserNameChange(userID: string, newUserName: string, oldUserName: string, updatedByAdmin: boolean): Promise<Response> {
return privateDB.prepare("run",
`INSERT INTO "userNameLogs"("userID", "newUserName", "oldUserName", "updatedByAdmin", "updatedAt") VALUES(?, ?, ?, ?, ?)`,
[userID, newUserName, oldUserName, + updatedByAdmin, new Date().getTime()]