user agents

This commit is contained in:
Ben Wilson
2023-07-25 18:54:18 -04:00
parent e08de753b6
commit 3b583b3d67
5 changed files with 33 additions and 6 deletions
+4 -2
View File
@@ -14,9 +14,12 @@ export class ClientEntity extends TrackedEntity {
@Column({ length: 62, type: 'varchar' })
address: string;
@Column()
@Column({ length: 64, type: 'varchar' })
clientName: string;
@Column({ length: 128, type: 'varchar', nullable: true })
userAgent: string;
@Column({ length: 8, type: 'varchar' })
sessionId: string;
@@ -24,7 +27,6 @@ export class ClientEntity extends TrackedEntity {
startTime: Date;
@Column({ type: 'real', default: 0 })
bestDifficulty: number
+10
View File
@@ -76,4 +76,14 @@ export class ClientService {
public async deleteAll() {
return await this.clientRepository.softDelete({})
}
public async getUserAgents() {
const result = await this.clientRepository.createQueryBuilder('client')
.select('client.userAgent as userAgent')
.addSelect('COUNT(client.userAgent)', 'count')
.groupBy('client.userAgent')
.orderBy('count', 'DESC')
.getRawMany();
return result;
}
}