diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 9d8bd649..dbfed66b 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -27,12 +27,12 @@ Once that is done then can steam ahead on the biz objects but until I have the c IMMEDIATE ITEMS: ================ - - - Testing issue with event log tests, see the test for details + - Search and search text indexing - Create a test for search that searches the widgets LOREM text - Test with huge dataset for performance testing + - Need to be able to specify max results, code that shit! - bugbug: why is the single letter a being indexed? Missing shortness filter, A not in stopwords for english?? - Update all the other routes to include search indexing (attachments, tags etc, anything with text in it) @@ -56,7 +56,9 @@ IMMEDIATE ITEMS: - Give widgets a visible ID number scheme and add to tests - Ensure search code process keywords includes the Visible ID value andadd test for that in Search indexing tests - + - Why are exceptions that are triggered intentionally in intengration tests showing in the console? + - Shouldn't that shit log only to text file?? + - Does it matter even though? Ensure all modern best practice security is properly enabled on helloayanova.com so testing is valid - https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security#Deployment_best_practices diff --git a/server/AyaNova/biz/Search.cs b/server/AyaNova/biz/Search.cs index 495d51bb..eb57cc25 100644 --- a/server/AyaNova/biz/Search.cs +++ b/server/AyaNova/biz/Search.cs @@ -72,12 +72,14 @@ namespace AyaNova.Biz public bool NameOnly { get; set; } public AyaType TypeOnly { get; set; } public List Tags { get; set; } + public int MaxResults { get; set; } public SearchRequestParameters() { NameOnly = false; TypeOnly = AyaType.NoType; Tags = new List(); + MaxResults = 500; } public bool IsValid @@ -313,6 +315,11 @@ namespace AyaNova.Biz MatchingObjects = CanReadMatchingObjects; } + //MAXIMUM RESULTS FILTER + //The theory is that it should be filtered BEFORE sorting so that you get the most random collection of results + //As the results are not ranked so... + MatchingObjects=MatchingObjects.Take(searchParameters.MaxResults).ToList(); + //Sort and group the matching objects list in return order //Customer.OrderBy(c => c.LastName).ThenBy(c => c.FirstName) var OrderedMatchingObjects = MatchingObjects.OrderBy(x => x.ObjectType).ThenByDescending(x => x.ObjectId); @@ -445,7 +452,7 @@ namespace AyaNova.Biz } ct.SearchKey.AddRange(NewSearchKeyList); ct.SaveChanges(); - + //--------------------------------- diff --git a/test/raven-integration/EventLog/EventLog.cs b/test/raven-integration/EventLog/EventLog.cs index 6786820c..75c501c9 100644 --- a/test/raven-integration/EventLog/EventLog.cs +++ b/test/raven-integration/EventLog/EventLog.cs @@ -38,11 +38,12 @@ namespace raven_integration ApiResponse EventLogResponse = await Util.GetAsync($"EventLog/ObjectLog?AyType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull")); Util.ValidateHTTPStatusCode(EventLogResponse, 200); - TODO: failing here, for no reason that makes any sense it thinks there are two created events by two users for the same widget. + //NOTE:was failing here, for no reason that makes any sense it thinks there are two created events by two users for the same widget. + //might have been some temporary bad code in the seeder at one point when I was experimenting with async stuff - ((JArray)EventLogResponse.ObjectResponse["result"]).Count.Should().Be(1);//only one event so far - EventLogResponse.ObjectResponse["result"][0]["date"].Value().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now + ((JArray)EventLogResponse.ObjectResponse["result"]).Count.Should().Be(1);//only one event so far + EventLogResponse.ObjectResponse["result"][0]["date"].Value().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now EventLogResponse.ObjectResponse["result"][0]["userId"].Should().NotBeNull(); EventLogResponse.ObjectResponse["result"][0]["event"].Value().Should().Be(1);//AyEvent 1 = created EventLogResponse.ObjectResponse["result"][0]["textra"].Should().BeNullOrEmpty(); diff --git a/test/raven-integration/Search/SearchOps.cs b/test/raven-integration/Search/SearchOps.cs index dd561b9c..cc07a993 100644 --- a/test/raven-integration/Search/SearchOps.cs +++ b/test/raven-integration/Search/SearchOps.cs @@ -449,6 +449,43 @@ namespace raven_integration }//eot + + [Fact] + public async void BigDataSearchShouldBeRelativelyFast() + { + + //THIS test is a bit different in that it relies partly on the big dataset for testing + //so it has different paths depending upon if it's testing against the big data or not + const string TEST_SEARCH_PHRASE = "et*"; + + //Now see if can find those objects with a phrase search + dynamic SearchParameters = new JObject(); + + SearchParameters.phrase = TEST_SEARCH_PHRASE; + SearchParameters.nameOnly = false; + SearchParameters.typeOnly = 0;//no type + SearchParameters.maxResults = 1000;//default is 500 + + var watch = new System.Diagnostics.Stopwatch(); + watch.Start(); + ApiResponse a = await Util.PostAsync("Search", await Util.GetTokenAsync("manager", "l3tm3in"), SearchParameters.ToString()); + watch.Stop(); + + var TimeToSearch = watch.ElapsedMilliseconds; + + Util.ValidateDataReturnResponseOk(a); + + //Now validate the return list + var ResultCount = ((JArray)a.ObjectResponse["result"]).Count; + //assert it's not unbounded + ResultCount.Should().BeLessOrEqualTo(1000); + + //1755ms is the longest I've seen in initial testing so setting slightly above + TimeToSearch.Should().BeLessThan(1760, "Big data search should not be too slow"); + + }//eot + + //================================================== }//eoc