chore: add new logic for the quota
This commit is contained in:
@@ -85,4 +85,25 @@ export class BusinessesService {
|
||||
if (!staff) throw new BadRequestException(BusinessMessage.STAFF_NOT_FOUND);
|
||||
return staff;
|
||||
}
|
||||
|
||||
//************************************************** */
|
||||
async getBusinessQuota(businessId: string) {
|
||||
const business = await this.businessRepository.findOne({ id: businessId, deletedAt: null });
|
||||
if (!business) throw new BadRequestException(BusinessMessage.NOT_FOUND);
|
||||
|
||||
return {
|
||||
quota: {
|
||||
total: Number(business.quota),
|
||||
used: Number(business.usedQuota),
|
||||
remaining: Number(business.remainingQuota),
|
||||
totalInMB: Math.round(Number(business.quota) / (1024 * 1024)),
|
||||
totalInGB: Math.round(Number(business.quota) / (1024 * 1024 * 1024)),
|
||||
usedInMB: Math.round(Number(business.usedQuota) / (1024 * 1024)),
|
||||
usedInGB: Math.round(Number(business.usedQuota) / (1024 * 1024 * 1024)),
|
||||
remainingInMB: Math.round(Number(business.remainingQuota) / (1024 * 1024)),
|
||||
remainingInGB: Math.round(Number(business.remainingQuota) / (1024 * 1024 * 1024)),
|
||||
usagePercentage: Math.round((Number(business.usedQuota) / Number(business.quota)) * 100),
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user