This commit is contained in:
@@ -47,13 +47,21 @@ AuthorizationRoles.Accounting;
|
||||
bool wotagsany = options.Criteria["wotagsany"].ToObject<bool>();
|
||||
string woTagsWhere = DataListSqlFilterCriteriaBuilder.KPITagFilterToSqlCriteria("aworkorder.tags", wotags, wotagsany);
|
||||
|
||||
|
||||
|
||||
|
||||
_dataQuery = @$"SELECT row_to_json(t) as res from (
|
||||
with subq as (
|
||||
SELECT COUNT(AWORKORDER.ID) wocount,
|
||||
DATE_TRUNC('{interval}',AWORKORDER.createddate) x,
|
||||
(LASTSTATUSID IS NULL OR AWORKORDERSTATUS.COMPLETED = FALSE) z
|
||||
(aworkorder.laststatusid is not null AND AWORKORDERSTATUS.COMPLETED = TRUE AND laststate.created < aworkorder.completebydate) Z
|
||||
FROM AWORKORDER
|
||||
LEFT JOIN AWORKORDERSTATUS ON (AWORKORDER.LASTSTATUSID = AWORKORDERSTATUS.ID)
|
||||
LEFT JOIN LATERAL (SELECT created
|
||||
FROM aworkorderstate
|
||||
WHERE aworkorderstate.workorderid = aworkorder.id
|
||||
ORDER BY aworkorderstate.created DESC
|
||||
LIMIT 1) AS laststate ON TRUE
|
||||
where AWORKORDER.COMPLETEBYDATE < NOW() AND {dateWhere} {woTagsWhere}
|
||||
GROUP BY x,z
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user