Browse Source
			
			
			Feature/add activities count to GET user endpoint (#4351)
			
				* Add activities count to GET user endpoint
* Update changelog
			
			
				pull/4330/head^2
			
			
		 
		
			
				
					
						 Shaunak Das
					
					8 months ago
						Shaunak Das
					
					8 months ago
					
						
							committed by
							
								 GitHub
								GitHub
							
						 
					
				 
				
			 
		 
		
			
				
					
					No known key found for this signature in database
					
						
							GPG Key ID: B5690EEEBB952194
						
					
				
			
		
		
		
	
		
			
				 3 changed files with 
9 additions and 
2 deletions
			 
			
		 
		
			
				- 
					
					
					 
					CHANGELOG.md
				
- 
					
					
					 
					apps/api/src/app/user/user.service.ts
				
- 
					
					
					 
					libs/common/src/lib/interfaces/user.interface.ts
				
				
				
					
						
							
								
									
	
		
		
			
				
					|  | @ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | 
			
		
	
		
		
			
				
					|  |  | ### Added |  |  | ### Added | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | - Extended the export functionality by the tags |  |  | - Extended the export functionality by the tags | 
			
		
	
		
		
			
				
					|  |  |  |  |  | - Extended the user endpoint `GET api/v1/user` by the activities count | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | ### Changed |  |  | ### Changed | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
		
			
				
					|  | @ -86,6 +86,9 @@ export class UserService { | 
			
		
	
		
		
			
				
					|  |  |         orderBy: { alias: 'asc' }, |  |  |         orderBy: { alias: 'asc' }, | 
			
		
	
		
		
			
				
					|  |  |         where: { GranteeUser: { id } } |  |  |         where: { GranteeUser: { id } } | 
			
		
	
		
		
			
				
					|  |  |       }), |  |  |       }), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       this.prismaService.order.count({ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         where: { userId: id } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       }), | 
			
		
	
		
		
			
				
					|  |  |       this.prismaService.order.findFirst({ |  |  |       this.prismaService.order.findFirst({ | 
			
		
	
		
		
			
				
					|  |  |         orderBy: { |  |  |         orderBy: { | 
			
		
	
		
		
			
				
					|  |  |           date: 'asc' |  |  |           date: 'asc' | 
			
		
	
	
		
		
			
				
					|  | @ -96,8 +99,9 @@ export class UserService { | 
			
		
	
		
		
			
				
					|  |  |     ]); |  |  |     ]); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     const access = userData[0]; |  |  |     const access = userData[0]; | 
			
		
	
		
		
			
				
					
					|  |  |     const firstActivity = userData[1]; |  |  |     const activitiesCount = userData[1]; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |     let tags = userData[2]; |  |  |     const firstActivity = userData[2]; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |     let tags = userData[3]; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     let systemMessage: SystemMessage; |  |  |     let systemMessage: SystemMessage; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | @ -117,6 +121,7 @@ export class UserService { | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     return { |  |  |     return { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       activitiesCount, | 
			
		
	
		
		
			
				
					|  |  |       id, |  |  |       id, | 
			
		
	
		
		
			
				
					|  |  |       permissions, |  |  |       permissions, | 
			
		
	
		
		
			
				
					|  |  |       subscription, |  |  |       subscription, | 
			
		
	
	
		
		
			
				
					|  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
		
			
				
					|  | @ -10,6 +10,7 @@ import { UserSettings } from './user-settings.interface'; | 
			
		
	
		
		
			
				
					|  |  | export interface User { |  |  | export interface User { | 
			
		
	
		
		
			
				
					|  |  |   access: Pick<Access, 'alias' | 'id' | 'permissions'>[]; |  |  |   access: Pick<Access, 'alias' | 'id' | 'permissions'>[]; | 
			
		
	
		
		
			
				
					|  |  |   accounts: Account[]; |  |  |   accounts: Account[]; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |   activitiesCount: number; | 
			
		
	
		
		
			
				
					|  |  |   dateOfFirstActivity: Date; |  |  |   dateOfFirstActivity: Date; | 
			
		
	
		
		
			
				
					|  |  |   id: string; |  |  |   id: string; | 
			
		
	
		
		
			
				
					|  |  |   permissions: string[]; |  |  |   permissions: string[]; | 
			
		
	
	
		
		
			
				
					|  | 
 |