Skip to content

Optimize startup project metadata refresh without changing global GetAll loading behavior#1397

Merged
aharwood2 merged 4 commits into
1375-compute-or-cache-project-meta-data-on-program-startfrom
copilot/fix-review-comment-1388
Jul 2, 2026
Merged

Optimize startup project metadata refresh without changing global GetAll loading behavior#1397
aharwood2 merged 4 commits into
1375-compute-or-cache-project-meta-data-on-program-startfrom
copilot/fix-review-comment-1388

Conversation

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

The review flagged startup overhead from calling ProjectService.GetAll(context) (deep eager-load + materialization) before per-project metadata updates. This PR keeps the heavy GetAll override intact for broader app usage, but narrows the startup-only metadata refresh path.

  • Scope of change (review comment only)

    • Updated UpdateAllProjectMetaData to stop using GetAll(context) in this path.
    • No changes to the shared GetAll override used elsewhere in the app.
  • Targeted query for metadata recomputation

    • Replaced the deep global load with the minimum include graph required by UpdateProjectMetaData and downstream cost calculation:
      • SubTasks -> AssignedResources -> Person -> WorkloadModelChanges
      • FundingSources
    • Removed non-required includes from this startup path after verification:
      • SubTasks -> AssignedResources -> FundedFrom
      • School -> Faculty
      • ProjectManager
  • Lower per-project write overhead

    • Removed Update(context, project) from the loop (which performs duplicate checks each iteration).
    • Persisted successful in-memory updates via CommitChanges(context) directly in the update path.
var projects = context.Projects
    .Include(p => p.SubTasks)
        .ThenInclude(s => s.AssignedResources)
            .ThenInclude(r => r.Person)
                .ThenInclude(p => p.WorkloadModelChanges)
    .Include(p => p.FundingSources)
    .ToList();

// ...
project.UpdateProjectMetaData(true, finrefs, indirects);
CommitChanges(context);

Copilot AI changed the title [WIP] Fix code based on review comment for PR 1388 Optimize startup project metadata refresh without changing global GetAll loading behavior Jul 1, 2026
Copilot AI requested a review from aharwood2 July 1, 2026 17:08
Comment thread PPMTool/Services/ProjectService.cs

@aharwood2 aharwood2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please respond to the open comment.

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please respond to the open comment.

I’ve re-checked this against UpdateProjectMetaData and its downstream cost path: for this startup refresh path the minimum required eager-load graph remains SubTasks -> AssignedResources -> Person -> WorkloadModelChanges plus FundingSources. The other previously removed includes (FundedFrom, School -> Faculty, ProjectManager) are not required for this flow.

@aharwood2 aharwood2 marked this pull request as ready for review July 1, 2026 18:45
@aharwood2 aharwood2 merged commit b22db45 into 1375-compute-or-cache-project-meta-data-on-program-start Jul 2, 2026
10 checks passed
@aharwood2 aharwood2 deleted the copilot/fix-review-comment-1388 branch July 2, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants