Browse Source

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

* Rename Subscription to subscriptions

* Update changelog
pull/4580/head
Thomas Kaul 1 week ago
committed by GitHub
parent
commit
3091c3f080
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 10
      apps/api/src/app/admin/admin.service.ts
  3. 8
      apps/api/src/app/user/user.service.ts
  4. 4
      apps/api/src/services/symbol-profile/symbol-profile.service.ts
  5. 2
      prisma/schema.prisma

1
CHANGELOG.md

@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- 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
- Migrated the lookup functionality by `isin` of the _Financial Modeling Prep_ service to its stable API version

10
apps/api/src/app/admin/admin.service.ts

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

8
apps/api/src/app/user/user.service.ts

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

4
apps/api/src/services/symbol-profile/symbol-profile.service.ts

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

2
prisma/schema.prisma

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

Loading…
Cancel
Save