This commit is contained in:
@@ -9,6 +9,60 @@
|
||||
|
||||
## TODO TO BETA
|
||||
|
||||
|
||||
figure out a way to group by tags and also filter to only include tags that contain a string of text
|
||||
i.e. either run a report that groups by each tag found in *every* record
|
||||
or, optionally, include a parameter which is a string of text to look for in the tag array and only include in a group if it's got that text somewhere in the tag
|
||||
async function ayPrepareData(ayData) {
|
||||
|
||||
|
||||
//Group by all tags no filter
|
||||
ayData.ayReportData = ayGroupByTag(ayData.ayReportData);
|
||||
|
||||
//Group by filtered tags that contain 'zone'
|
||||
//ayData.ayReportData = ayGroupByTag(ayData.ayReportData, 'zone');
|
||||
|
||||
return ayData;
|
||||
}
|
||||
|
||||
function ayGroupByTag(reportDataArray, tagContains) {
|
||||
//array to hold grouped data
|
||||
const ret = [];
|
||||
const containsQuery = tagContains != null && tagContains != '';
|
||||
|
||||
//iterate through the raw reprot data
|
||||
for (let i = 0; i < reportDataArray.length; i++) {
|
||||
//get a reference to each object to save typing
|
||||
let o = reportDataArray[i];
|
||||
//don't bother with any that don't have tags at all
|
||||
if (o.Tags && o.Tags.length) {
|
||||
//loop through all tags for this record
|
||||
o.Tags.forEach(t => {//t=each tag
|
||||
//if not a contains query just process it, if it is a contains query then only process if tag contains tagContains
|
||||
if (!containsQuery || t.includes(tagContains)) {
|
||||
let groupObject = ret.find(z => z.group == t);
|
||||
if (groupObject != undefined) {
|
||||
//there is already a matching group in the return array so just push this raw report data record into it
|
||||
groupObject.items.push(o);
|
||||
//update the count for this group's items
|
||||
groupObject.count++;
|
||||
} else {
|
||||
//No group yet, so start a new one in the ret array and push this raw report data record
|
||||
ret.push({ group: t, items: [o], count: 1 });
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
//Sort based on the group name in a locale aware manner
|
||||
ret.sort(function (a, b) {
|
||||
return a.group.localeCompare(b.group);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Update front / back / dotnet 6 is out
|
||||
https://dotnet.microsoft.com/download/dotnet/6.0
|
||||
https://docs.microsoft.com/en-us/dotnet/core/compatibility/6.0
|
||||
|
||||
Reference in New Issue
Block a user