chore: format
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
export interface $DbEnums {}
|
||||
|
||||
export namespace $DbEnums {
|
||||
type CampaignStatus =
|
||||
| "DRAFT"
|
||||
| "SCHEDULED"
|
||||
| "SENDING"
|
||||
| "COMPLETED"
|
||||
| "CANCELLED";
|
||||
type MessageStatus =
|
||||
| "QUEUED"
|
||||
| "PENDING"
|
||||
| "SENT"
|
||||
| "OPENED"
|
||||
| "CLICKED"
|
||||
| "FAILED"
|
||||
| "RETRYING";
|
||||
type SmtpEncryption = "STARTTLS" | "SSL_TLS" | "NONE";
|
||||
type CampaignStatus =
|
||||
| "DRAFT"
|
||||
| "SCHEDULED"
|
||||
| "SENDING"
|
||||
| "COMPLETED"
|
||||
| "CANCELLED";
|
||||
type MessageStatus =
|
||||
| "QUEUED"
|
||||
| "PENDING"
|
||||
| "SENT"
|
||||
| "OPENED"
|
||||
| "CLICKED"
|
||||
| "FAILED"
|
||||
| "RETRYING";
|
||||
type SmtpEncryption = "STARTTLS" | "SSL_TLS" | "NONE";
|
||||
}
|
||||
|
||||
@@ -4,19 +4,19 @@ import * as $runtime from "../runtime/library";
|
||||
* @param text
|
||||
*/
|
||||
export const countDbSize: (
|
||||
text: string,
|
||||
text: string,
|
||||
) => $runtime.TypedSql<countDbSize.Parameters, countDbSize.Result>;
|
||||
|
||||
export namespace countDbSize {
|
||||
export type Parameters = [text: string];
|
||||
export type Result = {
|
||||
organization_id: string;
|
||||
organization_name: string;
|
||||
campaign_count: bigint | null;
|
||||
template_count: bigint | null;
|
||||
message_count: bigint | null;
|
||||
subscriber_count: bigint | null;
|
||||
list_count: bigint | null;
|
||||
total_size_mb: $runtime.Decimal | null;
|
||||
};
|
||||
export type Parameters = [text: string];
|
||||
export type Result = {
|
||||
organization_id: string;
|
||||
organization_name: string;
|
||||
campaign_count: bigint | null;
|
||||
template_count: bigint | null;
|
||||
message_count: bigint | null;
|
||||
subscriber_count: bigint | null;
|
||||
list_count: bigint | null;
|
||||
total_size_mb: $runtime.Decimal | null;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
"use strict";
|
||||
const { makeTypedQueryFactory: $mkFactory } = require("../runtime/edge.js");
|
||||
exports.countDbSize = /*#__PURE__*/ $mkFactory(
|
||||
'WITH organization_storage AS (\nSELECT\nc."organizationId",\nCOALESCE(SUM(LENGTH(c.content)), 0) as campaign_content_size,\nCOALESCE(SUM(LENGTH(c.subject)), 0) as campaign_subject_size,\nCOALESCE(SUM(LENGTH(c.title)), 0) as campaign_title_size,\nCOALESCE(SUM(LENGTH(c.description)), 0) as campaign_description_size,\nCOUNT(*) as campaign_count\nFROM "Campaign" c\nWHERE c."organizationId" = $1\nGROUP BY c."organizationId"\n),\ntemplate_storage AS (\nSELECT\nt."organizationId",\nCOALESCE(SUM(LENGTH(t.content)), 0) as template_content_size,\nCOALESCE(SUM(LENGTH(t.name)), 0) as template_name_size,\nCOALESCE(SUM(LENGTH(t.description)), 0) as template_description_size,\nCOUNT(*) as template_count\nFROM "Template" t\nWHERE t."organizationId" = $1\nGROUP BY t."organizationId"\n),\nmessage_storage AS (\nSELECT\nc."organizationId",\nCOALESCE(SUM(LENGTH(m.content)), 0) as message_content_size,\nCOALESCE(SUM(LENGTH(m.error)), 0) as message_error_size,\nCOUNT(*) as message_count\nFROM "Message" m\nJOIN "Campaign" c ON c.id = m."campaignId"\nWHERE c."organizationId" = $1\nGROUP BY c."organizationId"\n),\nsubscriber_storage AS (\nSELECT\ns."organizationId",\nCOALESCE(SUM(LENGTH(s.email)), 0) as subscriber_email_size,\nCOALESCE(SUM(LENGTH(s.name)), 0) as subscriber_name_size,\nCOUNT(*) as subscriber_count\nFROM "Subscriber" s\nWHERE s."organizationId" = $1\nGROUP BY s."organizationId"\n),\nlist_storage AS (\nSELECT\nl."organizationId",\nCOALESCE(SUM(LENGTH(l.name)), 0) as list_name_size,\nCOALESCE(SUM(LENGTH(l.description)), 0) as list_description_size,\nCOUNT(*) as list_count\nFROM "List" l\nWHERE l."organizationId" = $1\nGROUP BY l."organizationId"\n)\n\nSELECT\no.id as organization_id,\no.name as organization_name,\nCOALESCE(os.campaign_count, 0) as campaign_count,\nCOALESCE(ts.template_count, 0) as template_count,\nCOALESCE(ms.message_count, 0) as message_count,\nCOALESCE(ss.subscriber_count, 0) as subscriber_count,\nCOALESCE(ls.list_count, 0) as list_count,\n(\nCOALESCE(os.campaign_content_size, 0) +\nCOALESCE(os.campaign_subject_size, 0) +\nCOALESCE(os.campaign_title_size, 0) +\nCOALESCE(os.campaign_description_size, 0) +\nCOALESCE(ts.template_content_size, 0) +\nCOALESCE(ts.template_name_size, 0) +\nCOALESCE(ts.template_description_size, 0) +\nCOALESCE(ms.message_content_size, 0) +\nCOALESCE(ms.message_error_size, 0) +\nCOALESCE(ss.subscriber_email_size, 0) +\nCOALESCE(ss.subscriber_name_size, 0) +\nCOALESCE(ls.list_name_size, 0) +\nCOALESCE(ls.list_description_size, 0)\n) / 1024.0 / 1024.0 as total_size_mb\nFROM "Organization" o\nLEFT JOIN organization_storage os ON o.id = os."organizationId"\nLEFT JOIN template_storage ts ON o.id = ts."organizationId"\nLEFT JOIN message_storage ms ON o.id = ms."organizationId"\nLEFT JOIN subscriber_storage ss ON o.id = ss."organizationId"\nLEFT JOIN list_storage ls ON o.id = ls."organizationId"\nWHERE o.id = $1;',
|
||||
'WITH organization_storage AS (\nSELECT\nc."organizationId",\nCOALESCE(SUM(LENGTH(c.content)), 0) as campaign_content_size,\nCOALESCE(SUM(LENGTH(c.subject)), 0) as campaign_subject_size,\nCOALESCE(SUM(LENGTH(c.title)), 0) as campaign_title_size,\nCOALESCE(SUM(LENGTH(c.description)), 0) as campaign_description_size,\nCOUNT(*) as campaign_count\nFROM "Campaign" c\nWHERE c."organizationId" = $1\nGROUP BY c."organizationId"\n),\ntemplate_storage AS (\nSELECT\nt."organizationId",\nCOALESCE(SUM(LENGTH(t.content)), 0) as template_content_size,\nCOALESCE(SUM(LENGTH(t.name)), 0) as template_name_size,\nCOALESCE(SUM(LENGTH(t.description)), 0) as template_description_size,\nCOUNT(*) as template_count\nFROM "Template" t\nWHERE t."organizationId" = $1\nGROUP BY t."organizationId"\n),\nmessage_storage AS (\nSELECT\nc."organizationId",\nCOALESCE(SUM(LENGTH(m.content)), 0) as message_content_size,\nCOALESCE(SUM(LENGTH(m.error)), 0) as message_error_size,\nCOUNT(*) as message_count\nFROM "Message" m\nJOIN "Campaign" c ON c.id = m."campaignId"\nWHERE c."organizationId" = $1\nGROUP BY c."organizationId"\n),\nsubscriber_storage AS (\nSELECT\ns."organizationId",\nCOALESCE(SUM(LENGTH(s.email)), 0) as subscriber_email_size,\nCOALESCE(SUM(LENGTH(s.name)), 0) as subscriber_name_size,\nCOUNT(*) as subscriber_count\nFROM "Subscriber" s\nWHERE s."organizationId" = $1\nGROUP BY s."organizationId"\n),\nlist_storage AS (\nSELECT\nl."organizationId",\nCOALESCE(SUM(LENGTH(l.name)), 0) as list_name_size,\nCOALESCE(SUM(LENGTH(l.description)), 0) as list_description_size,\nCOUNT(*) as list_count\nFROM "List" l\nWHERE l."organizationId" = $1\nGROUP BY l."organizationId"\n)\n\nSELECT\no.id as organization_id,\no.name as organization_name,\nCOALESCE(os.campaign_count, 0) as campaign_count,\nCOALESCE(ts.template_count, 0) as template_count,\nCOALESCE(ms.message_count, 0) as message_count,\nCOALESCE(ss.subscriber_count, 0) as subscriber_count,\nCOALESCE(ls.list_count, 0) as list_count,\n(\nCOALESCE(os.campaign_content_size, 0) +\nCOALESCE(os.campaign_subject_size, 0) +\nCOALESCE(os.campaign_title_size, 0) +\nCOALESCE(os.campaign_description_size, 0) +\nCOALESCE(ts.template_content_size, 0) +\nCOALESCE(ts.template_name_size, 0) +\nCOALESCE(ts.template_description_size, 0) +\nCOALESCE(ms.message_content_size, 0) +\nCOALESCE(ms.message_error_size, 0) +\nCOALESCE(ss.subscriber_email_size, 0) +\nCOALESCE(ss.subscriber_name_size, 0) +\nCOALESCE(ls.list_name_size, 0) +\nCOALESCE(ls.list_description_size, 0)\n) / 1024.0 / 1024.0 as total_size_mb\nFROM "Organization" o\nLEFT JOIN organization_storage os ON o.id = os."organizationId"\nLEFT JOIN template_storage ts ON o.id = ts."organizationId"\nLEFT JOIN message_storage ms ON o.id = ms."organizationId"\nLEFT JOIN subscriber_storage ss ON o.id = ss."organizationId"\nLEFT JOIN list_storage ls ON o.id = ls."organizationId"\nWHERE o.id = $1;',
|
||||
);
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
/* eslint-disable */
|
||||
import { makeTypedQueryFactory as $mkFactory } from "../runtime/edge.js";
|
||||
export const countDbSize = /*#__PURE__*/ $mkFactory(
|
||||
'WITH organization_storage AS (\nSELECT\nc."organizationId",\nCOALESCE(SUM(LENGTH(c.content)), 0) as campaign_content_size,\nCOALESCE(SUM(LENGTH(c.subject)), 0) as campaign_subject_size,\nCOALESCE(SUM(LENGTH(c.title)), 0) as campaign_title_size,\nCOALESCE(SUM(LENGTH(c.description)), 0) as campaign_description_size,\nCOUNT(*) as campaign_count\nFROM "Campaign" c\nWHERE c."organizationId" = $1\nGROUP BY c."organizationId"\n),\ntemplate_storage AS (\nSELECT\nt."organizationId",\nCOALESCE(SUM(LENGTH(t.content)), 0) as template_content_size,\nCOALESCE(SUM(LENGTH(t.name)), 0) as template_name_size,\nCOALESCE(SUM(LENGTH(t.description)), 0) as template_description_size,\nCOUNT(*) as template_count\nFROM "Template" t\nWHERE t."organizationId" = $1\nGROUP BY t."organizationId"\n),\nmessage_storage AS (\nSELECT\nc."organizationId",\nCOALESCE(SUM(LENGTH(m.content)), 0) as message_content_size,\nCOALESCE(SUM(LENGTH(m.error)), 0) as message_error_size,\nCOUNT(*) as message_count\nFROM "Message" m\nJOIN "Campaign" c ON c.id = m."campaignId"\nWHERE c."organizationId" = $1\nGROUP BY c."organizationId"\n),\nsubscriber_storage AS (\nSELECT\ns."organizationId",\nCOALESCE(SUM(LENGTH(s.email)), 0) as subscriber_email_size,\nCOALESCE(SUM(LENGTH(s.name)), 0) as subscriber_name_size,\nCOUNT(*) as subscriber_count\nFROM "Subscriber" s\nWHERE s."organizationId" = $1\nGROUP BY s."organizationId"\n),\nlist_storage AS (\nSELECT\nl."organizationId",\nCOALESCE(SUM(LENGTH(l.name)), 0) as list_name_size,\nCOALESCE(SUM(LENGTH(l.description)), 0) as list_description_size,\nCOUNT(*) as list_count\nFROM "List" l\nWHERE l."organizationId" = $1\nGROUP BY l."organizationId"\n)\n\nSELECT\no.id as organization_id,\no.name as organization_name,\nCOALESCE(os.campaign_count, 0) as campaign_count,\nCOALESCE(ts.template_count, 0) as template_count,\nCOALESCE(ms.message_count, 0) as message_count,\nCOALESCE(ss.subscriber_count, 0) as subscriber_count,\nCOALESCE(ls.list_count, 0) as list_count,\n(\nCOALESCE(os.campaign_content_size, 0) +\nCOALESCE(os.campaign_subject_size, 0) +\nCOALESCE(os.campaign_title_size, 0) +\nCOALESCE(os.campaign_description_size, 0) +\nCOALESCE(ts.template_content_size, 0) +\nCOALESCE(ts.template_name_size, 0) +\nCOALESCE(ts.template_description_size, 0) +\nCOALESCE(ms.message_content_size, 0) +\nCOALESCE(ms.message_error_size, 0) +\nCOALESCE(ss.subscriber_email_size, 0) +\nCOALESCE(ss.subscriber_name_size, 0) +\nCOALESCE(ls.list_name_size, 0) +\nCOALESCE(ls.list_description_size, 0)\n) / 1024.0 / 1024.0 as total_size_mb\nFROM "Organization" o\nLEFT JOIN organization_storage os ON o.id = os."organizationId"\nLEFT JOIN template_storage ts ON o.id = ts."organizationId"\nLEFT JOIN message_storage ms ON o.id = ms."organizationId"\nLEFT JOIN subscriber_storage ss ON o.id = ss."organizationId"\nLEFT JOIN list_storage ls ON o.id = ls."organizationId"\nWHERE o.id = $1;',
|
||||
'WITH organization_storage AS (\nSELECT\nc."organizationId",\nCOALESCE(SUM(LENGTH(c.content)), 0) as campaign_content_size,\nCOALESCE(SUM(LENGTH(c.subject)), 0) as campaign_subject_size,\nCOALESCE(SUM(LENGTH(c.title)), 0) as campaign_title_size,\nCOALESCE(SUM(LENGTH(c.description)), 0) as campaign_description_size,\nCOUNT(*) as campaign_count\nFROM "Campaign" c\nWHERE c."organizationId" = $1\nGROUP BY c."organizationId"\n),\ntemplate_storage AS (\nSELECT\nt."organizationId",\nCOALESCE(SUM(LENGTH(t.content)), 0) as template_content_size,\nCOALESCE(SUM(LENGTH(t.name)), 0) as template_name_size,\nCOALESCE(SUM(LENGTH(t.description)), 0) as template_description_size,\nCOUNT(*) as template_count\nFROM "Template" t\nWHERE t."organizationId" = $1\nGROUP BY t."organizationId"\n),\nmessage_storage AS (\nSELECT\nc."organizationId",\nCOALESCE(SUM(LENGTH(m.content)), 0) as message_content_size,\nCOALESCE(SUM(LENGTH(m.error)), 0) as message_error_size,\nCOUNT(*) as message_count\nFROM "Message" m\nJOIN "Campaign" c ON c.id = m."campaignId"\nWHERE c."organizationId" = $1\nGROUP BY c."organizationId"\n),\nsubscriber_storage AS (\nSELECT\ns."organizationId",\nCOALESCE(SUM(LENGTH(s.email)), 0) as subscriber_email_size,\nCOALESCE(SUM(LENGTH(s.name)), 0) as subscriber_name_size,\nCOUNT(*) as subscriber_count\nFROM "Subscriber" s\nWHERE s."organizationId" = $1\nGROUP BY s."organizationId"\n),\nlist_storage AS (\nSELECT\nl."organizationId",\nCOALESCE(SUM(LENGTH(l.name)), 0) as list_name_size,\nCOALESCE(SUM(LENGTH(l.description)), 0) as list_description_size,\nCOUNT(*) as list_count\nFROM "List" l\nWHERE l."organizationId" = $1\nGROUP BY l."organizationId"\n)\n\nSELECT\no.id as organization_id,\no.name as organization_name,\nCOALESCE(os.campaign_count, 0) as campaign_count,\nCOALESCE(ts.template_count, 0) as template_count,\nCOALESCE(ms.message_count, 0) as message_count,\nCOALESCE(ss.subscriber_count, 0) as subscriber_count,\nCOALESCE(ls.list_count, 0) as list_count,\n(\nCOALESCE(os.campaign_content_size, 0) +\nCOALESCE(os.campaign_subject_size, 0) +\nCOALESCE(os.campaign_title_size, 0) +\nCOALESCE(os.campaign_description_size, 0) +\nCOALESCE(ts.template_content_size, 0) +\nCOALESCE(ts.template_name_size, 0) +\nCOALESCE(ts.template_description_size, 0) +\nCOALESCE(ms.message_content_size, 0) +\nCOALESCE(ms.message_error_size, 0) +\nCOALESCE(ss.subscriber_email_size, 0) +\nCOALESCE(ss.subscriber_name_size, 0) +\nCOALESCE(ls.list_name_size, 0) +\nCOALESCE(ls.list_description_size, 0)\n) / 1024.0 / 1024.0 as total_size_mb\nFROM "Organization" o\nLEFT JOIN organization_storage os ON o.id = os."organizationId"\nLEFT JOIN template_storage ts ON o.id = ts."organizationId"\nLEFT JOIN message_storage ms ON o.id = ms."organizationId"\nLEFT JOIN subscriber_storage ss ON o.id = ss."organizationId"\nLEFT JOIN list_storage ls ON o.id = ls."organizationId"\nWHERE o.id = $1;',
|
||||
);
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
"use strict";
|
||||
const { makeTypedQueryFactory: $mkFactory } = require("../runtime/library");
|
||||
exports.countDbSize = /*#__PURE__*/ $mkFactory(
|
||||
'WITH organization_storage AS (\nSELECT\nc."organizationId",\nCOALESCE(SUM(LENGTH(c.content)), 0) as campaign_content_size,\nCOALESCE(SUM(LENGTH(c.subject)), 0) as campaign_subject_size,\nCOALESCE(SUM(LENGTH(c.title)), 0) as campaign_title_size,\nCOALESCE(SUM(LENGTH(c.description)), 0) as campaign_description_size,\nCOUNT(*) as campaign_count\nFROM "Campaign" c\nWHERE c."organizationId" = $1\nGROUP BY c."organizationId"\n),\ntemplate_storage AS (\nSELECT\nt."organizationId",\nCOALESCE(SUM(LENGTH(t.content)), 0) as template_content_size,\nCOALESCE(SUM(LENGTH(t.name)), 0) as template_name_size,\nCOALESCE(SUM(LENGTH(t.description)), 0) as template_description_size,\nCOUNT(*) as template_count\nFROM "Template" t\nWHERE t."organizationId" = $1\nGROUP BY t."organizationId"\n),\nmessage_storage AS (\nSELECT\nc."organizationId",\nCOALESCE(SUM(LENGTH(m.content)), 0) as message_content_size,\nCOALESCE(SUM(LENGTH(m.error)), 0) as message_error_size,\nCOUNT(*) as message_count\nFROM "Message" m\nJOIN "Campaign" c ON c.id = m."campaignId"\nWHERE c."organizationId" = $1\nGROUP BY c."organizationId"\n),\nsubscriber_storage AS (\nSELECT\ns."organizationId",\nCOALESCE(SUM(LENGTH(s.email)), 0) as subscriber_email_size,\nCOALESCE(SUM(LENGTH(s.name)), 0) as subscriber_name_size,\nCOUNT(*) as subscriber_count\nFROM "Subscriber" s\nWHERE s."organizationId" = $1\nGROUP BY s."organizationId"\n),\nlist_storage AS (\nSELECT\nl."organizationId",\nCOALESCE(SUM(LENGTH(l.name)), 0) as list_name_size,\nCOALESCE(SUM(LENGTH(l.description)), 0) as list_description_size,\nCOUNT(*) as list_count\nFROM "List" l\nWHERE l."organizationId" = $1\nGROUP BY l."organizationId"\n)\n\nSELECT\no.id as organization_id,\no.name as organization_name,\nCOALESCE(os.campaign_count, 0) as campaign_count,\nCOALESCE(ts.template_count, 0) as template_count,\nCOALESCE(ms.message_count, 0) as message_count,\nCOALESCE(ss.subscriber_count, 0) as subscriber_count,\nCOALESCE(ls.list_count, 0) as list_count,\n(\nCOALESCE(os.campaign_content_size, 0) +\nCOALESCE(os.campaign_subject_size, 0) +\nCOALESCE(os.campaign_title_size, 0) +\nCOALESCE(os.campaign_description_size, 0) +\nCOALESCE(ts.template_content_size, 0) +\nCOALESCE(ts.template_name_size, 0) +\nCOALESCE(ts.template_description_size, 0) +\nCOALESCE(ms.message_content_size, 0) +\nCOALESCE(ms.message_error_size, 0) +\nCOALESCE(ss.subscriber_email_size, 0) +\nCOALESCE(ss.subscriber_name_size, 0) +\nCOALESCE(ls.list_name_size, 0) +\nCOALESCE(ls.list_description_size, 0)\n) / 1024.0 / 1024.0 as total_size_mb\nFROM "Organization" o\nLEFT JOIN organization_storage os ON o.id = os."organizationId"\nLEFT JOIN template_storage ts ON o.id = ts."organizationId"\nLEFT JOIN message_storage ms ON o.id = ms."organizationId"\nLEFT JOIN subscriber_storage ss ON o.id = ss."organizationId"\nLEFT JOIN list_storage ls ON o.id = ls."organizationId"\nWHERE o.id = $1;',
|
||||
'WITH organization_storage AS (\nSELECT\nc."organizationId",\nCOALESCE(SUM(LENGTH(c.content)), 0) as campaign_content_size,\nCOALESCE(SUM(LENGTH(c.subject)), 0) as campaign_subject_size,\nCOALESCE(SUM(LENGTH(c.title)), 0) as campaign_title_size,\nCOALESCE(SUM(LENGTH(c.description)), 0) as campaign_description_size,\nCOUNT(*) as campaign_count\nFROM "Campaign" c\nWHERE c."organizationId" = $1\nGROUP BY c."organizationId"\n),\ntemplate_storage AS (\nSELECT\nt."organizationId",\nCOALESCE(SUM(LENGTH(t.content)), 0) as template_content_size,\nCOALESCE(SUM(LENGTH(t.name)), 0) as template_name_size,\nCOALESCE(SUM(LENGTH(t.description)), 0) as template_description_size,\nCOUNT(*) as template_count\nFROM "Template" t\nWHERE t."organizationId" = $1\nGROUP BY t."organizationId"\n),\nmessage_storage AS (\nSELECT\nc."organizationId",\nCOALESCE(SUM(LENGTH(m.content)), 0) as message_content_size,\nCOALESCE(SUM(LENGTH(m.error)), 0) as message_error_size,\nCOUNT(*) as message_count\nFROM "Message" m\nJOIN "Campaign" c ON c.id = m."campaignId"\nWHERE c."organizationId" = $1\nGROUP BY c."organizationId"\n),\nsubscriber_storage AS (\nSELECT\ns."organizationId",\nCOALESCE(SUM(LENGTH(s.email)), 0) as subscriber_email_size,\nCOALESCE(SUM(LENGTH(s.name)), 0) as subscriber_name_size,\nCOUNT(*) as subscriber_count\nFROM "Subscriber" s\nWHERE s."organizationId" = $1\nGROUP BY s."organizationId"\n),\nlist_storage AS (\nSELECT\nl."organizationId",\nCOALESCE(SUM(LENGTH(l.name)), 0) as list_name_size,\nCOALESCE(SUM(LENGTH(l.description)), 0) as list_description_size,\nCOUNT(*) as list_count\nFROM "List" l\nWHERE l."organizationId" = $1\nGROUP BY l."organizationId"\n)\n\nSELECT\no.id as organization_id,\no.name as organization_name,\nCOALESCE(os.campaign_count, 0) as campaign_count,\nCOALESCE(ts.template_count, 0) as template_count,\nCOALESCE(ms.message_count, 0) as message_count,\nCOALESCE(ss.subscriber_count, 0) as subscriber_count,\nCOALESCE(ls.list_count, 0) as list_count,\n(\nCOALESCE(os.campaign_content_size, 0) +\nCOALESCE(os.campaign_subject_size, 0) +\nCOALESCE(os.campaign_title_size, 0) +\nCOALESCE(os.campaign_description_size, 0) +\nCOALESCE(ts.template_content_size, 0) +\nCOALESCE(ts.template_name_size, 0) +\nCOALESCE(ts.template_description_size, 0) +\nCOALESCE(ms.message_content_size, 0) +\nCOALESCE(ms.message_error_size, 0) +\nCOALESCE(ss.subscriber_email_size, 0) +\nCOALESCE(ss.subscriber_name_size, 0) +\nCOALESCE(ls.list_name_size, 0) +\nCOALESCE(ls.list_description_size, 0)\n) / 1024.0 / 1024.0 as total_size_mb\nFROM "Organization" o\nLEFT JOIN organization_storage os ON o.id = os."organizationId"\nLEFT JOIN template_storage ts ON o.id = ts."organizationId"\nLEFT JOIN message_storage ms ON o.id = ms."organizationId"\nLEFT JOIN subscriber_storage ss ON o.id = ss."organizationId"\nLEFT JOIN list_storage ls ON o.id = ls."organizationId"\nWHERE o.id = $1;',
|
||||
);
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
/* eslint-disable */
|
||||
import { makeTypedQueryFactory as $mkFactory } from "../runtime/library";
|
||||
export const countDbSize = /*#__PURE__*/ $mkFactory(
|
||||
'WITH organization_storage AS (\nSELECT\nc."organizationId",\nCOALESCE(SUM(LENGTH(c.content)), 0) as campaign_content_size,\nCOALESCE(SUM(LENGTH(c.subject)), 0) as campaign_subject_size,\nCOALESCE(SUM(LENGTH(c.title)), 0) as campaign_title_size,\nCOALESCE(SUM(LENGTH(c.description)), 0) as campaign_description_size,\nCOUNT(*) as campaign_count\nFROM "Campaign" c\nWHERE c."organizationId" = $1\nGROUP BY c."organizationId"\n),\ntemplate_storage AS (\nSELECT\nt."organizationId",\nCOALESCE(SUM(LENGTH(t.content)), 0) as template_content_size,\nCOALESCE(SUM(LENGTH(t.name)), 0) as template_name_size,\nCOALESCE(SUM(LENGTH(t.description)), 0) as template_description_size,\nCOUNT(*) as template_count\nFROM "Template" t\nWHERE t."organizationId" = $1\nGROUP BY t."organizationId"\n),\nmessage_storage AS (\nSELECT\nc."organizationId",\nCOALESCE(SUM(LENGTH(m.content)), 0) as message_content_size,\nCOALESCE(SUM(LENGTH(m.error)), 0) as message_error_size,\nCOUNT(*) as message_count\nFROM "Message" m\nJOIN "Campaign" c ON c.id = m."campaignId"\nWHERE c."organizationId" = $1\nGROUP BY c."organizationId"\n),\nsubscriber_storage AS (\nSELECT\ns."organizationId",\nCOALESCE(SUM(LENGTH(s.email)), 0) as subscriber_email_size,\nCOALESCE(SUM(LENGTH(s.name)), 0) as subscriber_name_size,\nCOUNT(*) as subscriber_count\nFROM "Subscriber" s\nWHERE s."organizationId" = $1\nGROUP BY s."organizationId"\n),\nlist_storage AS (\nSELECT\nl."organizationId",\nCOALESCE(SUM(LENGTH(l.name)), 0) as list_name_size,\nCOALESCE(SUM(LENGTH(l.description)), 0) as list_description_size,\nCOUNT(*) as list_count\nFROM "List" l\nWHERE l."organizationId" = $1\nGROUP BY l."organizationId"\n)\n\nSELECT\no.id as organization_id,\no.name as organization_name,\nCOALESCE(os.campaign_count, 0) as campaign_count,\nCOALESCE(ts.template_count, 0) as template_count,\nCOALESCE(ms.message_count, 0) as message_count,\nCOALESCE(ss.subscriber_count, 0) as subscriber_count,\nCOALESCE(ls.list_count, 0) as list_count,\n(\nCOALESCE(os.campaign_content_size, 0) +\nCOALESCE(os.campaign_subject_size, 0) +\nCOALESCE(os.campaign_title_size, 0) +\nCOALESCE(os.campaign_description_size, 0) +\nCOALESCE(ts.template_content_size, 0) +\nCOALESCE(ts.template_name_size, 0) +\nCOALESCE(ts.template_description_size, 0) +\nCOALESCE(ms.message_content_size, 0) +\nCOALESCE(ms.message_error_size, 0) +\nCOALESCE(ss.subscriber_email_size, 0) +\nCOALESCE(ss.subscriber_name_size, 0) +\nCOALESCE(ls.list_name_size, 0) +\nCOALESCE(ls.list_description_size, 0)\n) / 1024.0 / 1024.0 as total_size_mb\nFROM "Organization" o\nLEFT JOIN organization_storage os ON o.id = os."organizationId"\nLEFT JOIN template_storage ts ON o.id = ts."organizationId"\nLEFT JOIN message_storage ms ON o.id = ms."organizationId"\nLEFT JOIN subscriber_storage ss ON o.id = ss."organizationId"\nLEFT JOIN list_storage ls ON o.id = ls."organizationId"\nWHERE o.id = $1;',
|
||||
'WITH organization_storage AS (\nSELECT\nc."organizationId",\nCOALESCE(SUM(LENGTH(c.content)), 0) as campaign_content_size,\nCOALESCE(SUM(LENGTH(c.subject)), 0) as campaign_subject_size,\nCOALESCE(SUM(LENGTH(c.title)), 0) as campaign_title_size,\nCOALESCE(SUM(LENGTH(c.description)), 0) as campaign_description_size,\nCOUNT(*) as campaign_count\nFROM "Campaign" c\nWHERE c."organizationId" = $1\nGROUP BY c."organizationId"\n),\ntemplate_storage AS (\nSELECT\nt."organizationId",\nCOALESCE(SUM(LENGTH(t.content)), 0) as template_content_size,\nCOALESCE(SUM(LENGTH(t.name)), 0) as template_name_size,\nCOALESCE(SUM(LENGTH(t.description)), 0) as template_description_size,\nCOUNT(*) as template_count\nFROM "Template" t\nWHERE t."organizationId" = $1\nGROUP BY t."organizationId"\n),\nmessage_storage AS (\nSELECT\nc."organizationId",\nCOALESCE(SUM(LENGTH(m.content)), 0) as message_content_size,\nCOALESCE(SUM(LENGTH(m.error)), 0) as message_error_size,\nCOUNT(*) as message_count\nFROM "Message" m\nJOIN "Campaign" c ON c.id = m."campaignId"\nWHERE c."organizationId" = $1\nGROUP BY c."organizationId"\n),\nsubscriber_storage AS (\nSELECT\ns."organizationId",\nCOALESCE(SUM(LENGTH(s.email)), 0) as subscriber_email_size,\nCOALESCE(SUM(LENGTH(s.name)), 0) as subscriber_name_size,\nCOUNT(*) as subscriber_count\nFROM "Subscriber" s\nWHERE s."organizationId" = $1\nGROUP BY s."organizationId"\n),\nlist_storage AS (\nSELECT\nl."organizationId",\nCOALESCE(SUM(LENGTH(l.name)), 0) as list_name_size,\nCOALESCE(SUM(LENGTH(l.description)), 0) as list_description_size,\nCOUNT(*) as list_count\nFROM "List" l\nWHERE l."organizationId" = $1\nGROUP BY l."organizationId"\n)\n\nSELECT\no.id as organization_id,\no.name as organization_name,\nCOALESCE(os.campaign_count, 0) as campaign_count,\nCOALESCE(ts.template_count, 0) as template_count,\nCOALESCE(ms.message_count, 0) as message_count,\nCOALESCE(ss.subscriber_count, 0) as subscriber_count,\nCOALESCE(ls.list_count, 0) as list_count,\n(\nCOALESCE(os.campaign_content_size, 0) +\nCOALESCE(os.campaign_subject_size, 0) +\nCOALESCE(os.campaign_title_size, 0) +\nCOALESCE(os.campaign_description_size, 0) +\nCOALESCE(ts.template_content_size, 0) +\nCOALESCE(ts.template_name_size, 0) +\nCOALESCE(ts.template_description_size, 0) +\nCOALESCE(ms.message_content_size, 0) +\nCOALESCE(ms.message_error_size, 0) +\nCOALESCE(ss.subscriber_email_size, 0) +\nCOALESCE(ss.subscriber_name_size, 0) +\nCOALESCE(ls.list_name_size, 0) +\nCOALESCE(ls.list_description_size, 0)\n) / 1024.0 / 1024.0 as total_size_mb\nFROM "Organization" o\nLEFT JOIN organization_storage os ON o.id = os."organizationId"\nLEFT JOIN template_storage ts ON o.id = ts."organizationId"\nLEFT JOIN message_storage ms ON o.id = ms."organizationId"\nLEFT JOIN subscriber_storage ss ON o.id = ss."organizationId"\nLEFT JOIN list_storage ls ON o.id = ls."organizationId"\nWHERE o.id = $1;',
|
||||
);
|
||||
|
||||
@@ -4,15 +4,15 @@ import * as $runtime from "../runtime/library";
|
||||
* @param text
|
||||
*/
|
||||
export const countDistinctRecipients: (
|
||||
text: string,
|
||||
text: string,
|
||||
) => $runtime.TypedSql<
|
||||
countDistinctRecipients.Parameters,
|
||||
countDistinctRecipients.Result
|
||||
countDistinctRecipients.Parameters,
|
||||
countDistinctRecipients.Result
|
||||
>;
|
||||
|
||||
export namespace countDistinctRecipients {
|
||||
export type Parameters = [text: string];
|
||||
export type Result = {
|
||||
count: bigint | null;
|
||||
};
|
||||
export type Parameters = [text: string];
|
||||
export type Result = {
|
||||
count: bigint | null;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
"use strict";
|
||||
const { makeTypedQueryFactory: $mkFactory } = require("../runtime/edge.js");
|
||||
exports.countDistinctRecipients = /*#__PURE__*/ $mkFactory(
|
||||
'SELECT COUNT(DISTINCT "subscriberId")\nFROM "Message" m\nJOIN "Campaign" c ON m."campaignId" = c.id\nWHERE c."organizationId" = $1;',
|
||||
'SELECT COUNT(DISTINCT "subscriberId")\nFROM "Message" m\nJOIN "Campaign" c ON m."campaignId" = c.id\nWHERE c."organizationId" = $1;',
|
||||
);
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
/* eslint-disable */
|
||||
import { makeTypedQueryFactory as $mkFactory } from "../runtime/edge.js";
|
||||
export const countDistinctRecipients = /*#__PURE__*/ $mkFactory(
|
||||
'SELECT COUNT(DISTINCT "subscriberId")\nFROM "Message" m\nJOIN "Campaign" c ON m."campaignId" = c.id\nWHERE c."organizationId" = $1;',
|
||||
'SELECT COUNT(DISTINCT "subscriberId")\nFROM "Message" m\nJOIN "Campaign" c ON m."campaignId" = c.id\nWHERE c."organizationId" = $1;',
|
||||
);
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
"use strict";
|
||||
const { makeTypedQueryFactory: $mkFactory } = require("../runtime/library");
|
||||
exports.countDistinctRecipients = /*#__PURE__*/ $mkFactory(
|
||||
'SELECT COUNT(DISTINCT "subscriberId")\nFROM "Message" m\nJOIN "Campaign" c ON m."campaignId" = c.id\nWHERE c."organizationId" = $1;',
|
||||
'SELECT COUNT(DISTINCT "subscriberId")\nFROM "Message" m\nJOIN "Campaign" c ON m."campaignId" = c.id\nWHERE c."organizationId" = $1;',
|
||||
);
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
/* eslint-disable */
|
||||
import { makeTypedQueryFactory as $mkFactory } from "../runtime/library";
|
||||
export const countDistinctRecipients = /*#__PURE__*/ $mkFactory(
|
||||
'SELECT COUNT(DISTINCT "subscriberId")\nFROM "Message" m\nJOIN "Campaign" c ON m."campaignId" = c.id\nWHERE c."organizationId" = $1;',
|
||||
'SELECT COUNT(DISTINCT "subscriberId")\nFROM "Message" m\nJOIN "Campaign" c ON m."campaignId" = c.id\nWHERE c."organizationId" = $1;',
|
||||
);
|
||||
|
||||
@@ -6,17 +6,17 @@ import * as $runtime from "../runtime/library";
|
||||
* @param timestamp
|
||||
*/
|
||||
export const countDistinctRecipientsInTimeRange: (
|
||||
text: string,
|
||||
timestamp: Date,
|
||||
timestamp: Date,
|
||||
text: string,
|
||||
timestamp: Date,
|
||||
timestamp: Date,
|
||||
) => $runtime.TypedSql<
|
||||
countDistinctRecipientsInTimeRange.Parameters,
|
||||
countDistinctRecipientsInTimeRange.Result
|
||||
countDistinctRecipientsInTimeRange.Parameters,
|
||||
countDistinctRecipientsInTimeRange.Result
|
||||
>;
|
||||
|
||||
export namespace countDistinctRecipientsInTimeRange {
|
||||
export type Parameters = [text: string, timestamp: Date, timestamp: Date];
|
||||
export type Result = {
|
||||
count: bigint | null;
|
||||
};
|
||||
export type Parameters = [text: string, timestamp: Date, timestamp: Date];
|
||||
export type Result = {
|
||||
count: bigint | null;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
"use strict";
|
||||
const { makeTypedQueryFactory: $mkFactory } = require("../runtime/edge.js");
|
||||
exports.countDistinctRecipientsInTimeRange = /*#__PURE__*/ $mkFactory(
|
||||
'SELECT COUNT(DISTINCT "subscriberId")\nFROM "Message" m\nJOIN "Campaign" c ON m."campaignId" = c.id\nWHERE c."organizationId" = $1\nAND m."createdAt" >= $2\nAND m."createdAt" <= $3;',
|
||||
'SELECT COUNT(DISTINCT "subscriberId")\nFROM "Message" m\nJOIN "Campaign" c ON m."campaignId" = c.id\nWHERE c."organizationId" = $1\nAND m."createdAt" >= $2\nAND m."createdAt" <= $3;',
|
||||
);
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
/* eslint-disable */
|
||||
import { makeTypedQueryFactory as $mkFactory } from "../runtime/edge.js";
|
||||
export const countDistinctRecipientsInTimeRange = /*#__PURE__*/ $mkFactory(
|
||||
'SELECT COUNT(DISTINCT "subscriberId")\nFROM "Message" m\nJOIN "Campaign" c ON m."campaignId" = c.id\nWHERE c."organizationId" = $1\nAND m."createdAt" >= $2\nAND m."createdAt" <= $3;',
|
||||
'SELECT COUNT(DISTINCT "subscriberId")\nFROM "Message" m\nJOIN "Campaign" c ON m."campaignId" = c.id\nWHERE c."organizationId" = $1\nAND m."createdAt" >= $2\nAND m."createdAt" <= $3;',
|
||||
);
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
"use strict";
|
||||
const { makeTypedQueryFactory: $mkFactory } = require("../runtime/library");
|
||||
exports.countDistinctRecipientsInTimeRange = /*#__PURE__*/ $mkFactory(
|
||||
'SELECT COUNT(DISTINCT "subscriberId")\nFROM "Message" m\nJOIN "Campaign" c ON m."campaignId" = c.id\nWHERE c."organizationId" = $1\nAND m."createdAt" >= $2\nAND m."createdAt" <= $3;',
|
||||
'SELECT COUNT(DISTINCT "subscriberId")\nFROM "Message" m\nJOIN "Campaign" c ON m."campaignId" = c.id\nWHERE c."organizationId" = $1\nAND m."createdAt" >= $2\nAND m."createdAt" <= $3;',
|
||||
);
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
/* eslint-disable */
|
||||
import { makeTypedQueryFactory as $mkFactory } from "../runtime/library";
|
||||
export const countDistinctRecipientsInTimeRange = /*#__PURE__*/ $mkFactory(
|
||||
'SELECT COUNT(DISTINCT "subscriberId")\nFROM "Message" m\nJOIN "Campaign" c ON m."campaignId" = c.id\nWHERE c."organizationId" = $1\nAND m."createdAt" >= $2\nAND m."createdAt" <= $3;',
|
||||
'SELECT COUNT(DISTINCT "subscriberId")\nFROM "Message" m\nJOIN "Campaign" c ON m."campaignId" = c.id\nWHERE c."organizationId" = $1\nAND m."createdAt" >= $2\nAND m."createdAt" <= $3;',
|
||||
);
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
"use strict";
|
||||
exports.countDbSize = require("./countDbSize.edge.js").countDbSize;
|
||||
exports.countDistinctRecipients =
|
||||
require("./countDistinctRecipients.edge.js").countDistinctRecipients;
|
||||
require("./countDistinctRecipients.edge.js").countDistinctRecipients;
|
||||
exports.countDistinctRecipientsInTimeRange =
|
||||
require("./countDistinctRecipientsInTimeRange.edge.js").countDistinctRecipientsInTimeRange;
|
||||
require("./countDistinctRecipientsInTimeRange.edge.js").countDistinctRecipientsInTimeRange;
|
||||
exports.subscriberGrowthQuery =
|
||||
require("./subscriberGrowthQuery.edge.js").subscriberGrowthQuery;
|
||||
require("./subscriberGrowthQuery.edge.js").subscriberGrowthQuery;
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
"use strict";
|
||||
exports.countDbSize = require("./countDbSize.js").countDbSize;
|
||||
exports.countDistinctRecipients =
|
||||
require("./countDistinctRecipients.js").countDistinctRecipients;
|
||||
require("./countDistinctRecipients.js").countDistinctRecipients;
|
||||
exports.countDistinctRecipientsInTimeRange =
|
||||
require("./countDistinctRecipientsInTimeRange.js").countDistinctRecipientsInTimeRange;
|
||||
require("./countDistinctRecipientsInTimeRange.js").countDistinctRecipientsInTimeRange;
|
||||
exports.subscriberGrowthQuery =
|
||||
require("./subscriberGrowthQuery.js").subscriberGrowthQuery;
|
||||
require("./subscriberGrowthQuery.js").subscriberGrowthQuery;
|
||||
|
||||
@@ -6,18 +6,18 @@ import * as $runtime from "../runtime/library";
|
||||
* @param timestamp
|
||||
*/
|
||||
export const subscriberGrowthQuery: (
|
||||
text: string,
|
||||
timestamp: Date,
|
||||
timestamp: Date,
|
||||
text: string,
|
||||
timestamp: Date,
|
||||
timestamp: Date,
|
||||
) => $runtime.TypedSql<
|
||||
subscriberGrowthQuery.Parameters,
|
||||
subscriberGrowthQuery.Result
|
||||
subscriberGrowthQuery.Parameters,
|
||||
subscriberGrowthQuery.Result
|
||||
>;
|
||||
|
||||
export namespace subscriberGrowthQuery {
|
||||
export type Parameters = [text: string, timestamp: Date, timestamp: Date];
|
||||
export type Result = {
|
||||
date: Date | null;
|
||||
count: bigint | null;
|
||||
};
|
||||
export type Parameters = [text: string, timestamp: Date, timestamp: Date];
|
||||
export type Result = {
|
||||
date: Date | null;
|
||||
count: bigint | null;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
"use strict";
|
||||
const { makeTypedQueryFactory: $mkFactory } = require("../runtime/edge.js");
|
||||
exports.subscriberGrowthQuery = /*#__PURE__*/ $mkFactory(
|
||||
'SELECT\nDATE_TRUNC(\'day\', "createdAt") as date,\nCOUNT(*) as count\nFROM "public"."Subscriber"\nWHERE "organizationId" = $1\nAND "createdAt" >= $2\nAND "createdAt" <= $3\nGROUP BY DATE_TRUNC(\'day\', "createdAt")\nORDER BY date ASC',
|
||||
'SELECT\nDATE_TRUNC(\'day\', "createdAt") as date,\nCOUNT(*) as count\nFROM "public"."Subscriber"\nWHERE "organizationId" = $1\nAND "createdAt" >= $2\nAND "createdAt" <= $3\nGROUP BY DATE_TRUNC(\'day\', "createdAt")\nORDER BY date ASC',
|
||||
);
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
/* eslint-disable */
|
||||
import { makeTypedQueryFactory as $mkFactory } from "../runtime/edge.js";
|
||||
export const subscriberGrowthQuery = /*#__PURE__*/ $mkFactory(
|
||||
'SELECT\nDATE_TRUNC(\'day\', "createdAt") as date,\nCOUNT(*) as count\nFROM "public"."Subscriber"\nWHERE "organizationId" = $1\nAND "createdAt" >= $2\nAND "createdAt" <= $3\nGROUP BY DATE_TRUNC(\'day\', "createdAt")\nORDER BY date ASC',
|
||||
'SELECT\nDATE_TRUNC(\'day\', "createdAt") as date,\nCOUNT(*) as count\nFROM "public"."Subscriber"\nWHERE "organizationId" = $1\nAND "createdAt" >= $2\nAND "createdAt" <= $3\nGROUP BY DATE_TRUNC(\'day\', "createdAt")\nORDER BY date ASC',
|
||||
);
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
"use strict";
|
||||
const { makeTypedQueryFactory: $mkFactory } = require("../runtime/library");
|
||||
exports.subscriberGrowthQuery = /*#__PURE__*/ $mkFactory(
|
||||
'SELECT\nDATE_TRUNC(\'day\', "createdAt") as date,\nCOUNT(*) as count\nFROM "public"."Subscriber"\nWHERE "organizationId" = $1\nAND "createdAt" >= $2\nAND "createdAt" <= $3\nGROUP BY DATE_TRUNC(\'day\', "createdAt")\nORDER BY date ASC',
|
||||
'SELECT\nDATE_TRUNC(\'day\', "createdAt") as date,\nCOUNT(*) as count\nFROM "public"."Subscriber"\nWHERE "organizationId" = $1\nAND "createdAt" >= $2\nAND "createdAt" <= $3\nGROUP BY DATE_TRUNC(\'day\', "createdAt")\nORDER BY date ASC',
|
||||
);
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
/* eslint-disable */
|
||||
import { makeTypedQueryFactory as $mkFactory } from "../runtime/library";
|
||||
export const subscriberGrowthQuery = /*#__PURE__*/ $mkFactory(
|
||||
'SELECT\nDATE_TRUNC(\'day\', "createdAt") as date,\nCOUNT(*) as count\nFROM "public"."Subscriber"\nWHERE "organizationId" = $1\nAND "createdAt" >= $2\nAND "createdAt" <= $3\nGROUP BY DATE_TRUNC(\'day\', "createdAt")\nORDER BY date ASC',
|
||||
'SELECT\nDATE_TRUNC(\'day\', "createdAt") as date,\nCOUNT(*) as count\nFROM "public"."Subscriber"\nWHERE "organizationId" = $1\nAND "createdAt" >= $2\nAND "createdAt" <= $3\nGROUP BY DATE_TRUNC(\'day\', "createdAt")\nORDER BY date ASC',
|
||||
);
|
||||
|
||||
@@ -1,99 +1,99 @@
|
||||
import { hashPassword } from "../src/utils/auth"
|
||||
import { prisma } from "../src/utils/prisma"
|
||||
import { SmtpEncryption } from "./client"
|
||||
import dayjs from "dayjs"
|
||||
import { hashPassword } from "../src/utils/auth";
|
||||
import { prisma } from "../src/utils/prisma";
|
||||
import { SmtpEncryption } from "./client";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
async function seed() {
|
||||
if (!(await prisma.organization.findFirst())) {
|
||||
await prisma.organization.create({
|
||||
data: {
|
||||
name: "Test Organization",
|
||||
description: "Test Description",
|
||||
GeneralSettings: {
|
||||
create: {},
|
||||
},
|
||||
EmailDeliverySettings: {
|
||||
create: {
|
||||
rateLimit: 100,
|
||||
},
|
||||
},
|
||||
SmtpSettings: {
|
||||
create: {
|
||||
host: "smtp.test.com",
|
||||
port: 587,
|
||||
username: "test",
|
||||
password: "test",
|
||||
encryption: SmtpEncryption.STARTTLS,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
if (!(await prisma.organization.findFirst())) {
|
||||
await prisma.organization.create({
|
||||
data: {
|
||||
name: "Test Organization",
|
||||
description: "Test Description",
|
||||
GeneralSettings: {
|
||||
create: {},
|
||||
},
|
||||
EmailDeliverySettings: {
|
||||
create: {
|
||||
rateLimit: 100,
|
||||
},
|
||||
},
|
||||
SmtpSettings: {
|
||||
create: {
|
||||
host: "smtp.test.com",
|
||||
port: 587,
|
||||
username: "test",
|
||||
password: "test",
|
||||
encryption: SmtpEncryption.STARTTLS,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const orgId = (
|
||||
await prisma.organization.findFirst({
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
})
|
||||
)?.id
|
||||
const orgId = (
|
||||
await prisma.organization.findFirst({
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
})
|
||||
)?.id;
|
||||
|
||||
if (!orgId) {
|
||||
throw new Error("not reachable")
|
||||
}
|
||||
if (!orgId) {
|
||||
throw new Error("not reachable");
|
||||
}
|
||||
|
||||
if (!(await prisma.user.findFirst())) {
|
||||
await prisma.user.create({
|
||||
data: {
|
||||
name: "Admin",
|
||||
email: "admin@example.com",
|
||||
password: await hashPassword("password123"),
|
||||
UserOrganizations: {
|
||||
create: {
|
||||
organizationId: orgId,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
if (!(await prisma.user.findFirst())) {
|
||||
await prisma.user.create({
|
||||
data: {
|
||||
name: "Admin",
|
||||
email: "admin@example.com",
|
||||
password: await hashPassword("password123"),
|
||||
UserOrganizations: {
|
||||
create: {
|
||||
organizationId: orgId,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Create 5000 subscribers
|
||||
const subscribers = Array.from({ length: 5000 }, (_, i) => ({
|
||||
name: `Subscriber ${i + 1}`,
|
||||
email: `subscriber${i + 1}@example.com`,
|
||||
organizationId: orgId,
|
||||
createdAt: dayjs().subtract(12, "days").toDate(),
|
||||
}))
|
||||
await prisma.subscriber.createMany({
|
||||
data: subscribers,
|
||||
skipDuplicates: true,
|
||||
})
|
||||
// Then 10 more for each day for 10 days
|
||||
const now = new Date()
|
||||
for (let d = 0; d < 10; d++) {
|
||||
const day = dayjs(now)
|
||||
.subtract(d + 1, "day")
|
||||
.toDate()
|
||||
// Create 5000 subscribers
|
||||
const subscribers = Array.from({ length: 5000 }, (_, i) => ({
|
||||
name: `Subscriber ${i + 1}`,
|
||||
email: `subscriber${i + 1}@example.com`,
|
||||
organizationId: orgId,
|
||||
createdAt: dayjs().subtract(12, "days").toDate(),
|
||||
}));
|
||||
await prisma.subscriber.createMany({
|
||||
data: subscribers,
|
||||
skipDuplicates: true,
|
||||
});
|
||||
// Then 10 more for each day for 10 days
|
||||
const now = new Date();
|
||||
for (let d = 0; d < 10; d++) {
|
||||
const day = dayjs(now)
|
||||
.subtract(d + 1, "day")
|
||||
.toDate();
|
||||
|
||||
const dailySubs = Array.from({ length: 10 }, (_, i) => ({
|
||||
name: `DailySub ${d + 1}-${i + 1}`,
|
||||
email: `dailysub${d + 1}-${i + 1}@example.com`,
|
||||
organizationId: orgId,
|
||||
createdAt: day,
|
||||
updatedAt: day,
|
||||
}))
|
||||
await prisma.subscriber.createMany({
|
||||
data: dailySubs,
|
||||
skipDuplicates: true,
|
||||
})
|
||||
}
|
||||
const dailySubs = Array.from({ length: 10 }, (_, i) => ({
|
||||
name: `DailySub ${d + 1}-${i + 1}`,
|
||||
email: `dailysub${d + 1}-${i + 1}@example.com`,
|
||||
organizationId: orgId,
|
||||
createdAt: day,
|
||||
updatedAt: day,
|
||||
}));
|
||||
await prisma.subscriber.createMany({
|
||||
data: dailySubs,
|
||||
skipDuplicates: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
seed()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect()
|
||||
})
|
||||
.catch(async (e) => {
|
||||
console.error(e)
|
||||
await prisma.$disconnect()
|
||||
})
|
||||
.then(async () => {
|
||||
await prisma.$disconnect();
|
||||
})
|
||||
.catch(async (e) => {
|
||||
console.error(e);
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user