diff --git a/server/AyaNova/biz/Search.cs b/server/AyaNova/biz/Search.cs index 74c04da5..dde805df 100644 --- a/server/AyaNova/biz/Search.cs +++ b/server/AyaNova/biz/Search.cs @@ -414,36 +414,44 @@ namespace AyaNova.Biz //BUILD A LIST OF MatchingDictionaryEntry items FOR THE MATCHING WORDS List MatchingKeywordIdList = new List(); - //ITERATE ALL THE KEYWORDS, SEARCH IN THE SEARCHDICTIONARY TABLE AND COLLECT ID'S OF ANY PRE-EXISTING IN DB KEYWORDS - var ExistingKeywordMatches = ct.SearchDictionary.Where(m => KeyWordList.Contains(m.Word)).ToDictionary(m => m.Id, m => m.Word); - //Put the matching keyword ID's into the list - foreach (KeyValuePair K in ExistingKeywordMatches) - { - bool IsName = false; - if (NameKeyWordList.Contains(K.Value)) - IsName = true; - MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = K.Key, InName = IsName }); - } - //ITERATE THROUGH THE KEYWORDS THAT DO *NOT* HAVE MATCHES IN THE SEARCHDICTIONARY AND ADD THEM TO THE SEARCH DICTIONARY, COLLECTING THEIR ID'S - bool NewWordsAdded = false; - var NewSearchDictionaryWordsList = new List(); - foreach (string KeyWord in KeyWordList) + //######### FROM HERE NEEDS TO LOCK SEARCHDICTIONARY FROM HERE TO ADDING NEW WORDS + using (var transaction = ct.Database.BeginTransaction()) { - if (!ExistingKeywordMatches.ContainsValue(KeyWord)) + //ITERATE ALL THE KEYWORDS, SEARCH IN THE SEARCHDICTIONARY TABLE AND COLLECT ID'S OF ANY PRE-EXISTING IN DB KEYWORDS + var ExistingKeywordMatches = ct.SearchDictionary.Where(m => KeyWordList.Contains(m.Word)).ToDictionary(m => m.Id, m => m.Word); + //Put the matching keyword ID's into the list + foreach (KeyValuePair K in ExistingKeywordMatches) { - NewSearchDictionaryWordsList.Add(new SearchDictionary() { Word = KeyWord }); - NewWordsAdded = true; + bool IsName = false; + if (NameKeyWordList.Contains(K.Value)) + IsName = true; + MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = K.Key, InName = IsName }); } - } - //Save the context in order to get the id's of the new words added - if (NewWordsAdded) - { - //adding in a range sped this up noticeably - ct.SearchDictionary.AddRange(NewSearchDictionaryWordsList); - ct.SaveChanges(); - } + //ITERATE THROUGH THE KEYWORDS THAT DO *NOT* HAVE MATCHES IN THE SEARCHDICTIONARY AND ADD THEM TO THE SEARCH DICTIONARY, COLLECTING THEIR ID'S + bool NewWordsAdded = false; + var NewSearchDictionaryWordsList = new List(); + foreach (string KeyWord in KeyWordList) + { + if (!ExistingKeywordMatches.ContainsValue(KeyWord)) + { + NewSearchDictionaryWordsList.Add(new SearchDictionary() { Word = KeyWord }); + NewWordsAdded = true; + } + } + + //Save the context in order to get the id's of the new words added + if (NewWordsAdded) + { + //adding in a range sped this up noticeably + ct.SearchDictionary.AddRange(NewSearchDictionaryWordsList); + ct.SaveChanges(); + } + + transaction.Commit(); + }//end transaction + //######################### //----- diff --git a/test/raven-integration/util.cs b/test/raven-integration/util.cs index 859551c3..0dbc0a55 100644 --- a/test/raven-integration/util.cs +++ b/test/raven-integration/util.cs @@ -236,7 +236,20 @@ namespace raven_integration var ErrorMessage = string.Empty; var ERR = a.ObjectResponse["error"]; if (ERR != null) - ErrorMessage = ERR.Value(); + { + var ecode = ERR["code"]; + if (ecode != null) + ErrorMessage += $"CODE: {ecode} "; + + var emsg = ERR["message"]; + if (emsg != null) + ErrorMessage += $"MESSAGE: {emsg} "; + + var etarget = ERR["target"]; + if (etarget != null) + ErrorMessage += $"TARGET: {etarget} "; + } + a.ObjectResponse["error"].Should().BeNull("because there should not be an error on an api call, error was: {0}", ErrorMessage); a.ObjectResponse["result"].Should().NotBeNull("A result should be returned"); }