Skip to content

Move over relations to emailAccount #412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 184 commits into from
May 4, 2025
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
184 commits
Select commit Hold shift + click to select a range
d4e072d
move over relations to emailaccount
elie222 Apr 20, 2025
fbd844a
more fixes
elie222 Apr 20, 2025
33a7413
move over more code
elie222 Apr 20, 2025
5d34941
move over more relations
elie222 Apr 20, 2025
5e6659c
more move overs
elie222 Apr 20, 2025
4de18e3
more
elie222 Apr 20, 2025
2fc3424
move over more
elie222 Apr 20, 2025
9d9a255
user email or
elie222 Apr 20, 2025
5dcef89
move over more relations
elie222 Apr 20, 2025
d9e4ab5
move remaning multi accounts over
elie222 Apr 21, 2025
066425a
account switcher ui
elie222 Apr 21, 2025
716ed96
update cursor rules
elie222 Apr 21, 2025
653f533
add account fetch hook
elie222 Apr 21, 2025
609e433
show accounts
elie222 Apr 21, 2025
f0c3f4c
fix mobile switcher
elie222 Apr 21, 2025
d61b90f
symbol
elie222 Apr 21, 2025
82824c8
keyboard shortcut switcher
elie222 Apr 21, 2025
142178d
fix modifier crash
elie222 Apr 21, 2025
fe9d943
add account link
elie222 Apr 21, 2025
2a3793a
Merge branch 'main' into multi-email
elie222 Apr 21, 2025
82edcf5
use account hook
elie222 Apr 21, 2025
77d181f
use account hook
elie222 Apr 21, 2025
021713a
clean up useaccount
elie222 Apr 21, 2025
6d1ed9d
add withauth middleware
elie222 Apr 21, 2025
86a2c83
fix nuqs
elie222 Apr 21, 2025
3fc590b
withauth
elie222 Apr 21, 2025
96306d5
add next safe action
elie222 Apr 22, 2025
f34b96d
move user actions to next safe action
elie222 Apr 22, 2025
c41e7c2
account provider
elie222 Apr 22, 2025
6da9772
fix email account cache
elie222 Apr 22, 2025
2992b52
Merge branch 'main' into multi-email
elie222 Apr 23, 2025
97f9592
safe action for whitelist and webhook
elie222 Apr 23, 2025
0a34846
safe action unsubscriber
elie222 Apr 23, 2025
c57deb8
Merge branch 'main' into multi-email
elie222 Apr 23, 2025
6db8e74
rule action
elie222 Apr 23, 2025
8d4cc34
reply tracking action
elie222 Apr 23, 2025
d46df21
premium action
elie222 Apr 23, 2025
c94615c
permissions action
elie222 Apr 23, 2025
bd5e23b
mail and knowledge actions
elie222 Apr 23, 2025
6e7244c
move more to next safe action
elie222 Apr 23, 2025
4c1beaf
admin action client
elie222 Apr 23, 2025
2fdddcc
action client
elie222 Apr 23, 2025
364c12a
clean action
elie222 Apr 23, 2025
136f0d9
cold email action
elie222 Apr 23, 2025
25dc89f
last move over
elie222 Apr 23, 2025
1049cbc
webhook
elie222 Apr 23, 2025
173d94f
assess
elie222 Apr 23, 2025
7066a6c
admin
elie222 Apr 23, 2025
77807d3
report mistake
elie222 Apr 23, 2025
4622fa6
rules
elie222 Apr 23, 2025
60c4984
clean up
elie222 Apr 23, 2025
225e8e4
fix up actions
elie222 Apr 23, 2025
6f49c26
reply tracker action
elie222 Apr 23, 2025
4b4a66a
clean up use account email
elie222 Apr 23, 2025
dc967c8
unsub action
elie222 Apr 23, 2025
83a7c3d
actions
elie222 Apr 23, 2025
efc7163
remove usesessions
elie222 Apr 23, 2025
d8ad19a
fix
elie222 Apr 23, 2025
8284f4a
More fixes
elie222 Apr 23, 2025
780112d
fix
elie222 Apr 23, 2025
83c7311
fix
elie222 Apr 23, 2025
a4ff35f
fix
elie222 Apr 23, 2025
a38b813
next safe action
elie222 Apr 24, 2025
109de9f
remove isactionerror
elie222 Apr 24, 2025
6cff1a7
fix infinite loop
elie222 Apr 24, 2025
2c8e8c0
add account id to path
elie222 Apr 24, 2025
91ec7f8
move over more to email support
elie222 Apr 24, 2025
77f7566
move over more email
elie222 Apr 24, 2025
e3a5850
more fixes
elie222 Apr 24, 2025
c101290
fix more user email
elie222 Apr 24, 2025
fc23663
update mdcs
elie222 Apr 24, 2025
156adb7
snippets
elie222 Apr 24, 2025
3bf5fdf
Merge branch 'main' into multi-email
elie222 Apr 24, 2025
cef50c3
fix params
elie222 Apr 25, 2025
e13a32e
mid way through massive refactor
elie222 Apr 25, 2025
2f2c88a
more fixes
elie222 Apr 25, 2025
ead9ec5
more fixes
elie222 Apr 25, 2025
6447aea
more fixes
elie222 Apr 26, 2025
661d906
adjustments to gmail client
elie222 Apr 26, 2025
941a695
clean up
elie222 Apr 26, 2025
f0d9338
more fixes
elie222 Apr 26, 2025
d5bb166
more fixes
elie222 Apr 26, 2025
44aff84
fixes
elie222 Apr 26, 2025
da327c5
fix tests
elie222 Apr 26, 2025
22dd981
fix ts
elie222 Apr 26, 2025
ed25c5a
fixes
elie222 Apr 26, 2025
a32013e
fixes
elie222 Apr 26, 2025
865fc6f
more fixes
elie222 Apr 26, 2025
a078093
emailAccountId fixes
elie222 Apr 26, 2025
c8725c1
fixes
elie222 Apr 26, 2025
421a285
fixes
elie222 Apr 27, 2025
8dc4403
fix
elie222 Apr 27, 2025
2204809
Merge branch 'main' into multi-email
elie222 Apr 27, 2025
e0c31b2
fix tests
elie222 Apr 27, 2025
827b465
Merge branch 'main' into multi-email
elie222 Apr 27, 2025
f5fb0b0
fix tests
elie222 Apr 27, 2025
7bfcfba
fixes
elie222 Apr 27, 2025
6350a27
fixes
elie222 Apr 27, 2025
cf86300
fix provider
elie222 Apr 27, 2025
45d7a44
redirect
elie222 Apr 27, 2025
7073da8
email fixes
elie222 Apr 27, 2025
1be5045
fix automation paths
elie222 Apr 27, 2025
cdc255c
more path fixes. move premium to global
elie222 Apr 27, 2025
6c6baa9
path
elie222 Apr 27, 2025
6c85ac7
unused imports
elie222 Apr 27, 2025
6b68667
refactor old tinybird files
elie222 Apr 27, 2025
524da95
fix useuser useemailaccount
elie222 Apr 27, 2025
a0bcb7d
path fixes
elie222 Apr 27, 2025
77cdeec
fix fetch email accounts
elie222 Apr 27, 2025
78b94d9
delete old code
elie222 Apr 27, 2025
80e533e
move post to action
elie222 Apr 27, 2025
6151322
settings post => action
elie222 Apr 27, 2025
4ee408a
move over email stats to action
elie222 Apr 27, 2025
e94f483
fix build
elie222 Apr 27, 2025
8487e59
clean up
elie222 Apr 27, 2025
b3e4cd7
fix actions
elie222 Apr 27, 2025
381368f
fix action
elie222 Apr 27, 2025
8550ba8
add api middleware tests
elie222 Apr 27, 2025
7e1b46c
clean up test
elie222 Apr 27, 2025
618e3ce
test for isadmin
elie222 Apr 27, 2025
a4c1081
adjust server action rule
elie222 Apr 27, 2025
534b012
clean up
elie222 Apr 27, 2025
03ca109
remove handled todo
elie222 Apr 27, 2025
a7621ae
safer oss page
elie222 Apr 27, 2025
6a2f9fa
remove unused api.ts file
elie222 Apr 27, 2025
b504c2a
fetch with account
elie222 Apr 27, 2025
4bf4637
path prefix for router push
elie222 Apr 27, 2025
22b63dd
tighter sidebar
elie222 Apr 27, 2025
3f5f57f
mdc update
elie222 Apr 28, 2025
0cc49d7
redirects
elie222 Apr 28, 2025
217959a
delete old pages
elie222 Apr 28, 2025
3288299
add account page
elie222 Apr 28, 2025
58b76c2
email account name and image
elie222 Apr 28, 2025
bba8cf4
fix account switcher name/image
elie222 Apr 28, 2025
c43a0da
link account
elie222 Apr 28, 2025
184e760
basic accounts page
elie222 Apr 28, 2025
995556d
delete account action
elie222 Apr 28, 2025
bb63391
fix side links
elie222 Apr 28, 2025
8bd0411
fix drop down nav
elie222 Apr 28, 2025
67bf8ed
side nav
elie222 Apr 28, 2025
0813f71
logs. show account switcher
elie222 Apr 28, 2025
2e72877
accounts pgae
elie222 Apr 28, 2025
a3bc962
fix up accounts
elie222 Apr 28, 2025
8023ecb
remove add accounts page
elie222 Apr 28, 2025
1caec3e
fix delete
elie222 Apr 28, 2025
9e26a9f
dont delete primary email account
elie222 Apr 28, 2025
d44ccf1
delete email account fix
elie222 Apr 28, 2025
c39ac98
cascade delete
elie222 Apr 28, 2025
3cd990f
adjust copy
elie222 Apr 28, 2025
318b265
show email in account switcher
elie222 Apr 28, 2025
69997f4
remove logs
elie222 Apr 28, 2025
f46f5cd
throw access token error
elie222 Apr 28, 2025
c3be7e2
better log
elie222 Apr 28, 2025
20b6870
clean up old user.email usage
elie222 Apr 28, 2025
74d8cfa
encrypt token. use gmail refresh
elie222 Apr 28, 2025
529f001
clean up gmail client
elie222 Apr 28, 2025
4793b03
handle premium for extra email accounts
elie222 Apr 29, 2025
a25c2d9
migrate data. keep user ids intact for now
elie222 Apr 29, 2025
8defc3c
move data from email account back to user
elie222 Apr 29, 2025
52721a9
permissions check fix
elie222 Apr 29, 2025
abd46f0
remove deprecated userids
elie222 Apr 29, 2025
fc0c71c
split up email and user settings
elie222 Apr 30, 2025
4616b21
default provider instead of anthropic
elie222 Apr 30, 2025
dd797ef
fix up settings
elie222 Apr 30, 2025
13e3013
fix build
elie222 Apr 30, 2025
904f179
Add account confirm dialog
elie222 May 1, 2025
f91ead3
remove crypto file
elie222 May 1, 2025
547f8a4
better security
elie222 May 1, 2025
2d60d25
fix cold email get
elie222 May 1, 2025
65b0b40
use prefix path. fix more links
elie222 May 1, 2025
d1dcff8
remove server fetching for settings page
elie222 May 1, 2025
b63be38
revalidate fixes
elie222 May 1, 2025
0e12281
fix settings bug
elie222 May 1, 2025
b9cdc6b
fix tests
elie222 May 1, 2025
0ac9cfe
merge accounts
elie222 May 1, 2025
fd91dd6
fix up account switcher
elie222 May 1, 2025
968cecb
adjust top right
elie222 May 1, 2025
b9beb3c
Merge branch 'main' into multi-email
elie222 May 2, 2025
2935b63
fIx build
elie222 May 2, 2025
c69ee5a
better error log
elie222 May 2, 2025
8391820
redirect to consent if no token
elie222 May 2, 2025
535b120
captureException
elie222 May 2, 2025
ff76e90
perf
elie222 May 2, 2025
8493d29
Merge branch 'main' into multi-email
elie222 May 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 11 additions & 18 deletions apps/web/app/(app)/automation/onboarding/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default async function OnboardingPage() {
);
}

type UserPreferences = Prisma.UserGetPayload<{
type UserPreferences = Prisma.EmailAccountGetPayload<{
select: {
rules: {
select: {
Expand All @@ -46,16 +46,12 @@ async function getUserPreferences({
const emailAccount = await prisma.emailAccount.findUnique({
where: { email },
select: {
user: {
rules: {
select: {
rules: {
systemType: true,
actions: {
select: {
systemType: true,
actions: {
select: {
type: true,
},
},
type: true,
},
},
},
Expand All @@ -66,16 +62,13 @@ async function getUserPreferences({
if (!emailAccount) return undefined;

return {
toReply: getToReplySetting(emailAccount.user.rules),
toReply: getToReplySetting(emailAccount.rules),
coldEmails: getColdEmailSetting(emailAccount.coldEmailBlocker),
newsletter: getRuleSetting(SystemType.NEWSLETTER, emailAccount.user.rules),
marketing: getRuleSetting(SystemType.MARKETING, emailAccount.user.rules),
calendar: getRuleSetting(SystemType.CALENDAR, emailAccount.user.rules),
receipt: getRuleSetting(SystemType.RECEIPT, emailAccount.user.rules),
notification: getRuleSetting(
SystemType.NOTIFICATION,
emailAccount.user.rules,
),
newsletter: getRuleSetting(SystemType.NEWSLETTER, emailAccount.rules),
marketing: getRuleSetting(SystemType.MARKETING, emailAccount.rules),
calendar: getRuleSetting(SystemType.CALENDAR, emailAccount.rules),
receipt: getRuleSetting(SystemType.RECEIPT, emailAccount.rules),
notification: getRuleSetting(SystemType.NOTIFICATION, emailAccount.rules),
};
}

Expand Down
5 changes: 3 additions & 2 deletions apps/web/app/(app)/automation/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export const maxDuration = 300; // Applies to the actions

export default async function AutomationPage() {
const session = await auth();
if (!session?.user) redirect("/login");
const email = session?.user.email;
if (!email) redirect("/login");

// onboarding redirect
const cookieStore = await cookies();
Expand All @@ -32,7 +33,7 @@ export default async function AutomationPage() {

if (!viewedOnboarding) {
const hasRule = await prisma.rule.findFirst({
where: { userId: session.user.id },
where: { emailAccountId: email },
select: { id: true },
});

Expand Down
5 changes: 3 additions & 2 deletions apps/web/app/(app)/automation/rule/[ruleId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ export default async function RulePage(props: {
const searchParams = await props.searchParams;
const params = await props.params;
const session = await auth();
if (!session?.user) redirect("/login");
const email = session?.user.email;
if (!email) redirect("/login");

const rule = await prisma.rule.findUnique({
where: { id: params.ruleId, userId: session.user.id },
where: { id: params.ruleId, emailAccountId: email },
include: {
actions: true,
categoryFilters: true,
Expand Down
10 changes: 5 additions & 5 deletions apps/web/app/(app)/clean/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import prisma from "utils/prisma";

export async function getJobById({
userId,
email,
jobId,
}: {
userId: string;
email: string;
jobId: string;
}) {
return await prisma.cleanupJob.findUnique({
where: { id: jobId, userId },
where: { id: jobId, email },
});
}

export async function getLastJob(userId: string) {
export async function getLastJob({ email }: { email: string }) {
return await prisma.cleanupJob.findFirst({
where: { userId },
where: { email },
orderBy: { createdAt: "desc" },
});
}
5 changes: 3 additions & 2 deletions apps/web/app/(app)/clean/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { Card } from "@/components/ui/card";

export default async function CleanPage() {
const session = await auth();
if (!session?.user.id) return <div>Not authenticated</div>;
const email = session?.user.email;
if (!email) return <div>Not authenticated</div>;

const lastJob = await getLastJob(session.user.id);
const lastJob = await getLastJob({ email });
if (!lastJob) redirect("/clean/onboarding");

return (
Expand Down
13 changes: 7 additions & 6 deletions apps/web/app/(app)/clean/run/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ export default async function CleanRunPage(props: {
const session = await auth();
if (!session?.user.email) return <div>Not authenticated</div>;

const userId = session.user.id;
const userEmail = session.user.email;

const threads = await getThreadsByJobId(userId, jobId);
const threads = await getThreadsByJobId({ emailAccountId: userEmail, jobId });

const job = jobId
? await getJobById({ userId, jobId })
: await getLastJob(userId);
? await getJobById({ email: userEmail, jobId })
: await getLastJob({ email: userEmail });

if (!job) return <CardTitle>Job not found</CardTitle>;

const [total, done] = await Promise.all([
prisma.cleanupThread.count({ where: { jobId, userId } }),
prisma.cleanupThread.count({ where: { jobId, userId, archived: true } }),
prisma.cleanupThread.count({ where: { jobId, emailAccountId: userEmail } }),
prisma.cleanupThread.count({
where: { jobId, emailAccountId: userEmail, archived: true },
}),
]);

return (
Expand Down
10 changes: 4 additions & 6 deletions apps/web/app/(app)/reply-zero/AwaitingReply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@ import { getPaginatedThreadTrackers } from "./fetch-trackers";
import type { TimeRange } from "./date-filter";

export async function AwaitingReply({
userId,
userEmail,
email,
page,
timeRange,
isAnalyzing,
}: {
userId: string;
userEmail: string;
email: string;
page: number;
timeRange: TimeRange;
isAnalyzing: boolean;
}) {
const { trackers, totalPages } = await getPaginatedThreadTrackers({
userId,
email,
type: ThreadTrackerType.AWAITING,
page,
timeRange,
Expand All @@ -26,7 +24,7 @@ export async function AwaitingReply({
return (
<ReplyTrackerEmails
trackers={trackers}
userEmail={userEmail}
email={email}
type={ThreadTrackerType.AWAITING}
totalPages={totalPages}
isAnalyzing={isAnalyzing}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/(app)/reply-zero/NeedsAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function NeedsAction({
isAnalyzing: boolean;
}) {
const { trackers, totalPages } = await getPaginatedThreadTrackers({
userId,
email: userEmail,
type: ThreadTrackerType.NEEDS_ACTION,
page,
timeRange,
Expand All @@ -26,7 +26,7 @@ export async function NeedsAction({
return (
<ReplyTrackerEmails
trackers={trackers}
userEmail={userEmail}
email={userEmail}
type={ThreadTrackerType.NEEDS_ACTION}
totalPages={totalPages}
isAnalyzing={isAnalyzing}
Expand Down
10 changes: 4 additions & 6 deletions apps/web/app/(app)/reply-zero/NeedsReply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@ import { getPaginatedThreadTrackers } from "./fetch-trackers";
import type { TimeRange } from "./date-filter";

export async function NeedsReply({
userId,
userEmail,
email,
page,
timeRange,
isAnalyzing,
}: {
userId: string;
userEmail: string;
email: string;
page: number;
timeRange: TimeRange;
isAnalyzing: boolean;
}) {
const { trackers, totalPages } = await getPaginatedThreadTrackers({
userId,
email,
type: ThreadTrackerType.NEEDS_REPLY,
page,
timeRange,
Expand All @@ -26,7 +24,7 @@ export async function NeedsReply({
return (
<ReplyTrackerEmails
trackers={trackers}
userEmail={userEmail}
email={email}
type={ThreadTrackerType.NEEDS_REPLY}
totalPages={totalPages}
isAnalyzing={isAnalyzing}
Expand Down
12 changes: 6 additions & 6 deletions apps/web/app/(app)/reply-zero/ReplyTrackerEmails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ import { useTableKeyboardNavigation } from "@/hooks/useTableKeyboardNavigation";

export function ReplyTrackerEmails({
trackers,
userEmail,
email,
type,
isResolved,
totalPages,
isAnalyzing,
}: {
trackers: ThreadTracker[];
userEmail: string;
email: string;
type?: ThreadTrackerType;
isResolved?: boolean;
totalPages: number;
Expand Down Expand Up @@ -179,7 +179,7 @@ export function ReplyTrackerEmails({
<Row
key={thread.id}
message={thread.messages.at(-1)!}
userEmail={userEmail}
email={email}
isResolved={isResolved}
type={type}
setSelectedEmail={setSelectedEmail}
Expand Down Expand Up @@ -257,7 +257,7 @@ export function ReplyTrackerEmails({

function Row({
message,
userEmail,
email,
isResolved,
type,
setSelectedEmail,
Expand All @@ -269,7 +269,7 @@ function Row({
rowRef,
}: {
message: ParsedMessage;
userEmail: string;
email: string;
isResolved?: boolean;
type?: ThreadTrackerType;
setSelectedEmail: (email: { threadId: string; messageId: string }) => void;
Expand Down Expand Up @@ -307,7 +307,7 @@ function Row({
}
subject={message.headers.subject}
snippet={message.snippet}
userEmail={userEmail}
userEmail={email}
threadId={message.threadId}
messageId={message.id}
hideViewEmailButton
Expand Down
12 changes: 5 additions & 7 deletions apps/web/app/(app)/reply-zero/Resolved.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import { Prisma } from "@prisma/client";
const PAGE_SIZE = 20;

export async function Resolved({
userId,
userEmail,
email,
page,
timeRange,
}: {
userId: string;
userEmail: string;
email: string;
page: number;
timeRange: TimeRange;
}) {
Expand All @@ -24,7 +22,7 @@ export async function Resolved({
prisma.$queryRaw<Array<{ id: string }>>`
SELECT MAX(id) as id
FROM "ThreadTracker"
WHERE "userId" = ${userId}
WHERE "emailAccountId" = ${email}
${dateFilter ? Prisma.sql`AND "sentAt" <= (${dateFilter}->>'lte')::timestamp` : Prisma.empty}
GROUP BY "threadId"
HAVING bool_and(resolved) = true
Expand All @@ -35,7 +33,7 @@ export async function Resolved({
prisma.$queryRaw<[{ count: bigint }]>`
SELECT COUNT(DISTINCT "threadId") as count
FROM "ThreadTracker"
WHERE "userId" = ${userId}
WHERE "emailAccountId" = ${email}
${dateFilter ? Prisma.sql`AND "sentAt" <= (${dateFilter}->>'lte')::timestamp` : Prisma.empty}
GROUP BY "threadId"
HAVING bool_and(resolved) = true
Expand All @@ -54,7 +52,7 @@ export async function Resolved({
return (
<ReplyTrackerEmails
trackers={trackers}
userEmail={userEmail}
email={email}
totalPages={totalPages}
isResolved
isAnalyzing={false}
Expand Down
10 changes: 5 additions & 5 deletions apps/web/app/(app)/reply-zero/fetch-trackers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { getDateFilter, type TimeRange } from "./date-filter";
const PAGE_SIZE = 20;

export async function getPaginatedThreadTrackers({
userId,
email,
type,
page,
timeRange = "all",
}: {
userId: string;
email: string;
type: ThreadTrackerType;
page: number;
timeRange?: TimeRange;
Expand All @@ -21,7 +21,7 @@ export async function getPaginatedThreadTrackers({
const [trackers, total] = await Promise.all([
prisma.threadTracker.findMany({
where: {
userId,
emailAccountId: email,
resolved: false,
type,
sentAt: dateFilter,
Expand All @@ -37,15 +37,15 @@ export async function getPaginatedThreadTrackers({
? prisma.$queryRaw<[{ count: bigint }]>`
SELECT COUNT(DISTINCT "threadId") as count
FROM "ThreadTracker"
WHERE "userId" = ${userId}
WHERE "emailAccountId" = ${email}
AND "resolved" = false
AND "type" = ${type}::text::"ThreadTrackerType"
AND "sentAt" <= ${dateFilter.lte}
`
: prisma.$queryRaw<[{ count: bigint }]>`
SELECT COUNT(DISTINCT "threadId") as count
FROM "ThreadTracker"
WHERE "userId" = ${userId}
WHERE "emailAccountId" = ${email}
AND "resolved" = false
AND "type" = ${type}::text::"ThreadTrackerType"
`,
Expand Down
Loading
Loading