fix: persist repeated profile test results (#10466)

This commit is contained in:
Shubham Padkonde
2026-11-02 06:56:34 +05:30
committed by GitHub
parent 7a52be4150
commit c436b998b4
3 changed files with 104 additions and 22 deletions
+7 -22
View File
@@ -39,15 +39,14 @@ public class ProfileExManager
{
if (indexId.IsNotEmpty())
{
//Speed tests touch this from many threads; duplicates are harmless here since
//the save loop just writes the same row more than once
//Speed tests touch this from many threads; the save loop deduplicates IDs.
_queIndexIds.Enqueue(indexId);
}
}
private async Task SaveQueueIndexIds()
{
var lstIds = new List<string>();
var lstIds = new HashSet<string>();
while (_queIndexIds.TryDequeue(out var id))
{
lstIds.Add(id);
@@ -55,39 +54,25 @@ public class ProfileExManager
if (lstIds.Count > 0)
{
var lstExists = await SQLiteHelper.Instance.TableAsync<ProfileExItem>().ToListAsync();
List<ProfileExItem> lstInserts = [];
List<ProfileExItem> lstUpdates = [];
List<ProfileExItem> lstSaves = [];
foreach (var id in lstIds)
{
var item = lstExists.FirstOrDefault(t => t.IndexId == id);
var itemNew = _lstProfileEx?.FirstOrDefault(t => t.IndexId == id);
if (itemNew is null)
{
continue;
}
if (item is not null)
{
lstUpdates.Add(itemNew);
}
else
{
lstInserts.Add(itemNew);
}
lstSaves.Add(itemNew);
}
try
{
if (lstInserts.Count > 0)
if (lstSaves.Count > 0)
{
await SQLiteHelper.Instance.InsertAllAsync(lstInserts);
}
if (lstUpdates.Count > 0)
{
await SQLiteHelper.Instance.UpdateAllAsync(lstUpdates);
//Another save may have inserted these rows since the queue was drained.
await SQLiteHelper.Instance.ReplaceAllAsync(lstSaves);
}
}
catch (Exception ex)