Browse Source
			
			
			Bugfix/fix active subscription in user table of admin control (#4544)
			
				* Fix active subscription
* Update changelog
			
			
				pull/4549/head
			
			
		 
		
			
				
					
						
						Thomas Kaul
					
					7 months ago
					
						
							committed by
							
								
								GitHub
							
						 
					
				 
				
			 
		 
		
			
				
					
					No known key found for this signature in database
					
						
							GPG Key ID: B5690EEEBB952194
						
					
				
			
		
		
		
	
		
			
				 3 changed files with 
17 additions and 
14 deletions
			 
			
		 
		
			
				- 
					
					
					 
					apps/api/src/app/admin/admin.module.ts
				
 
			
				- 
					
					
					 
					apps/api/src/app/admin/admin.service.ts
				
 
			
				- 
					
					
					 
					apps/client/src/app/components/admin-users/admin-users.html
				
 
			
		
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					| 
						
						
						
					 | 
				
				 | 
				
					@ -1,5 +1,4 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { OrderModule } from '@ghostfolio/api/app/order/order.module'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { SubscriptionModule } from '@ghostfolio/api/app/subscription/subscription.module'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { TransformDataSourceInRequestModule } from '@ghostfolio/api/interceptors/transform-data-source-in-request/transform-data-source-in-request.module'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { ApiModule } from '@ghostfolio/api/services/api/api.module'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { BenchmarkModule } from '@ghostfolio/api/services/benchmark/benchmark.module'; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -31,7 +30,6 @@ import { QueueModule } from './queue/queue.module'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    PrismaModule, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    PropertyModule, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    QueueModule, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    SubscriptionModule, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    SymbolProfileModule, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    TransformDataSourceInRequestModule | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  ], | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  | 
				
			
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					| 
						
						
						
					 | 
				
				 | 
				
					@ -1,5 +1,4 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { OrderService } from '@ghostfolio/api/app/order/order.service'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { SubscriptionService } from '@ghostfolio/api/app/subscription/subscription.service'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { environment } from '@ghostfolio/api/environments/environment'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { BenchmarkService } from '@ghostfolio/api/services/benchmark/benchmark.service'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -62,7 +61,6 @@ export class AdminService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private readonly orderService: OrderService, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private readonly prismaService: PrismaService, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private readonly propertyService: PropertyService, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private readonly subscriptionService: SubscriptionService, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private readonly symbolProfileService: SymbolProfileService | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  ) {} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -807,7 +805,17 @@ export class AdminService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        createdAt: true, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        id: true, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        role: true, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Subscription: true | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Subscription: { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          orderBy: { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            expiresAt: 'desc' | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          }, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          take: 1, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          where: { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            expiresAt: { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					              gt: new Date() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -819,14 +827,11 @@ export class AdminService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          ? Analytics.activityCount / daysSinceRegistration | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          : undefined; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        const subscription = this.configurationService.get( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          'ENABLE_FEATURE_SUBSCRIPTION' | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        ) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          ? this.subscriptionService.getSubscription({ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					              createdAt, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					              subscriptions: Subscription | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          : undefined; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        const subscription = | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') && | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          Subscription?.length > 0 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            ? Subscription[0] | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            : undefined; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          createdAt, | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  | 
				
			
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -49,7 +49,7 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                  }" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                  >{{ (element.id | slice: 0 : 5) + '...' }}</span | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                > | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                @if (element?.subscription?.type === 'Premium') { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                @if (element.subscription?.expiresAt) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                  <gf-premium-indicator | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    class="ml-1" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    [enableLink]="false" | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |