GutoVeronezi commented on code in PR #6690:
URL: https://github.com/apache/cloudstack/pull/6690#discussion_r967058249


##########
framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java:
##########
@@ -133,9 +134,21 @@ public boolean stop() {
         return true;
     }
 
+    public boolean isQuotaEnabledForAccountDomain(final AccountVO account) {
+        boolean isQuotaAccountEnabled = 
QuotaConfig.QuotaAccountEnabled.valueIn(account.getAccountId());
+        if (!isQuotaAccountEnabled) {
+            s_logger.debug(String.format("Considering usage records as 
calculated and skipping it because the account [%s] has the quota plugin 
disabled.", account));
+        }
+        return isQuotaAccountEnabled;
+    }
+
+    public boolean isUsageRecordsEmpty(final Pair<List<? extends UsageVO>, 
Integer> usageRecords) {
+        return usageRecords == null || usageRecords.first() == null || 
usageRecords.first().isEmpty();

Review Comment:
   We can use `org.apache.commons.collections.CollectionUtils#isEmpty` here.
   ```suggestion
           return usageRecords == null || 
CollectionUtils.isEmpty(usageRecords.first());
   ```



##########
framework/quota/src/main/java/org/apache/cloudstack/quota/dao/QuotaAccountDaoImpl.java:
##########
@@ -36,7 +38,15 @@ public class QuotaAccountDaoImpl extends 
GenericDaoBase<QuotaAccountVO, Long> im
 
     @Override
     public List<QuotaAccountVO> listAllQuotaAccount() {
-        return listAllQuotaAccount(null, null).first();
+        List<QuotaAccountVO> accountsWithQuotaEnabled = new ArrayList<>();
+        for (QuotaAccountVO account : listAllQuotaAccount(null, null).first()) 
{
+            if 
(Boolean.TRUE.equals(getQuotaAccountEnabled(account.getAccountId()))) {

Review Comment:
   We can use `org.apache.commons.lang3.BooleanUtils#isTrue()` here: 
   
   ```suggestion
               if 
(BooleanUtils.isTrue(getQuotaAccountEnabled(account.getAccountId()))) {
   ```



##########
ui/src/config/section/plugin/quota.js:
##########
@@ -28,7 +28,10 @@ export default {
       title: 'label.quota.summary',
       icon: 'bars-outlined',
       permission: ['quotaSummary'],
-      columns: ['account', 'domain', 'state', 'currency', 'balance', 'quota'],
+      columns: [
+        {
+          account: (record) => record.quotaenabled ? record.account : 
record.account + ' (quota-disabled)'

Review Comment:
   @BryanMLima, would not be better to add it as a column?



-- 
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]

Reply via email to