From 9931732ded2448eb72a9cb36988bb0f92bbbbeed Mon Sep 17 00:00:00 2001 From: Nathan Rashleigh Date: Sun, 30 Jun 2024 23:19:06 +1000 Subject: [PATCH] linting --- archiver/index.ts | 12 +++--------- archiver/src/scraper.ts | 6 +----- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/archiver/index.ts b/archiver/index.ts index f312d57..6c9fe40 100644 --- a/archiver/index.ts +++ b/archiver/index.ts @@ -1,6 +1,5 @@ import "dotenv/config" -import fs from 'fs/promises' import { exec as execCb } from 'child_process' import { promisify } from 'util' @@ -21,9 +20,9 @@ BigInt.prototype.toJSON = function bigIntStringify() { }; const exec = promisify(execCb) +const log = pino({ base: {} }); async function main() { - const log = pino({ base: {} }); const VISION_CREDENTIALS = JSON.parse(process.env.VISION_CREDENTIALS) const vision = new Vision.ImageAnnotatorClient({ credentials: VISION_CREDENTIALS }) @@ -43,7 +42,7 @@ async function main() { const memes = await memeService(log, prisma, meili) const attachments = await attachmentService(log, minio, prisma, memes) - const scraper = await discordScraper(process.env.DISCORD_AUTH, vision, minio, prisma, log, attachments) + const scraper = await discordScraper(process.env.DISCORD_AUTH, vision, prisma, log, attachments) const CHANNEL_IDS = [ // 367936426962190336n, // TPM shitposts @@ -59,14 +58,9 @@ async function main() { } await migrateDb() - - log.info('ready') - await Promise.all(CHANNEL_IDS.map(id => scraper.processChannel(id))) } main() .then(() => true) - .catch(e => console.error(e)) - - + .catch(e => log.error(e)) diff --git a/archiver/src/scraper.ts b/archiver/src/scraper.ts index 4047f24..619cdbb 100644 --- a/archiver/src/scraper.ts +++ b/archiver/src/scraper.ts @@ -8,8 +8,6 @@ import type { ImageAnnotatorClient } from '@google-cloud/vision'; import type { Logger } from 'pino'; import type Minio from 'minio' -import sharp from 'sharp'; - import type { AttachmentService } from './attachments' import { IMAGE_TYPES, VIDEO_TYPES } from './attachments' @@ -25,7 +23,6 @@ function convertSnowflakeToDate(snowflake) { export default async function discordScraper( discordAuth, vision: ImageAnnotatorClient, - minio: Minio.Client, prisma: PrismaClient, baseLog: Logger, attachments: AttachmentService @@ -130,6 +127,7 @@ export default async function discordScraper( } // actually assign vision here + // so we can pass an Attachment to detectText return { ...attachment, vision: await detectText(attachment) } })) } @@ -166,8 +164,6 @@ export default async function discordScraper( }) } - const history = await ensureHistory() - async function processLoop() { const history = await ensureHistory() const newAttachments = fetchNew(channelId, log, history.latestMessageId)