mirror of https://github.com/ghostfolio/ghostfolio
22 changed files with 421 additions and 120 deletions
@ -0,0 +1,24 @@ |
|||||
|
import { TAG_ID_EXCLUDE_FROM_ANALYSIS } from '@ghostfolio/common/config'; |
||||
|
|
||||
|
import { Prisma, Tag } from '@prisma/client'; |
||||
|
|
||||
|
export const WHERE_ACCOUNT_NOT_EXCLUDED: Prisma.AccountWhereInput = { |
||||
|
isExcluded: false, |
||||
|
tags: { |
||||
|
none: { |
||||
|
tagId: TAG_ID_EXCLUDE_FROM_ANALYSIS |
||||
|
} |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
export function isAccountExcluded(account: { |
||||
|
isExcluded: boolean; |
||||
|
tags?: Tag[]; |
||||
|
}) { |
||||
|
return ( |
||||
|
account.isExcluded || |
||||
|
account.tags?.some(({ id }) => { |
||||
|
return id === TAG_ID_EXCLUDE_FROM_ANALYSIS; |
||||
|
}) === true |
||||
|
); |
||||
|
} |
||||
@ -1,7 +1,11 @@ |
|||||
import { Account } from '@prisma/client'; |
import { User } from '@ghostfolio/common/interfaces'; |
||||
|
|
||||
|
import { Account, Tag } from '@prisma/client'; |
||||
|
|
||||
export interface CreateOrUpdateAccountDialogParams { |
export interface CreateOrUpdateAccountDialogParams { |
||||
account: Omit<Account, 'createdAt' | 'id' | 'updatedAt' | 'userId'> & { |
account: Omit<Account, 'createdAt' | 'id' | 'updatedAt' | 'userId'> & { |
||||
id: string | null; |
id: string | null; |
||||
|
tags?: Tag[]; |
||||
}; |
}; |
||||
|
user: User; |
||||
} |
} |
||||
|
|||||
@ -1,3 +1,6 @@ |
|||||
import { Account, Platform } from '@prisma/client'; |
import { Account, Platform, Tag } from '@prisma/client'; |
||||
|
|
||||
export type AccountWithPlatform = Account & { platform?: Platform }; |
export type AccountWithPlatform = Account & { |
||||
|
platform?: Platform; |
||||
|
tags?: Tag[]; |
||||
|
}; |
||||
|
|||||
@ -0,0 +1,20 @@ |
|||||
|
-- CreateTable |
||||
|
CREATE TABLE "TagsOnAccounts" ( |
||||
|
"accountId" TEXT NOT NULL, |
||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, |
||||
|
"tagId" TEXT NOT NULL, |
||||
|
"updatedAt" TIMESTAMP(3) NOT NULL, |
||||
|
"userId" TEXT NOT NULL, |
||||
|
|
||||
|
CONSTRAINT "TagsOnAccounts_pkey" PRIMARY KEY ("accountId","tagId","userId") |
||||
|
); |
||||
|
|
||||
|
-- CreateIndex |
||||
|
CREATE INDEX "TagsOnAccounts_tagId_idx" ON "TagsOnAccounts"("tagId"); |
||||
|
|
||||
|
-- AddForeignKey |
||||
|
ALTER TABLE "TagsOnAccounts" ADD CONSTRAINT "TagsOnAccounts_accountId_userId_fkey" FOREIGN KEY ("accountId", "userId") REFERENCES "Account"("id", "userId") ON DELETE CASCADE ON UPDATE CASCADE; |
||||
|
|
||||
|
-- AddForeignKey |
||||
|
ALTER TABLE "TagsOnAccounts" ADD CONSTRAINT "TagsOnAccounts_tagId_fkey" FOREIGN KEY ("tagId") REFERENCES "Tag"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
||||
|
|
||||
Loading…
Reference in new issue