Merge pull request 'fix(filters): relative dates in an analysis filter no longer answer HTTP 500' (#44) from fix/relative-date-filters into develop
This commit was merged in pull request #44.
This commit is contained in:
3 files changed
+33
No files matched your search
@@ -10,6 +10,7 @@ Following [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and [Semantic
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed HTTP 500 ("Unsupported class ...NowWithOffset for converting to Instant") from every analysis whose filter holds a relative date (a filter expression such as "now minus one day" or "this month") on a date or date-time field: the pivot, profiles, comparisons and the stand-in backend converted filter values to the field's type before querying and did not expect an expression. Expressions are now left for core to evaluate when the query runs, so "printed in the last day" works from the Analyses screens, over the UI API (`POST /qbit/data-analysis/tables/{table}/pivot`) and in a saved or scheduled analysis, where it means the last day on every run. Drill-through filters carry the expression.
|
||||
- Reject saved analyses with a NULL or false shared flag and no read owner in the generated schema. Existing hosts must apply the documented constraint correction through a new migration.
|
||||
- Scheduled analyses and watches work under OAuth2. When the host declares the `data-analysis` service principal (QQQ service identities, `DataAnalysisQBitConfig.withServicePrincipal`), schedule and watch inventory runs as that principal, and owner and recipient runs go on their behalf through it: their current access intersected with the principal's. The self-made `data-analysis-scheduler` session was rejected under OAuth2 (`Invalid session in request` on every `data_analysis_run_schedules` run). With no principal declared, behavior is unchanged. Needs the QQQ release with service identities (qqq#1255, #1256).
|
||||
- QBit metadata now reports the Maven artifact version, including release versions, from a filtered build resource.
|
||||
|
||||
@@ -302,9 +302,19 @@ public final class DrillFilters
|
||||
|
||||
/*******************************************************************************
|
||||
** String decimal operands preserve exact scale and precision across JSON round trips.
|
||||
** Filter expressions (relative dates) are left for core to evaluate.
|
||||
*******************************************************************************/
|
||||
private static Serializable restoreValue(com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldType type, Serializable value)
|
||||
{
|
||||
if(value instanceof com.kingsrook.qqq.backend.core.model.actions.tables.query.expressions.AbstractFilterExpression<?>)
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// a relative date ("now minus one day", "this month") is not a value to //
|
||||
// convert: core evaluates it when the query runs, so a saved or //
|
||||
// scheduled analysis means "the last day" on every run //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
return (value);
|
||||
}
|
||||
if(type == com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldType.DECIMAL)
|
||||
{
|
||||
return (value == null ? null : value.toString());
|
||||
|
||||
@@ -118,6 +118,28 @@ abstract class PivotContractTest extends EngineFixture
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
** A relative date in the filter ("created in the last N days") is evaluated
|
||||
** by core when the pivot runs, also after the JSON round trip of an HTTP
|
||||
** request or a saved definition, and the drills carry it.
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void pivotWithRelativeDateFilter() throws Exception
|
||||
{
|
||||
PivotRequest everything = pivot(List.of("status"), List.of()).withFilter(new com.kingsrook.qqq.backend.core.model.actions.tables.query.QQueryFilter()
|
||||
.withCriteria("created", QCriteriaOperator.GREATER_THAN_OR_EQUALS, com.kingsrook.qqq.backend.core.model.actions.tables.query.expressions.NowWithOffset.minus(36500, java.time.temporal.ChronoUnit.DAYS)));
|
||||
for(PivotRequest request : List.of(everything, JsonUtils.toObject(JsonUtils.toJson(everything), PivotRequest.class)))
|
||||
{
|
||||
PivotResult result = service.pivot(request);
|
||||
equalNumber(result.getGrandTotals().getFirst(), "12");
|
||||
countDrills(result);
|
||||
}
|
||||
|
||||
PivotRequest lastDay = pivot(List.of("status"), List.of()).withFilter(new com.kingsrook.qqq.backend.core.model.actions.tables.query.QQueryFilter()
|
||||
.withCriteria("created", QCriteriaOperator.GREATER_THAN_OR_EQUALS, com.kingsrook.qqq.backend.core.model.actions.tables.query.expressions.NowWithOffset.minus(1, java.time.temporal.ChronoUnit.DAYS)));
|
||||
assertThat(service.pivot(JsonUtils.toObject(JsonUtils.toJson(lastDay), PivotRequest.class)).getCells()).isEmpty();
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
** Verify or support the pivot and field-access contract.
|
||||
*******************************************************************************/
|
||||
|
||||
Reference in new issue
Block a user