mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
setup community statistics
This commit is contained in:
parent
2f67e5f98a
commit
924db68d06
@ -44,4 +44,5 @@ export enum RIGHTS {
|
|||||||
LIST_CONTRIBUTION_LINKS = 'LIST_CONTRIBUTION_LINKS',
|
LIST_CONTRIBUTION_LINKS = 'LIST_CONTRIBUTION_LINKS',
|
||||||
DELETE_CONTRIBUTION_LINK = 'DELETE_CONTRIBUTION_LINK',
|
DELETE_CONTRIBUTION_LINK = 'DELETE_CONTRIBUTION_LINK',
|
||||||
UPDATE_CONTRIBUTION_LINK = 'UPDATE_CONTRIBUTION_LINK',
|
UPDATE_CONTRIBUTION_LINK = 'UPDATE_CONTRIBUTION_LINK',
|
||||||
|
COMMUNITY_STATISTICS = 'COMMUNITY_STATISTICS',
|
||||||
}
|
}
|
||||||
|
|||||||
26
backend/src/graphql/model/CommunityStatistics.ts
Normal file
26
backend/src/graphql/model/CommunityStatistics.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { ObjectType, Field } from 'type-graphql'
|
||||||
|
import Decimal from 'decimal.js-light'
|
||||||
|
|
||||||
|
@ObjectType()
|
||||||
|
export class CommunityStatistics {
|
||||||
|
@Field(() => Number)
|
||||||
|
totalUsers: number
|
||||||
|
|
||||||
|
@Field(() => Number)
|
||||||
|
activeUsers: number
|
||||||
|
|
||||||
|
@Field(() => Number)
|
||||||
|
deletedUsers: number
|
||||||
|
|
||||||
|
@Field(() => Decimal)
|
||||||
|
totalGradidoCreated: Decimal
|
||||||
|
|
||||||
|
@Field(() => Decimal)
|
||||||
|
totalGradidoDecayed: Decimal
|
||||||
|
|
||||||
|
@Field(() => Decimal)
|
||||||
|
totalGradidoAvailable: Decimal
|
||||||
|
|
||||||
|
@Field(() => Decimal)
|
||||||
|
totalGradidoUnbookedDecayed: Decimal
|
||||||
|
}
|
||||||
26
backend/src/graphql/resolver/StatisticsResolver.ts
Normal file
26
backend/src/graphql/resolver/StatisticsResolver.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { Resolver, Query, Arg, Args, Authorized, Ctx, Int } from 'type-graphql'
|
||||||
|
import { RIGHTS } from '@/auth/RIGHTS'
|
||||||
|
import { CommunityStatistics } from '@model/CommunityStatistics'
|
||||||
|
import { User as DbUser } from '@entity/User'
|
||||||
|
import { getConnection } from '@dbTools/typeorm'
|
||||||
|
import Decimal from 'decimal.js-light'
|
||||||
|
|
||||||
|
@Resolver()
|
||||||
|
export class StatisticsResolver {
|
||||||
|
@Authorized([RIGHTS.COMMUNITY_STATISTICS])
|
||||||
|
@Query(() => CommunityStatistics)
|
||||||
|
async communityStatistics(): Promise<CommunityStatistics> {
|
||||||
|
const totalUsers = await DbUser.find({ withDeleted: true })
|
||||||
|
console.log(totalUsers.length)
|
||||||
|
|
||||||
|
return {
|
||||||
|
totalUsers: 12,
|
||||||
|
activeUsers: 6,
|
||||||
|
deletedUsers: 1,
|
||||||
|
totalGradidoCreated: new Decimal(3000),
|
||||||
|
totalGradidoDecayed: new Decimal(200),
|
||||||
|
totalGradidoAvailable: new Decimal(2800),
|
||||||
|
totalGradidoUnbookedDecayed: new Decimal(200),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user