Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions apps/web/utils/ai/choose-rule/match-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getConditionTypes, isAIRule } from "@/utils/condition";
import {
findMatchingGroup,
getGroupsWithRules,
type GroupsWithRules,
} from "@/utils/group/find-matching-group";
import type { ParsedMessage, RuleWithActions } from "@/utils/types";
import {
Expand Down Expand Up @@ -296,7 +297,7 @@ export function evaluateRuleConditions({

// Lazy load learned patterns when needed
class LearnedPatternsLoader {
private groups?: Awaited<ReturnType<typeof getGroupsWithRules>> | null;
private groups?: GroupsWithRules | null;

async getGroups(emailAccountId: string) {
if (this.groups === undefined)
Expand Down Expand Up @@ -496,7 +497,7 @@ export function splitEmailPatterns(pattern: string): string[] {

function matchesGroupRule(
rule: RuleWithActions,
groups: Awaited<ReturnType<typeof getGroupsWithRules>>,
groups: GroupsWithRules,
message: ParsedMessage,
) {
const ruleGroup = groups.find((g) => g.rule?.id === rule.id);
Expand Down
9 changes: 7 additions & 2 deletions apps/web/utils/group/find-matching-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ import { generalizeSubject } from "@/utils/string";
import type { ParsedMessage } from "@/utils/types";
import { type GroupItem, GroupItemType } from "@prisma/client";

type GroupsWithRules = Awaited<ReturnType<typeof getGroupsWithRules>>;
export type GroupsWithRules = Awaited<ReturnType<typeof getGroupsWithRules>>;

export async function getGroupsWithRules({
emailAccountId,
enabledOnly = true,
}: {
emailAccountId: string;
enabledOnly?: boolean;
}) {
return prisma.group.findMany({
where: { emailAccountId, rule: { isNot: null } },
where: {
emailAccountId,
rule: enabledOnly ? { enabled: true } : { isNot: null },
},
include: { items: true, rule: { include: { actions: true } } },
});
}
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.17.8
v2.17.9
Loading