collect more metrics, move everything related to metrics repo
This commit is contained in:
@@ -1,11 +1,40 @@
|
||||
import { MetricsDto } from '@app/domain/metrics';
|
||||
import { IMetricsRepository } from '@app/domain/repositories/metrics.repository';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import axios from 'axios';
|
||||
import os from 'os';
|
||||
import { Repository } from 'typeorm';
|
||||
import { AssetEntity, AssetType } from '../entities';
|
||||
|
||||
@Injectable()
|
||||
export class MetricsRepository implements IMetricsRepository {
|
||||
constructor(@InjectRepository(AssetEntity) private assetRepository: Repository<AssetEntity>) {}
|
||||
async sendMetrics(payload: MetricsDto): Promise<void> {
|
||||
await axios.post('IMMICH-DATA-DOMAIN', payload);
|
||||
}
|
||||
|
||||
getAssetCount() {
|
||||
return this.assetRepository.count();
|
||||
}
|
||||
|
||||
getCpuCount() {
|
||||
return os.cpus().length;
|
||||
}
|
||||
|
||||
getCpuModel() {
|
||||
return os.cpus()[0].model;
|
||||
}
|
||||
|
||||
getMemoryCount() {
|
||||
return os.totalmem();
|
||||
}
|
||||
|
||||
getImageCount() {
|
||||
return this.assetRepository.count({ where: { isVisible: true, type: AssetType.IMAGE } });
|
||||
}
|
||||
|
||||
getVideoCount() {
|
||||
return this.assetRepository.count({ where: { isVisible: true, type: AssetType.VIDEO } });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user