Skip to content

Add project sample data generation#2231

Open
ejsmith wants to merge 4 commits into
mainfrom
project-sample-data-reset
Open

Add project sample data generation#2231
ejsmith wants to merge 4 commits into
mainfrom
project-sample-data-reset

Conversation

@ejsmith
Copy link
Copy Markdown
Member

@ejsmith ejsmith commented May 11, 2026

Adds a project-scoped sample data workflow so users can populate a newly configured project without wiring up a client first.

Summary:

  • Add API support to queue project sample data generation and project data reset work items.
  • Generate project sample events through the normal event pipeline.
  • Add configure-page sample data actions in both the legacy Angular UI and the Svelte UI.
  • Keep project reset available from project settings/manage rather than the configure flow.
  • Update OpenAPI baseline, HTTP samples, and project controller coverage.

Validation:

  • dotnet build with isolated output paths
  • Targeted ProjectControllerTests and OpenApiControllerTests
  • Svelte npm run check
  • ESLint on the touched Svelte configure page
  • Angular npm run lint
  • git diff --check
  • Local browser verification for Angular and Svelte configure pages

@ejsmith ejsmith force-pushed the project-sample-data-reset branch from 3e34251 to 66be09b Compare May 11, 2026 03:38
@ejsmith ejsmith force-pushed the project-sample-data-reset branch from 66be09b to c44274b Compare May 11, 2026 03:41
@ejsmith ejsmith requested a review from Copilot May 11, 2026 03:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a project-scoped “sample data” workflow so users can populate a newly configured project (via API + both UIs), and updates the existing project “reset data” flow to queue work items (now supporting POST while keeping the legacy GET).

Changes:

  • Add POST /projects/{id}/sample-data endpoint that enqueues project-scoped sample event generation.
  • Add POST /projects/{id}/reset-data (in addition to legacy GET) and implement a new ResetProjectDataWorkItem + handler to remove project data.
  • Wire new actions into both the Svelte configure page and the legacy Angular configure flow; update OpenAPI baseline, HTTP samples, and controller tests.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/http/projects.http Adds HTTP samples for sample-data generation and POST reset-data (keeps legacy GET).
tests/Exceptionless.Tests/Controllers/ProjectControllerTests.cs Adds coverage for project-scoped sample generation and updates reset-data behavior assertions.
tests/Exceptionless.Tests/Controllers/Data/openapi.json Updates OpenAPI baseline for new sample-data endpoint and reset-data POST.
src/Exceptionless.Web/Controllers/ProjectController.cs Adds POST {id}/sample-data; adds POST {id}/reset-data; switches reset work item to ResetProjectDataWorkItem.
src/Exceptionless.Web/ClientApp/src/routes/(app)/project/[projectId]/configure/+page.svelte Adds “Generate Sample Data” button/flow to Svelte configure page.
src/Exceptionless.Web/ClientApp/src/lib/features/projects/api.svelte.ts Adds generateSampleData mutation and updates resetData mutation to return WorkInProgressResult from 202.
src/Exceptionless.Web/ClientApp.angular/lang/zh-cn.json Adds translations for sample data generation UI strings.
src/Exceptionless.Web/ClientApp.angular/lang/en-us.json Adds translations for sample data generation UI strings.
src/Exceptionless.Web/ClientApp.angular/components/project/project-service.js Adds generateSampleData() API call; switches resetData() to POST.
src/Exceptionless.Web/ClientApp.angular/app/project/configure.tpl.html Adds a “Generate Sample Data” button to legacy Angular configure UI.
src/Exceptionless.Web/ClientApp.angular/app/project/configure-controller.js Implements legacy Angular controller behavior for queuing sample data generation.
src/Exceptionless.Core/Utility/SampleDataService.cs Adds a project-scoped enqueue method that returns the work item id.
src/Exceptionless.Core/Models/WorkItems/ResetProjectDataWorkItem.cs Introduces a new work item payload for project data reset.
src/Exceptionless.Core/Models/WorkItems/GenerateSampleEventsWorkItem.cs Extends sample event work item with optional OrganizationId/ProjectId for project-scoped generation.
src/Exceptionless.Core/Jobs/WorkItemHandlers/ResetProjectDataWorkItemHandler.cs Adds handler to remove stacks/events by project and clear related cache entries.
src/Exceptionless.Core/Jobs/WorkItemHandlers/GenerateSampleEventsWorkItemHandler.cs Adds project-scoped generation path and per-project work item locking.
src/Exceptionless.Core/Bootstrapper.cs Registers the new ResetProjectDataWorkItem handler.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown

Code Coverage

Package Line Rate Branch Rate Complexity Health
Exceptionless.Core 67% 61% 7742
Exceptionless.Insulation 25% 23% 203
Exceptionless.Web 60% 46% 3908
Exceptionless.AppHost 18% 9% 82
Summary 62% (12669 / 20283) 55% (6331 / 11476) 11935

}

var project = await _projectRepository.GetByIdAsync(workItem.ProjectId);
if (project is null || project.OrganizationId != organization.Id)
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.

Suggested change
if (project is null || project.OrganizationId != organization.Id)
if (project is null || !String.Equals(project.OrganizationId, organization.Id))

const int batchSize = 100;
var events = generator.Generate(organization.Id, project.Id, eventCount, minDate, utcNow);

for (int i = 0; i < events.Count; i += batchSize)
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.

use new Enumerable.Chunk and foreach over the chunks.

await context.ReportProgressAsync(50, $"Events removed: {removedEvents}");

long removedStacks = await _stackRepository.RemoveAllByProjectIdAsync(workItem.OrganizationId, workItem.ProjectId);
await _cacheClient.RemoveByPrefixAsync(String.Concat("stack-filter:", workItem.OrganizationId, ":", workItem.ProjectId));
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.

We should probably create a static cache key for this stack filter and reference it here, so it doesn't break over time and we know usages.

Comment on lines +5 to +6
public string? OrganizationId { get; init; }
public string? ProjectId { get; init; }
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.

shouldn't these be required?


<div class="border-border flex flex-col-reverse gap-2 border-t pt-4 sm:flex-row sm:justify-end">
<Button
class="bg-green-600 text-white hover:bg-green-700 focus-visible:border-green-700 focus-visible:ring-green-600/20 dark:bg-green-600 dark:hover:bg-green-700"
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.

I think this would just be a variant color on the button for green

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants