Feature/rename Subscription to subscriptions in user database schema (#4575)

* Rename Subscription to subscriptions

* Update changelog
This commit is contained in:
Thomas Kaul 2025-04-21 16:30:01 +02:00 committed by GitHub
parent d6e0b499d9
commit 3091c3f080
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 13 additions and 12 deletions

View File

@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Made the historical market data editor expandable in the admin control panel - Made the historical market data editor expandable in the admin control panel
- Renamed `Subscription` to `subscriptions` in the `User` database schema
- Parallelized the requests in the get quotes functionality of the _Financial Modeling Prep_ service - Parallelized the requests in the get quotes functionality of the _Financial Modeling Prep_ service
- Migrated the lookup functionality by `isin` of the _Financial Modeling Prep_ service to its stable API version - Migrated the lookup functionality by `isin` of the _Financial Modeling Prep_ service to its stable API version

View File

@ -645,7 +645,7 @@ export class AdminService {
Order: { Order: {
where: { where: {
User: { User: {
Subscription: { subscriptions: {
some: { some: {
expiresAt: { expiresAt: {
gt: new Date() gt: new Date()
@ -806,7 +806,7 @@ export class AdminService {
createdAt: true, createdAt: true,
id: true, id: true,
role: true, role: true,
Subscription: { subscriptions: {
orderBy: { orderBy: {
expiresAt: 'desc' expiresAt: 'desc'
}, },
@ -821,7 +821,7 @@ export class AdminService {
}); });
return usersWithAnalytics.map( return usersWithAnalytics.map(
({ _count, Analytics, createdAt, id, role, Subscription }) => { ({ _count, Analytics, createdAt, id, role, subscriptions }) => {
const daysSinceRegistration = const daysSinceRegistration =
differenceInDays(new Date(), createdAt) + 1; differenceInDays(new Date(), createdAt) + 1;
const engagement = Analytics const engagement = Analytics
@ -830,8 +830,8 @@ export class AdminService {
const subscription = const subscription =
this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') && this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') &&
Subscription?.length > 0 subscriptions?.length > 0
? Subscription[0] ? subscriptions[0]
: undefined; : undefined;
return { return {

View File

@ -189,7 +189,7 @@ export class UserService {
provider, provider,
role, role,
Settings, Settings,
Subscription, subscriptions,
thirdPartyId, thirdPartyId,
updatedAt updatedAt
} = await this.prismaService.user.findUnique({ } = await this.prismaService.user.findUnique({
@ -200,7 +200,7 @@ export class UserService {
}, },
Analytics: true, Analytics: true,
Settings: true, Settings: true,
Subscription: true subscriptions: true
}, },
where: userWhereUniqueInput where: userWhereUniqueInput
}); });
@ -340,8 +340,8 @@ export class UserService {
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) { if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) {
user.subscription = await this.subscriptionService.getSubscription({ user.subscription = await this.subscriptionService.getSubscription({
createdAt: user.createdAt, subscriptions,
subscriptions: Subscription createdAt: user.createdAt
}); });
if (user.subscription?.type === 'Basic') { if (user.subscription?.type === 'Basic') {

View File

@ -55,14 +55,14 @@ export class SymbolProfileService {
? { ? {
some: { some: {
User: { User: {
Subscription: { some: { expiresAt: { gt: new Date() } } } subscriptions: { some: { expiresAt: { gt: new Date() } } }
} }
} }
} }
: { : {
every: { every: {
User: { User: {
Subscription: { none: { expiresAt: { gt: new Date() } } } subscriptions: { none: { expiresAt: { gt: new Date() } } }
} }
} }
} }

View File

@ -250,6 +250,7 @@ model User {
id String @id @default(uuid()) id String @id @default(uuid())
provider Provider @default(ANONYMOUS) provider Provider @default(ANONYMOUS)
role Role @default(USER) role Role @default(USER)
subscriptions Subscription[]
thirdPartyId String? thirdPartyId String?
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
watchlist SymbolProfile[] @relation("UserWatchlist") watchlist SymbolProfile[] @relation("UserWatchlist")
@ -261,7 +262,6 @@ model User {
AuthDevice AuthDevice[] AuthDevice AuthDevice[]
Order Order[] Order Order[]
Settings Settings? Settings Settings?
Subscription Subscription[]
SymbolProfile SymbolProfile[] SymbolProfile SymbolProfile[]
Tag Tag[] Tag Tag[]