mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-20 07:49:58 +00:00
20 lines
726 B
TypeScript
20 lines
726 B
TypeScript
![]() |
import { getRepository, Repository } from "typeorm";
|
||
|
import { ScheduledPost } from "./entities/ScheduledPost";
|
||
|
import { BaseRepository } from "./BaseRepository";
|
||
|
import moment from "moment-timezone";
|
||
|
import { DBDateFormat } from "../utils";
|
||
|
|
||
|
export class ScheduledPosts extends BaseRepository {
|
||
|
private scheduledPosts: Repository<ScheduledPost>;
|
||
|
|
||
|
constructor() {
|
||
|
super();
|
||
|
this.scheduledPosts = getRepository(ScheduledPost);
|
||
|
}
|
||
|
|
||
|
getScheduledPostsDueSoon(threshold: number): Promise<ScheduledPost[]> {
|
||
|
const thresholdDateStr = moment.utc().add(threshold, "ms").format(DBDateFormat);
|
||
|
return this.scheduledPosts.createQueryBuilder().andWhere("post_at <= :date", { date: thresholdDateStr }).getMany();
|
||
|
}
|
||
|
}
|