Fixing StorageUsageRecord request
This commit is contained in:
parent
67163d3b1e
commit
0c5f652b15
|
@ -14,6 +14,7 @@ import org.gcube.accounting.analytics.TemporalConstraint.CalendarEnum;
|
||||||
import org.gcube.accounting.datamodel.UsageRecord;
|
import org.gcube.accounting.datamodel.UsageRecord;
|
||||||
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
|
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
|
||||||
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageStatusRecord;
|
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.PostgreSQLQuery;
|
||||||
import org.gcube.accounting.utility.postgresql.RecordToDBFields;
|
import org.gcube.accounting.utility.postgresql.RecordToDBFields;
|
||||||
import org.gcube.accounting.utility.postgresql.RecordToDBMapping;
|
import org.gcube.accounting.utility.postgresql.RecordToDBMapping;
|
||||||
|
@ -185,6 +186,12 @@ public class Query extends PostgreSQLQuery {
|
||||||
stringBuffer.append(") AS ");
|
stringBuffer.append(") AS ");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case AggregatedStorageUsageRecord.DATA_VOLUME:
|
||||||
|
stringBuffer.append(", SUM(");
|
||||||
|
stringBuffer.append(dbField);
|
||||||
|
stringBuffer.append(") AS ");
|
||||||
|
break;
|
||||||
|
|
||||||
// WEIGHTED AVERAGE
|
// WEIGHTED AVERAGE
|
||||||
case AggregatedServiceUsageRecord.DURATION:
|
case AggregatedServiceUsageRecord.DURATION:
|
||||||
stringBuffer.append(", ROUND(SUM(");
|
stringBuffer.append(", ROUND(SUM(");
|
||||||
|
|
|
@ -21,6 +21,8 @@ import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQu
|
||||||
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery;
|
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery;
|
||||||
import org.gcube.accounting.datamodel.UsageRecord;
|
import org.gcube.accounting.datamodel.UsageRecord;
|
||||||
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
|
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.accounting.utility.postgresql.RecordToDBMapping;
|
||||||
import org.gcube.documentstore.records.Record;
|
import org.gcube.documentstore.records.Record;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -98,9 +100,18 @@ public class AccountingPersistenceQueryPostgreSQLTest extends ContextTest {
|
||||||
Info info = timeseries.get(c);
|
Info info = timeseries.get(c);
|
||||||
logger.debug("{}", info);
|
logger.debug("{}", info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
timeseries = accountingPersistenceQueryPostgreSQL.getTimeSeries(AggregatedStorageUsageRecord.class, temporalConstraint, filters);
|
||||||
|
for(Calendar c : timeseries.keySet()) {
|
||||||
|
Info info = timeseries.get(c);
|
||||||
|
logger.debug("{}", info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testContextTimeSeries() throws DuplicatedKeyFilterException, KeyException, ValueException, Exception {
|
public void testContextTimeSeries() throws DuplicatedKeyFilterException, KeyException, ValueException, Exception {
|
||||||
Calendar startTimeCalendar = Calendar.getInstance();
|
Calendar startTimeCalendar = Calendar.getInstance();
|
||||||
|
|
Loading…
Reference in New Issue