eris/db/jobStore.ts

45 lines
979 B
TypeScript
Raw Normal View History

2023-09-10 18:56:17 +00:00
import { GrammyTypes, IKV } from "../deps.ts";
2023-09-13 09:50:22 +00:00
import { SdTxt2ImgInfo } from "../common/sdApi.ts";
import { PngInfo } from "../common/parsePngInfo.ts";
2023-09-10 18:56:17 +00:00
import { db } from "./db.ts";
export interface JobSchema {
2023-09-12 01:57:44 +00:00
task:
| {
type: "txt2img";
params: Partial<PngInfo>;
}
| {
type: "img2img";
params: Partial<PngInfo>;
fileId: string;
};
2023-09-12 01:57:44 +00:00
from: GrammyTypes.User;
chat: GrammyTypes.Chat;
requestMessageId: number;
2023-09-10 18:56:17 +00:00
status:
| {
type: "waiting";
message?: GrammyTypes.Message.TextMessage;
2023-09-14 01:23:55 +00:00
lastErrorDate?: Date;
}
| {
type: "processing";
progress: number;
worker: string;
updatedDate: Date;
message?: GrammyTypes.Message.TextMessage;
}
| {
type: "done";
info?: SdTxt2ImgInfo;
startDate?: Date;
endDate?: Date;
};
2023-09-10 18:56:17 +00:00
}
export const jobStore = new IKV.Store(db, "job", {
schema: new IKV.Schema<JobSchema>(),
indices: ["status.type"],
});