This commit is contained in:
2022-02-25 17:00:24 +00:00
parent c7a14e2843
commit 4a1072d11d
3 changed files with 6 additions and 6 deletions

View File

@@ -8,7 +8,7 @@ namespace AyaNova.KPI
AuthorizationRoles AllowedRoles { get; }
//build the data and meta queries based on the criteria and this kpi's standard query
void BuildQuery(KPIRequestOptions options);
void BuildQuery(KPIRequestOptions options, long userId);
string MetaQuery{get;}//Query to fetch json meta data for report purposes mainly (lookup stuff like names etc where applicable)
string DataQuery{get;}//Query to fetch json format data for result set
string ErrorMessage{get;}//if there was a problem then this is set with the error message

View File

@@ -40,7 +40,7 @@ namespace AyaNova.KPI
});
}
kpi.BuildQuery(options);
kpi.BuildQuery(options, userId);
if (!string.IsNullOrWhiteSpace(kpi.ErrorMessage))
{

View File

@@ -15,7 +15,7 @@ namespace AyaNova.KPI
public string DataQuery => _dataQuery;
public string ErrorMessage => _errorMessage;
public void BuildQuery(KPIRequestOptions options)
public void BuildQuery(KPIRequestOptions options, long userId)
{
//build data and meta queries
@@ -38,12 +38,12 @@ namespace AyaNova.KPI
// jobData.ContainsKey("toTag") ? (string)jobData["toTag"] : null
_dataQuery = @"SELECT row_to_json(t) as res from (
select SUM(AWORKORDERITEMLABOR.serviceratequantity) SERVICERATESUM, date_trunc('month',AWORKORDERITEMLABOR.servicestartdate) timeframe
_dataQuery = @$"SELECT row_to_json(t) as res from (
select SUM(AWORKORDERITEMLABOR.serviceratequantity) SERVICERATESUM, date_trunc('{unit}',AWORKORDERITEMLABOR.servicestopdate) timeframe
FROM AWORKORDER
LEFT JOIN AWORKORDERITEM ON AWORKORDER.ID = AWORKORDERITEM.WORKORDERID
LEFT JOIN AWORKORDERITEMLABOR ON AWORKORDERITEM.ID = AWORKORDERITEMLABOR.WORKORDERITEMID
WHERE AWORKORDERITEMLABOR.userid = 10
WHERE AWORKORDERITEMLABOR.userid = {userId}
GROUP BY timeframe
ORDER BY timeframe ASC
) t";