Fixing StorageUsageRecord request

This commit is contained in:
Luca Frosini 2021-03-29 11:45:48 +02:00
parent 67163d3b1e
commit 0c5f652b15
2 changed files with 18 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import org.gcube.accounting.analytics.TemporalConstraint.CalendarEnum;
import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageStatusRecord;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
import org.gcube.accounting.utility.postgresql.PostgreSQLQuery;
import org.gcube.accounting.utility.postgresql.RecordToDBFields;
import org.gcube.accounting.utility.postgresql.RecordToDBMapping;
@ -185,6 +186,12 @@ public class Query extends PostgreSQLQuery {
stringBuffer.append(") AS ");
break;
case AggregatedStorageUsageRecord.DATA_VOLUME:
stringBuffer.append(", SUM(");
stringBuffer.append(dbField);
stringBuffer.append(") AS ");
break;
// WEIGHTED AVERAGE
case AggregatedServiceUsageRecord.DURATION:
stringBuffer.append(", ROUND(SUM(");

View File

@ -21,6 +21,8 @@ import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQu
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery;
import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageStatusRecord;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
import org.gcube.accounting.utility.postgresql.RecordToDBMapping;
import org.gcube.documentstore.records.Record;
import org.junit.Before;
@ -98,9 +100,18 @@ public class AccountingPersistenceQueryPostgreSQLTest extends ContextTest {
Info info = timeseries.get(c);
logger.debug("{}", info);
}
timeseries = accountingPersistenceQueryPostgreSQL.getTimeSeries(AggregatedStorageUsageRecord.class, temporalConstraint, filters);
for(Calendar c : timeseries.keySet()) {
Info info = timeseries.get(c);
logger.debug("{}", info);
}
}
@Test
public void testContextTimeSeries() throws DuplicatedKeyFilterException, KeyException, ValueException, Exception {
Calendar startTimeCalendar = Calendar.getInstance();