From e97d39f0f53be29bcaa38015a56ae53ab249b807 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 10 Dec 2018 17:00:53 +0000 Subject: [PATCH] --- devdocs/todo.txt | 49 ++++++++++++++++++++++++++++++++- server/AyaNova/biz/PrimeData.cs | 2 +- server/AyaNova/biz/WidgetBiz.cs | 21 ++++++++------ test/raven-integration/util.cs | 4 +-- 4 files changed, 64 insertions(+), 12 deletions(-) diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 913ce9a8..19ddc13e 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -148,6 +148,53 @@ Here at this server locally they are starting out in pacific time and then conve Will need the debug log of the query built to see what the what next + + + +Working (localhost) next month filter log: +2018-12-10 08:39:49.3954|INFO|WidgetBiz::GetManyAsync|Filter criteria: +2018-12-10 08:39:49.3954|INFO|WidgetBiz::GetManyAsync|[ + { + "fld": "name", + "op": "%-", + "value": "DateTokenNextMonthFilterWorks" + }, + { + "fld": "startdate", + "op": "=", + "value": "{[nextmonth]}" + } +] +2018-12-10 08:39:49.3954|INFO|WidgetBiz::GetManyAsync|Generated SQL: +2018-12-10 08:39:49.4126|INFO|WidgetBiz::GetManyAsync|SELECT *, xmin FROM AWIDGET where name Like 'DateTokenNextMonthFilterWorks%' AND startdate >'2019-01-01T07:59:59.0000000Z' AND startdate <'2019-02-01T08:00:00.0000000Z' +2018-12-10 08:39:49.4248|WARN|Microsoft.EntityFrameworkCore.Query|Query: '(from Widget _4 in DbSet select [_4]).Skip(__p_1).Take(__p_2)' uses a row limiting operation (Skip/Take) without OrderBy which may lead to unpredictable results. + +SERVER DEVOPS VERSION: +2018-12-10 16:46:25.5657|INFO|WidgetBiz::GetManyAsync|Filter criteria: +2018-12-10 16:46:25.5657|INFO|WidgetBiz::GetManyAsync|[ + { + "fld": "name", + "op": "%-", + "value": "DateTokenNextMonthFilterWorks" + }, + { + "fld": "startdate", + "op": "=", + "value": "{[nextmonth]}" + } +] +2018-12-10 16:46:25.5657|INFO|WidgetBiz::GetManyAsync|Generated SQL: +2018-12-10 16:46:25.5657|INFO|WidgetBiz::GetManyAsync|SELECT *, xmin FROM AWIDGET where name Like 'DateTokenNextMonthFilterWorks%' AND startdate >'2018-12-31T23:59:59.0000000Z' AND startdate <'2019-02-01T00:00:00.0000000Z' +2018-12-10 16:46:25.5733|WARN|Microsoft.EntityFrameworkCore.Query|Query: '(from Widget _4 in DbSet select [_4]).Skip(__p_1).Take(__p_2)' uses a row limiting operation (Skip/Take) without OrderBy which may lead to unpredictable results. + +WHAT IS HAPPENING +what is happening is that the data is converted to UTC before sending to the server, the server is supposed to be a dumb date unaware repository +However if I want "next month" then that's relative to my personal location, I can't go by the server's next month because that is in UTC and I'm not. +So for the server to process *my* next month it needs to know what my relative time offset is. +I've decided to never trust the client for current time zone information and use an independent setting for the user account. +So the relative time query builders need to use the relative offset in the production of the NOW date that everything keys off of. + + ================= @@ -233,7 +280,7 @@ SERVER - Delete user should delete private datafilters - Did I code how to handle implications of user delete anywhere yet?? - + - LOG File names, when logs are rotated, I'm seeing the number 18 and 17 in the devops log file rotated names?! Shouldn't it just be 1 to 3 or something, will that number keep growing infinitely? - Stage 2 AFTER POSTED TEST ROUND COMPLETED diff --git a/server/AyaNova/biz/PrimeData.cs b/server/AyaNova/biz/PrimeData.cs index 37d63d23..9d5aafbd 100644 --- a/server/AyaNova/biz/PrimeData.cs +++ b/server/AyaNova/biz/PrimeData.cs @@ -27,7 +27,7 @@ namespace AyaNova.Biz public static void PrimeManagerAccount(AyContext ct) { //get a db and logger - ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("PrimeData"); + //ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("PrimeData"); User u = new User(); u.Active = true; u.Name = "AyaNova Administrator"; diff --git a/server/AyaNova/biz/WidgetBiz.cs b/server/AyaNova/biz/WidgetBiz.cs index 846a2633..7eec1228 100644 --- a/server/AyaNova/biz/WidgetBiz.cs +++ b/server/AyaNova/biz/WidgetBiz.cs @@ -10,6 +10,8 @@ using AyaNova.Biz; using AyaNova.Models; using System.Collections.Generic; +using Microsoft.Extensions.Logging; + namespace AyaNova.Biz { @@ -158,17 +160,12 @@ namespace AyaNova.Biz return ret; } + + + //get many (paged) internal async Task> GetManyAsync(IUrlHelper Url, string routeName, PagingOptions pagingOptions) { - - //TODO: build a query, run it outside of Entity Framework directly and return the results in models?! - //Or can ef accept a query with criteria - //https://docs.microsoft.com/en-us/ef/core/querying/raw-sql - //If no datafilter then it can just run this regular code which already works, I think? - //no, order by is brokeh - - pagingOptions.Offset = pagingOptions.Offset ?? PagingOptions.DefaultOffset; pagingOptions.Limit = pagingOptions.Limit ?? PagingOptions.DefaultLimit; @@ -190,6 +187,14 @@ namespace AyaNova.Biz //BUILD WHERE AND APPEND IT q = q + FilterSqlCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, WidgetBiz.FilterOptions()); + + //TESTING: + //LOG THE CRIT AND QUERY + ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("WidgetBiz::GetManyAsync"); + log.LogInformation("Filter criteria:"); + log.LogInformation(TheFilter.Filter); + log.LogInformation("Generated SQL:"); + log.LogInformation(q); } //BUILD ORDER BY AND APPEND IT diff --git a/test/raven-integration/util.cs b/test/raven-integration/util.cs index 64e73df1..637adb25 100644 --- a/test/raven-integration/util.cs +++ b/test/raven-integration/util.cs @@ -12,8 +12,8 @@ namespace raven_integration { private static HttpClient client { get; } = new HttpClient(); - private static string API_BASE_URL = "http://localhost:7575/api/v8.0/"; - // private static string API_BASE_URL = "https://test.helloayanova.com/api/v8.0/"; + // private static string API_BASE_URL = "http://localhost:7575/api/v8.0/"; + private static string API_BASE_URL = "https://test.helloayanova.com/api/v8.0/"; public static string TEST_DATA_FOLDER = @"..\..\..\testdata\";