Add project sample data generation#2231
Conversation
3e34251 to
66be09b
Compare
66be09b to
c44274b
Compare
There was a problem hiding this comment.
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-dataendpoint that enqueues project-scoped sample event generation. - Add
POST /projects/{id}/reset-data(in addition to legacy GET) and implement a newResetProjectDataWorkItem+ 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.
| } | ||
|
|
||
| var project = await _projectRepository.GetByIdAsync(workItem.ProjectId); | ||
| if (project is null || project.OrganizationId != organization.Id) |
There was a problem hiding this comment.
| 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) |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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.
| public string? OrganizationId { get; init; } | ||
| public string? ProjectId { get; init; } |
|
|
||
| <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" |
There was a problem hiding this comment.
I think this would just be a variant color on the button for green
Adds a project-scoped sample data workflow so users can populate a newly configured project without wiring up a client first.
Summary:
Validation:
dotnet buildwith isolated output pathsProjectControllerTestsandOpenApiControllerTestsnpm run checknpm run lintgit diff --check