From cb878bbf67bceb013813c2a0664159c408c69afd Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 2 Sep 2021 19:38:51 +0000 Subject: [PATCH] --- .../DataListSqlFilterCriteriaBuilder.cs | 39 +++---------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/server/AyaNova/DataList/DataListSqlFilterCriteriaBuilder.cs b/server/AyaNova/DataList/DataListSqlFilterCriteriaBuilder.cs index 8195b51f..33ad1f81 100644 --- a/server/AyaNova/DataList/DataListSqlFilterCriteriaBuilder.cs +++ b/server/AyaNova/DataList/DataListSqlFilterCriteriaBuilder.cs @@ -68,7 +68,7 @@ namespace AyaNova.DataList if (DataTypeToFilter != UiFieldDataType.Tags) sb.Append(DataFilterToColumnCriteria(columnNameToFilter, DataTypeToFilter, filterItem.op, filterItem.value, listOptions.ClientTimeStamp)); else - sb.Append(TagDataFilterToColumnCriteria(columnNameToFilter, filterItem.op, filterItem.value, listOptions.ClientTimeStamp)); + sb.Append(TagDataFilterToColumnCriteria(columnNameToFilter, filterItem.op, filterItem.value)); ThisIsTheFirstFilterItemForThisColumn = false; } if (ThereAreMultipleFilterItems) @@ -875,52 +875,25 @@ namespace AyaNova.DataList } - /////////////////////////////////////// + //////////////////////////////////////////////////////////////////////// // /// /// Translate TAG DataFilter to Postgres friendly SQL criteria /// - private static string TagDataFilterToColumnCriteria(string SqlColumnNameToFilter, string sOperator, string sValue, DateTimeOffset clientTimeStamp) + private static string TagDataFilterToColumnCriteria(string SqlColumnNameToFilter, string sOperator, string sValue) { - StringBuilder sb = new StringBuilder(); - //Column name - // sb.Append(SqlColumnNameToFilter); - // sb.Append(" "); - - - - //Build tags filter fragment - //https://www.postgresql.org/docs/current/functions-array.html - //https://www.postgresql.org/docs/9.1/functions-array.html /* - For these reasons, am requesting the ability to filter on the Tag column to include: - -**(no value) - to filter to show records that have no tags - -**(has value) - to filter to show records that have any tags - -**Not equal to - to filter to show records that do NOT have a specific tag - -**Contains - to filter to show records that have tags with this text as part of the tag (i.e. be able to type in the text workordercategory so would return ALL workorder records that have one or more tags that have the text workordercategory in it - such as "inspection.workordercategory" or "service.workordercategory" or any one of the unit service types that now are a tag) -**NotContains MY ADDITION see below - - //NOTE: all tags are lowercase so case is not an issue really with any of these queries - - array operators for queries and examples: - where 'red'=ANY(tags) //case sensitive, matches any single item in array, must be in that order or it will bomb if ANY is first - - //contains operator is the one I've been using: sbTags.Append("@> array["); - + https://www.postgresql.org/docs/current/functions-array.html Filter ui builder allows multiple tag selection just like any other tag selection and sends the filter to the server like this: filter "[{\"column\":\"customertags\",\"any\":false,\"items\":[{\"op\":\"=\",\"value\":\"completed.reminder,burnaby.dispatchzone,cabling-fibre.user-skill\"}]}]" Comma separated list. Current equalto filter doesn't work with this type of query as it directly compares it as if it was one string instead of does it contain all those terms - ### HOW IT SHOULD WORK ### + ### FILTERS AVAILABLE ### Equality: Exactly equal (aside from order) compare entire search term array to tag array in db - all terms in search exactly present and no others in db record contains and also length is same as search terms length, in this example 1 is the number of search terms as the search is for {'green'} @@ -994,7 +967,7 @@ namespace AyaNova.DataList } } - //////////////////////////////////// + //This is only used by the token date query code above and that code does NOT convert to UTC time to match the DB so this function will handle that