From 58534af3dc61a7692ea1278bfe588c47b13d3e4e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 12 Dec 2025 15:58:16 +0000 Subject: [PATCH 1/3] Initial plan From 83d8c8e8eab6210795c40de9bb38b6347b7dfe40 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 12 Dec 2025 16:04:46 +0000 Subject: [PATCH 2/3] Fix CrystaTaskServiceFake query logic and SyncInfo population per code review Co-authored-by: afshinalizadeh <4254006+afshinalizadeh@users.noreply.github.com> --- .../CrystaProgramSyncModuleServiceFake.cs | 2 +- .../Services/CrystaTaskServiceFake.cs | 45 ++++++++++--------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/Core/CrystaLearn.Core/Services/CrystaProgramSyncModuleServiceFake.cs b/src/Core/CrystaLearn.Core/Services/CrystaProgramSyncModuleServiceFake.cs index 2513bcd..0870e20 100644 --- a/src/Core/CrystaLearn.Core/Services/CrystaProgramSyncModuleServiceFake.cs +++ b/src/Core/CrystaLearn.Core/Services/CrystaProgramSyncModuleServiceFake.cs @@ -10,7 +10,7 @@ public partial class CrystaProgramSyncModuleServiceFake : ICrystaProgramSyncModu { private static List _modules = new(); - private IConfiguration Configuration { get; set; } = default!; + private IConfiguration Configuration { get; set; } = default!; public CrystaProgramSyncModuleServiceFake(IConfiguration configuration) { diff --git a/src/Core/CrystaLearn.Core/Services/CrystaTaskServiceFake.cs b/src/Core/CrystaLearn.Core/Services/CrystaTaskServiceFake.cs index 4e2a9ab..5a4aed3 100644 --- a/src/Core/CrystaLearn.Core/Services/CrystaTaskServiceFake.cs +++ b/src/Core/CrystaLearn.Core/Services/CrystaTaskServiceFake.cs @@ -95,29 +95,22 @@ public Task DeleteCrystaTaskUpdatesAsync(List syncIds) public Task> GetAllWorkItemSyncIdsAsync(string project) { - var ids = _tasks - .Where(t => !string.IsNullOrEmpty(t.ProviderTaskId)) - .Select(t => t.ProviderTaskId!) + // Get all non-deleted tasks sync IDs matching the project + var syncIds = _tasks + .Where(t => !t.IsDeleted && t.ProjectName == project && !string.IsNullOrEmpty(t.WorkItemSyncInfo.SyncId)) + .Select(t => t.WorkItemSyncInfo.SyncId ?? "") + .Where(id => !string.IsNullOrEmpty(id)) .ToList(); - // If project filtering is required and CrystaProgram contains project name, filter. - if (!string.IsNullOrEmpty(project)) - { - ids = _tasks - .Where(t => t.CrystaProgram != null && string.Equals(t.CrystaProgram.ToString(), project, StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(t.ProviderTaskId)) - .Select(t => t.ProviderTaskId!) - .ToList(); - } - - return Task.FromResult(ids); + return Task.FromResult(syncIds); } public Task> GetCommentsSyncItemsAsync(List ids) { if (ids == null || ids.Count == 0) return Task.FromResult(new List()); var found = _comments - .Where(c => (c.Revision != null && ids.Contains(c.Revision)) || (c.ProviderTaskId != null && ids.Contains(c.ProviderTaskId)) || (c.Id != Guid.Empty && ids.Contains(c.Id.ToString()))) - .Select(c => new SyncItem { Id = c.Id }) + .Where(c => c.SyncInfo != null && ids.Contains(c.SyncInfo.SyncId ?? "")) + .Select(c => new SyncItem { Id = c.Id, SyncInfo = c.SyncInfo }) .ToList(); return Task.FromResult(found); } @@ -126,8 +119,8 @@ public Task> GetRevisionsSyncItemsAsync(List ids) { if (ids == null || ids.Count == 0) return Task.FromResult(new List()); var found = _revisions - .Where(r => (r.Revision != null && ids.Contains(r.Revision)) || (r.ProviderTaskId != null && ids.Contains(r.ProviderTaskId)) || (r.Id != Guid.Empty && ids.Contains(r.Id.ToString()))) - .Select(r => new SyncItem { Id = r.Id }) + .Where(r => ids.Contains(r.WorkItemSyncInfo.SyncId ?? "")) + .Select(r => new SyncItem { Id = r.Id, SyncInfo = r.WorkItemSyncInfo }) .ToList(); return Task.FromResult(found); } @@ -136,8 +129,8 @@ public Task> GetUpdatesSyncItemsAsync(List ids) { if (ids == null || ids.Count == 0) return Task.FromResult(new List()); var found = _updates - .Where(u => (u.Revision != null && ids.Contains(u.Revision)) || (u.ProviderTaskId != null && ids.Contains(u.ProviderTaskId)) || (u.Id != Guid.Empty && ids.Contains(u.Id.ToString()))) - .Select(u => new SyncItem { Id = u.Id }) + .Where(u => u.SyncInfo != null && ids.Contains(u.SyncInfo.SyncId ?? "")) + .Select(u => new SyncItem { Id = u.Id, SyncInfo = u.SyncInfo }) .ToList(); return Task.FromResult(found); } @@ -146,8 +139,18 @@ public Task> GetWorkItemSyncItemsAsync(List ids) { if (ids == null || ids.Count == 0) return Task.FromResult(new List()); var found = _tasks - .Where(t => (t.ProviderTaskId != null && ids.Contains(t.ProviderTaskId)) || (t.Id != Guid.Empty && ids.Contains(t.Id.ToString()))) - .Select(t => new SyncItem { Id = t.Id }) + .Where(t => ids.Contains(t.WorkItemSyncInfo.SyncId ?? "")) + .Select(t => new SyncItem + { + Id = t.Id, + SyncInfo = t.WorkItemSyncInfo == null + ? null + : new SyncInfo + { + SyncId = t.WorkItemSyncInfo.SyncId, + ContentHash = t.WorkItemSyncInfo.ContentHash + } + }) .ToList(); return Task.FromResult(found); } From bc75731d3540675eb0d44382fabaf187fadb817f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 12 Dec 2025 16:06:12 +0000 Subject: [PATCH 3/3] Simplify GetWorkItemSyncItemsAsync to directly assign SyncInfo Co-authored-by: afshinalizadeh <4254006+afshinalizadeh@users.noreply.github.com> --- .../Services/CrystaTaskServiceFake.cs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/Core/CrystaLearn.Core/Services/CrystaTaskServiceFake.cs b/src/Core/CrystaLearn.Core/Services/CrystaTaskServiceFake.cs index 5a4aed3..7dd6d89 100644 --- a/src/Core/CrystaLearn.Core/Services/CrystaTaskServiceFake.cs +++ b/src/Core/CrystaLearn.Core/Services/CrystaTaskServiceFake.cs @@ -140,17 +140,7 @@ public Task> GetWorkItemSyncItemsAsync(List ids) if (ids == null || ids.Count == 0) return Task.FromResult(new List()); var found = _tasks .Where(t => ids.Contains(t.WorkItemSyncInfo.SyncId ?? "")) - .Select(t => new SyncItem - { - Id = t.Id, - SyncInfo = t.WorkItemSyncInfo == null - ? null - : new SyncInfo - { - SyncId = t.WorkItemSyncInfo.SyncId, - ContentHash = t.WorkItemSyncInfo.ContentHash - } - }) + .Select(t => new SyncItem { Id = t.Id, SyncInfo = t.WorkItemSyncInfo }) .ToList(); return Task.FromResult(found); }