This commit is contained in:
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
@@ -40,8 +40,8 @@
|
||||
"env": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"AYANOVA_JWT_SECRET": "UNLICENSED5G*QQJ8#bQ7$Xr_@sXfHq4",
|
||||
"AYANOVA_LOG_LEVEL": "Info",
|
||||
//"AYANOVA_LOG_LEVEL": "Debug",
|
||||
//"AYANOVA_LOG_LEVEL": "Info",
|
||||
"AYANOVA_LOG_LEVEL": "Debug",
|
||||
"AYANOVA_DEFAULT_LANGUAGE": "en",
|
||||
//LOCALE MUST BE en for Integration TESTING
|
||||
//"AYANOVA_PERMANENTLY_ERASE_DATABASE": "true",
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace AyaNova
|
||||
bool LOG_SENSITIVE_DATA = false;
|
||||
|
||||
#if (DEBUG)
|
||||
LOG_SENSITIVE_DATA = false;//############################################################################
|
||||
LOG_SENSITIVE_DATA = true;//############################################################################
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -456,6 +456,10 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Process the keywords into the dictionary
|
||||
/// NOTE: NAME parameter is in ADDITION to the NAME also being one of the strings passed in text parameter
|
||||
@@ -496,6 +500,14 @@ namespace AyaNova.Biz
|
||||
|
||||
//ITERATE ALL THE KEYWORDS, SEARCH IN THE SEARCHDICTIONARY TABLE AND COLLECT ID'S OF ANY PRE-EXISTING IN DB KEYWORDS
|
||||
var ExistingKeywordMatches = ServiceProviderProvider.DBContext.SearchDictionary.AsNoTracking().Where(m => KeyWordList.Contains(m.Word)).ToDictionary(m => m.Id, m => m.Word);
|
||||
/*example of above query, returns a list of words and ids
|
||||
SELECT a.id, a.xmin, a.word
|
||||
FROM asearchdictionary AS a
|
||||
WHERE a.word IN ('eos', 'quia', 'voluptate', 'delectus', 'sapiente', 'omnis', 'suscipit', 'rerum', 'unbranded', 'soft', 'towels', '25', 'green', 'zone', 'red', 'sequi', 'aspernatur', 'animi', '85586490', '70907391547648')
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
//Put the matching keyword ID's into the list
|
||||
foreach (KeyValuePair<long, string> K in ExistingKeywordMatches)
|
||||
@@ -513,6 +525,7 @@ namespace AyaNova.Biz
|
||||
var log = AyaNova.Util.ApplicationLogging.CreateLogger("### Search::ProcessKeywords ###");
|
||||
#endif
|
||||
|
||||
//TODO: this foreach block needs to add all the words at once in a single range query rather than one word at a time
|
||||
foreach (string KeyWord in KeyWordList)
|
||||
{
|
||||
if (!ExistingKeywordMatches.ContainsValue(KeyWord))
|
||||
@@ -525,11 +538,41 @@ namespace AyaNova.Biz
|
||||
|
||||
try
|
||||
{
|
||||
//ORIGINAL
|
||||
// //ADD WORD TO DICTIONARY, SAVE THE ID INTO THE MATCHINGKEYWORDIDLIST
|
||||
// var CtAdd = ServiceProviderProvider.DBContext;
|
||||
// CtAdd.SearchDictionary.Add(NewWord);
|
||||
// CtAdd.SaveChanges();
|
||||
|
||||
|
||||
|
||||
//ADD WORD TO DICTIONARY, SAVE THE ID INTO THE MATCHINGKEYWORDIDLIST
|
||||
var CtAdd = ServiceProviderProvider.DBContext;
|
||||
CtAdd.SearchDictionary.Add(NewWord);
|
||||
CtAdd.SaveChanges();
|
||||
|
||||
/*
|
||||
LOG of above operation:
|
||||
2020-01-24 10:08:40.5768|DEBUG|Microsoft.EntityFrameworkCore.Database.Command|Executing DbCommand [Parameters=[@p0='quia' (Nullable = false)], CommandType='Text', CommandTimeout='30']
|
||||
INSERT INTO asearchdictionary (word)
|
||||
VALUES (@p0)
|
||||
RETURNING id, xmin;
|
||||
2020-01-24 10:08:40.5768|INFO|Microsoft.EntityFrameworkCore.Database.Command|Executed DbCommand (2ms) [Parameters=[@p0='quia' (Nullable = false)], CommandType='Text', CommandTimeout='30']
|
||||
INSERT INTO asearchdictionary (word)
|
||||
VALUES (@p0)
|
||||
RETURNING id, xmin;
|
||||
2020-01-24 10:08:40.5768|DEBUG|Microsoft.EntityFrameworkCore.ChangeTracking|Foreign key property 'SearchDictionary.Id' detected as changed from '-9223372036854774587' to '221' for entity with key '{Id: 221}'.
|
||||
2020-01-24 10:08:40.5768|DEBUG|Microsoft.EntityFrameworkCore.Database.Command|A data reader was disposed.
|
||||
2020-01-24 10:08:40.5768|DEBUG|Microsoft.EntityFrameworkCore.Database.Transaction|Committing transaction.
|
||||
2020-01-24 10:08:40.5768|DEBUG|Microsoft.EntityFrameworkCore.Database.Transaction|Committing transaction.
|
||||
2020-01-24 10:08:40.5768|DEBUG|Microsoft.EntityFrameworkCore.Database.Connection|Closing connection to database 'AyaNova' on server 'tcp://localhost:5432'.
|
||||
2020-01-24 10:08:40.5768|DEBUG|Microsoft.EntityFrameworkCore.Database.Connection|Closed connection to database 'AyaNova' on server 'tcp://localhost:5432'.
|
||||
2020-01-24 10:08:40.5768|DEBUG|Microsoft.EntityFrameworkCore.Database.Transaction|Disposing transaction.
|
||||
2020-01-24 10:08:40.5768|DEBUG|Microsoft.EntityFrameworkCore.ChangeTracking|The 'SearchDictionary' entity with key '{Id: 221}' tracked by 'AyContext' changed from 'Added' to 'Unchanged'.
|
||||
2020-01-24 10:08:40.5768|DEBUG|Microsoft.EntityFrameworkCore.Update|SaveChanges completed for 'AyContext' with 1 entities written to the database.
|
||||
|
||||
*/
|
||||
|
||||
//-------
|
||||
//Add to matching keywords
|
||||
MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = NewWord.Id, InName = NameKeyWordList.Contains(KeyWord) });
|
||||
@@ -543,6 +586,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
catch (Microsoft.EntityFrameworkCore.DbUpdateException ex)
|
||||
{
|
||||
#region Exceptions from word already existing (added maybe in another thread)
|
||||
#if (DEBUG)
|
||||
log.LogInformation($"###################### Exception caught attempting to add word: '{KeyWord}' fetching instead...");
|
||||
#endif
|
||||
@@ -569,6 +613,7 @@ namespace AyaNova.Biz
|
||||
log.LogInformation($"###################### NULL when expected to find word: '{KeyWord}'!?");
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user