change psql-lib from knex to postgres.js
This commit is contained in:
@ -2,14 +2,17 @@ import fetch from "flumm-fetch-cookies";
|
||||
import { promises as fs } from "fs";
|
||||
import { exec } from "child_process";
|
||||
import cfg from "../config.mjs";
|
||||
import sql from "../sql.mjs";
|
||||
import db from "../sql.mjs";
|
||||
import lib from "../lib.mjs";
|
||||
|
||||
const cleanTags = async () => {
|
||||
const tags = await sql("tags")
|
||||
.leftJoin("tags_assign", "tags_assign.tag_id", "tags.id")
|
||||
.whereNull("tags_assign.item_id");
|
||||
|
||||
/*const cleanTags = async () => {
|
||||
const tags = await db`
|
||||
select *
|
||||
from "tags"
|
||||
left join "tags_assign" on "tags_assign".tag_id = "tags".id
|
||||
where "tags_assign".item_id is null
|
||||
`;
|
||||
|
||||
if(tags.length === 0)
|
||||
return 0;
|
||||
|
||||
@ -23,7 +26,7 @@ const cleanTags = async () => {
|
||||
});
|
||||
await deleteTag.del();
|
||||
return dtags;
|
||||
};
|
||||
};*/
|
||||
|
||||
export default async bot => {
|
||||
|
||||
@ -49,7 +52,10 @@ export default async bot => {
|
||||
case "limit":
|
||||
return e.reply(`up to ${lib.formatSize(cfg.main.maxfilesize)} (${lib.formatSize(cfg.main.maxfilesize * cfg.main.adminmultiplier)} for admins)`);
|
||||
case "thumb":
|
||||
const rows = await sql("items").select("id");
|
||||
const rows = await db`
|
||||
select id
|
||||
from "items"
|
||||
`;
|
||||
const dir = (await fs.readdir("./public/t")).filter(d => d.endsWith(".png")).map(e => +e.split(".")[0]);
|
||||
const tmp = [];
|
||||
for(let row of rows)
|
||||
@ -69,10 +75,10 @@ export default async bot => {
|
||||
e.reply("hay hay patron, hemen!");
|
||||
exec("sudo systemctl restart f0ck");
|
||||
break;
|
||||
case "cleanTags":
|
||||
/*case "cleanTags":
|
||||
const tags = await cleanTags();
|
||||
e.reply(tags + " tags removed");
|
||||
break;
|
||||
break;*/
|
||||
case "clearTmp":
|
||||
await Promise.all((await fs.readdir("./tmp")).filter(d => d !== ".empty").map(async d => fs.unlink(`./tmp/${d}`)));
|
||||
e.reply("cleared lol");
|
||||
|
Reference in New Issue
Block a user