abh1sar commented on code in PR #10017:
URL: https://github.com/apache/cloudstack/pull/10017#discussion_r1872935058
##########
engine/schema/src/main/java/com/cloud/storage/dao/BucketDaoImpl.java:
##########
@@ -79,4 +98,21 @@ public List<BucketVO> searchByIds(Long[] ids) {
sc.setParameters("idIN", ids);
return search(sc, null, null, false);
}
+
+ @Override
+ public Long countBucketsForAccount(long accountId) {
+ SearchCriteria<Long> sc = CountBucketsByAccount.create();
+ sc.setParameters(ACCOUNT_ID, accountId);
+ sc.setParameters(STATE, BucketVO.State.Destroyed);
+ return customSearch(sc, null).get(0);
+ }
+
+ @Override
+ public Long calculateObjectStorageAllocationForAccount(long accountId) {
+ SearchCriteria<SumCount> sc = CalculateBucketsQuotaByAccount.create();
+ sc.setParameters(ACCOUNT_ID, accountId);
+ sc.setParameters(STATE, BucketVO.State.Destroyed);
+ Long totalQuota = customSearch(sc, null).get(0).sum;
Review Comment:
Similar to above this sums up the quota column for all buckets for that
account.
If there are no buckets, it is retuning one element with value 0.
##########
engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupDaoImpl.java:
##########
@@ -142,6 +168,31 @@ public List<Backup> syncBackups(Long zoneId, Long vmId,
List<Backup> externalBac
return listByVmId(zoneId, vmId);
}
+ @Override
+ public Long countBackupsForAccount(long accountId) {
+ SearchCriteria<Long> sc = CountBackupsByAccount.create();
+ sc.setParameters("account", accountId);
+ sc.setParameters("status", Backup.Status.Error, Backup.Status.Failed,
Backup.Status.Removed, Backup.Status.Expunged);
+ return customSearch(sc, null).get(0);
+ }
+
+ @Override
+ public Long calculateBackupStorageForAccount(long accountId) {
+ SearchCriteria<SumCount> sc = CalculateBackupStorageByAccount.create();
+ sc.setParameters("account", accountId);
+ sc.setParameters("status", Backup.Status.Error, Backup.Status.Failed,
Backup.Status.Removed, Backup.Status.Expunged);
+ return customSearch(sc, null).get(0).sum;
Review Comment:
Same as above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]