feat(subscriptions): added polar as payment provider for subscriptions
* feature(dashboard): add polar / subscription * wip(payments): manage subscription * wip(payments): add free product, faq and some other improvements * fix(root): change node to bundler in tsconfig * wip(payments): display current subscription * feat(dashboard): schedule project for deletion * wip(payments): support custom products/subscriptions * wip(payments): fix polar scripts * wip(payments): add json package to dockerfiles
This commit is contained in:
committed by
GitHub
parent
86bf9dd064
commit
168ebc3430
34
apps/worker/src/jobs/cron.delete-projects.ts
Normal file
34
apps/worker/src/jobs/cron.delete-projects.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { logger } from '@/utils/logger';
|
||||
import { generateSalt } from '@openpanel/common/server';
|
||||
import { TABLE_NAMES, ch, chQuery, db } from '@openpanel/db';
|
||||
import { escape } from 'sqlstring';
|
||||
|
||||
export async function deleteProjects() {
|
||||
const projects = await db.project.findMany({
|
||||
where: {
|
||||
deleteAt: {
|
||||
lte: new Date(),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (projects.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const project of projects) {
|
||||
await db.project.delete({
|
||||
where: {
|
||||
id: project.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
await ch.command({
|
||||
query: `DELETE FROM ${TABLE_NAMES.events} WHERE project_id IN (${projects.map((project) => escape(project.id)).join(',')});`,
|
||||
});
|
||||
|
||||
logger.info(`Deleted ${projects.length} projects`, {
|
||||
projects,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user