diff --git a/IAGrim/Database/DAO/PlayerItemDaoImpl.cs b/IAGrim/Database/DAO/PlayerItemDaoImpl.cs index 5e0f8563..10b1c942 100644 --- a/IAGrim/Database/DAO/PlayerItemDaoImpl.cs +++ b/IAGrim/Database/DAO/PlayerItemDaoImpl.cs @@ -636,9 +636,9 @@ public List SearchForItems(ItemSearchRequest query) { if (!string.IsNullOrEmpty(query.Wildcard)) { // queryFragments.Add("(PI.namelowercase LIKE :name OR R.text LIKE :wildcard)"); - queryFragments.Add("(PI.namelowercase LIKE :name OR R.id IN (SELECT replicaitemid FROM replicaitemrow WHERE text LIKE :wildcard))"); - queryParams.Add("wildcard", $"%{query.Wildcard.ToLower()}%"); - queryParams.Add("name", $"%{query.Wildcard.Replace(' ', '%').ToLower()}%"); + queryFragments.Add("(PI.namelowercase LIKE :name OR R.id IN (SELECT replicaitemid FROM replicaitemrow WHERE IFNULL(textlowercase, text) LIKE :wildcard))"); + queryParams.Add("wildcard", $"%{query.Wildcard.ToLowerInvariant()}%"); + queryParams.Add("name", $"%{query.Wildcard.Replace(' ', '%').ToLowerInvariant()}%"); } // Filter by mod/hc diff --git a/IAGrim/Database/Model/ReplicaItemRow.cs b/IAGrim/Database/Model/ReplicaItemRow.cs index ebf0236e..085f43f1 100644 --- a/IAGrim/Database/Model/ReplicaItemRow.cs +++ b/IAGrim/Database/Model/ReplicaItemRow.cs @@ -10,5 +10,6 @@ public class ReplicaItemRow { public virtual long ReplicaItemId { get; set; } public virtual long Type { get; set; } = 0; public virtual string Text { get; set; } = ""; + public virtual string TextLowercase { get; set; } = ""; } } diff --git a/IAGrim/Database/Model/ReplicaItemRow.hbm.xml b/IAGrim/Database/Model/ReplicaItemRow.hbm.xml index c7c39a32..6a73d72d 100644 --- a/IAGrim/Database/Model/ReplicaItemRow.hbm.xml +++ b/IAGrim/Database/Model/ReplicaItemRow.hbm.xml @@ -12,5 +12,6 @@ + \ No newline at end of file diff --git a/IAGrim/Services/ItemReplica/ItemReplicaParser.cs b/IAGrim/Services/ItemReplica/ItemReplicaParser.cs index a320f421..2937557f 100644 --- a/IAGrim/Services/ItemReplica/ItemReplicaParser.cs +++ b/IAGrim/Services/ItemReplica/ItemReplicaParser.cs @@ -123,6 +123,7 @@ private void Process(string filename) { var stats = template.stats .Select(m => new ReplicaItemRow { Text = Regex.Replace(m.text.Trim(), @"(\^.?)", ""), + TextLowercase = Regex.Replace(m.text.Trim(), @"(\^.?)", "").ToLowerInvariant(), Type = Int32.Parse(m.type), }).ToList(); diff --git a/IAGrim/Services/ItemReplica/ReplicaCache.cs b/IAGrim/Services/ItemReplica/ReplicaCache.cs index 9c9387ea..8dbcc56d 100644 --- a/IAGrim/Services/ItemReplica/ReplicaCache.cs +++ b/IAGrim/Services/ItemReplica/ReplicaCache.cs @@ -16,7 +16,7 @@ public void Add(string hash) { _cache.Add(hash, 0); // TODO: In the future, delete the oldest or something - if (_cache.Keys.Count > 10000) + if (_cache.Keys.Count > 500000) _cache.Clear(); } diff --git a/IAGrim/Services/ItemReplicaService.cs b/IAGrim/Services/ItemReplicaService.cs index a8a6f3c7..d5d8d568 100644 --- a/IAGrim/Services/ItemReplicaService.cs +++ b/IAGrim/Services/ItemReplicaService.cs @@ -79,8 +79,7 @@ private bool Process() { count += items.Count; foreach (var item in items) { var hash = item.Id + ".csv"; - if (_cache.Exists( - hash)) // Don't ask for the same item twice. Esp if the user somehow gets two identical items in, this would infinitely loop. + if (_cache.Exists(hash)) // Don't ask for the same item twice. Esp if the user somehow gets two identical items in, this would infinitely loop. continue; diff --git a/IAGrim/Services/ItemStatService.cs b/IAGrim/Services/ItemStatService.cs index e7b3f276..ad164b8d 100644 --- a/IAGrim/Services/ItemStatService.cs +++ b/IAGrim/Services/ItemStatService.cs @@ -82,37 +82,6 @@ private List GetBuddyItems(List items) { return items.Where(IsBuddyItem).Select(item => item as BuddyItem).ToList(); } - private void ApplyStatsToAugmentations(List items) { - ApplyStatsToDbItems(items, StatFetch.AugmentItems); - } - - private void ApplyStatsToDbItems(List items, StatFetch type) { - var records = GetRecordsForItems(items); - Dictionary> statMap = _databaseItemStatDao.GetStats(records, type); - - foreach (PlayerHeldItem phi in items) { - List stats = new List(); - if (statMap.ContainsKey(phi.BaseRecord)) - stats.AddRange(Filter(statMap[phi.BaseRecord])); - - var statsWithText = Filter(stats.Where(m => !string.IsNullOrEmpty(m.TextValue))); - List statsWithNumerics = stats.Where(m => string.IsNullOrEmpty(m.TextValue)) - .GroupBy(r => r.Stat) - .Select(g => new DBStatRow { - Record = g.FirstOrDefault()?.Record, - TextValue = g.FirstOrDefault()?.TextValue, - Stat = g.FirstOrDefault()?.Stat, - Value = g.Sum(v => v.Value) - }) - .ToList(); - - statsWithNumerics.AddRange(statsWithText); - - phi.Tags = new HashSet(statsWithNumerics); - } - - Logger.Debug($"Applied stats to {items.Count} items"); - } public void ApplyStats(IEnumerable itemSource) { var items = itemSource.ToList();