mirror of https://github.com/apache/cloudstack.git
Merge pull request #1205 from shapeblue/master-9126
QUOTA: Ensuring that the dates displayed are as per user expectations When querying db we use start of next day to query quota usage for
today, but while displaying it to user we still need to show it as
todays date
* pr/1205:
QUOTA: Ensuring that the dates displayed are as per user expectations
Signed-off-by: Remi Bergsma <github@remi.nl>
This commit is contained in:
commit
7c83e1b240
|
|
@ -83,7 +83,12 @@ public class QuotaBalanceCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
public Date getEndDate() {
|
||||
return endDate == null ? null : _responseBuilder.startOfNextDay(endDate == null ? null : new Date(endDate.getTime()));
|
||||
if (endDate == null){
|
||||
return null;
|
||||
}
|
||||
else{
|
||||
return _responseBuilder.startOfNextDay(new Date(endDate.getTime()));
|
||||
}
|
||||
}
|
||||
|
||||
public void setEndDate(Date endDate) {
|
||||
|
|
@ -113,10 +118,10 @@ public class QuotaBalanceCmd extends BaseCmd {
|
|||
List<QuotaBalanceVO> quotaUsage = _responseBuilder.getQuotaBalance(this);
|
||||
|
||||
QuotaBalanceResponse response;
|
||||
if (getEndDate() == null) {
|
||||
if (endDate == null) {
|
||||
response = _responseBuilder.createQuotaLastBalanceResponse(quotaUsage, getStartDate());
|
||||
} else {
|
||||
response = _responseBuilder.createQuotaBalanceResponse(quotaUsage, getStartDate(), endDate == null ? null : new Date(endDate.getTime()));
|
||||
response = _responseBuilder.createQuotaBalanceResponse(quotaUsage, getStartDate(), new Date(endDate.getTime()));
|
||||
}
|
||||
response.setResponseName(getCommandName());
|
||||
setResponseObject(response);
|
||||
|
|
|
|||
|
|
@ -233,9 +233,9 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
|
|||
// order is desc last item is the start item
|
||||
QuotaBalanceVO startItem = quotaBalance.get(quotaBalance.size() - 1);
|
||||
QuotaBalanceVO endItem = quotaBalance.get(0);
|
||||
resp.setStartDate(startItem.getUpdatedOn());
|
||||
resp.setStartDate(startDate);
|
||||
resp.setStartQuota(startItem.getCreditBalance());
|
||||
resp.setEndDate(endItem.getUpdatedOn());
|
||||
resp.setEndDate(endDate);
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("createQuotaBalanceResponse: Start Entry=" + startItem);
|
||||
s_logger.debug("createQuotaBalanceResponse: End Entry=" + endItem);
|
||||
|
|
@ -489,7 +489,7 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
|
|||
lastCredits = lastCredits.add(entry.getCreditBalance());
|
||||
}
|
||||
resp.setStartQuota(lastCredits);
|
||||
resp.setStartDate(_quotaService.computeAdjustedTime(startDate));
|
||||
resp.setStartDate(startDate);
|
||||
resp.setCurrency(QuotaConfig.QuotaCurrencySymbol.value());
|
||||
resp.setObjectName("balance");
|
||||
return resp;
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi
|
|||
Date adjustedEndDate = computeAdjustedTime(endDate);
|
||||
Date adjustedStartDate = computeAdjustedTime(startDate);
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Getting quota records for account: " + accountId + ", domainId: " + domainId + ", between " + startDate + " and " + endDate);
|
||||
s_logger.debug("Getting quota records for account: " + accountId + ", domainId: " + domainId + ", between " + adjustedStartDate + " and " + adjustedEndDate);
|
||||
}
|
||||
return _quotaUsageDao.findQuotaUsage(accountId, domainId, usageType, adjustedStartDate, adjustedEndDate);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue