diff --git a/src/main/java/org/gcube/accounting/analytics/persistence/postgresql/Query.java b/src/main/java/org/gcube/accounting/analytics/persistence/postgresql/Query.java index 891f3dd..3ea4d94 100644 --- a/src/main/java/org/gcube/accounting/analytics/persistence/postgresql/Query.java +++ b/src/main/java/org/gcube/accounting/analytics/persistence/postgresql/Query.java @@ -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("); diff --git a/src/test/java/org/gcube/accounting/analytics/persistence/postgresql/AccountingPersistenceQueryPostgreSQLTest.java b/src/test/java/org/gcube/accounting/analytics/persistence/postgresql/AccountingPersistenceQueryPostgreSQLTest.java index 07792a6..c63476d 100644 --- a/src/test/java/org/gcube/accounting/analytics/persistence/postgresql/AccountingPersistenceQueryPostgreSQLTest.java +++ b/src/test/java/org/gcube/accounting/analytics/persistence/postgresql/AccountingPersistenceQueryPostgreSQLTest.java @@ -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();