Skip to content

Revert "Align Orders queries with existing use case view models"#16

Open
mzet97 wants to merge 1 commit intomainfrom
revert-13-codex/implement-application-and-infrastructure-for-orders
Open

Revert "Align Orders queries with existing use case view models"#16
mzet97 wants to merge 1 commit intomainfrom
revert-13-codex/implement-application-and-infrastructure-for-orders

Conversation

@mzet97
Copy link
Copy Markdown
Owner

@mzet97 mzet97 commented Dec 9, 2025

Reverts #13

Copilot AI review requested due to automatic review settings December 9, 2025 21:14
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @mzet97, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request completely reverts the changes introduced in PR #13, which aimed to align order queries with existing use case view models. The reversion involves removing the Paramore.Darker query processing framework, consolidating Brighter event mapping logic into the shared domain, and eliminating numerous command, query, and event classes that were part of the previous implementation. This effectively rolls back the application's event dispatching and query handling mechanisms to their state before PR #13.

Highlights

  • Reversion of Query Infrastructure: Fully reverts the integration of Paramore.Darker for query processing, removing ServiceProviderQueryProcessor and all associated query definitions and handlers for orders, categories, and status types.
  • Reversion of Command Infrastructure: Undoes the introduction of specific command classes and their handlers for order management (e.g., AssignOrderCommand, CreateOrderCommand, UpdateOrderCommand, CloseOrderCommand, ChangeOrderStatusCommand).
  • Event Dispatcher Relocation: Moves the Brighter domain event dispatching components (BrighterDomainEventDispatcher, IBrighterEventMapper, BrighterEventMapper) from EChamado.Server.Infrastructure.Events back to EChamado.Shared.Domain.Events, indicating a shift in where these core event handling mechanisms reside.
  • Dependency Rollback: Removes the DomainEventsSaveChangesInterceptor from the EF Core configuration and the EChamado.Server.Infrastructure dependency injection setup, along with the specific Brighter event mapper registrations for various domain events.
  • Shared Project Update: Adds the Paramore.Brighter NuGet package reference to the EChamado.Shared.csproj file, supporting the relocation of Brighter-related interfaces and implementations to the shared domain.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@deepsource-io
Copy link
Copy Markdown
Contributor

deepsource-io bot commented Dec 9, 2025

Here's the code health analysis summary for commits 60f0455..55fe2d5. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource C# LogoC#❌ Failure
❗ 1 occurence introduced
🎯 1 occurence resolved
View Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request reverts changes from PR #13, which aimed to align Orders queries. The revert correctly removes numerous files and dependencies related to Paramore.Darker and the CQRS query pattern. However, the revert appears to be incomplete and has a critical side effect: it disables the domain event dispatching system. While event-related files are moved to the Shared project, their dependency injection registrations and the crucial DomainEventsSaveChangesInterceptor are removed. This will cause domain events, which are still being created in entities like Order, to be silently ignored. This needs to be addressed to ensure application correctness.

I am having trouble creating individual review comments. Click here to see my feedback.

src/EChamado/Server/EChamado.Server.Infrastructure/Configuration/DependencyInjectionConfig.cs (46-64)

critical

Removing these service registrations, along with the DomainEventsSaveChangesInterceptor (which is also removed in this PR), will break the domain event dispatching mechanism. Domain entities like Order are still generating events (e.g., OrderCreated, OrderUpdated), but they will no longer be dispatched and handled. This is a critical issue as it can lead to silent failures and inconsistent state.

This revert seems to have unintentionally removed the wiring for domain events. Please either:

  1. Restore the domain event dispatching infrastructure, including these DI registrations and the DomainEventsSaveChangesInterceptor.
  2. If domain events are no longer desired, remove the event generation logic from the domain entities (e.g., calls to AddEvent in Order.cs).

Given that event-related files were moved to the Shared project, it seems likely that their removal from DI was an oversight.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 28 to 30
var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
options.UseLoggerFactory(loggerFactory);
options.UseNpgsql(configuration.GetConnectionString("DefaultConnection"));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Domain events no longer dispatched after SaveChanges

This DbContext configuration no longer adds the DomainEventsSaveChangesInterceptor, so aggregates that call AddEvent (e.g., OrderCreated/OrderUpdated in Order) will keep their events in-memory but nothing ever publishes them through Brighter or clears them after SaveChangesAsync. As a result, creating or updating orders/categories/statuses will silently skip all domain-event side effects and message bus handlers.

Useful? React with 👍 / 👎.

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

This PR reverts changes from PR #13, which attempted to align Orders queries with existing use case view models. The revert removes duplicate CQRS query implementations that overlapped with existing functionality and reorganizes domain event infrastructure from the Infrastructure layer to the Shared layer for better architectural separation.

Key changes:

  • Removes duplicate query handlers and queries for Orders, Categories, and StatusTypes that duplicated existing UseCases implementations
  • Removes duplicate command handlers and commands for Order operations (Create, Update, Close, Assign, ChangeStatus) that already exist in UseCases folder
  • Moves domain event infrastructure (IDomainEventDispatcher, IBrighterEventMapper, BrighterEventMapper, BrighterDomainEventDispatcher) from EChamado.Server.Infrastructure.Events to EChamado.Shared.Domain.Events for better reusability
  • Removes the DomainEventsSaveChangesInterceptor and its registration from the database context configuration
  • Cleans up unused event wrapper classes and Brighter event registrations from DependencyInjectionConfig

Reviewed changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
DomainEventsSaveChangesInterceptor.cs Removed EF Core interceptor that was dispatching domain events on save
IDomainEventDispatcher.cs (Infrastructure) Removed from Infrastructure layer (moved to Shared)
IBrighterEventMapper.cs (Infrastructure) Removed from Infrastructure layer (moved to Shared)
BrighterDomainEventDispatcher.cs (Infrastructure) Removed from Infrastructure layer (moved to Shared)
BrighterEventMapper.cs (Infrastructure) Removed from Infrastructure layer (moved to Shared)
IdentityConfig.cs Removed interceptor registration from DbContext configuration
DependencyInjectionConfig.cs (Infrastructure) Removed Brighter event mapper registrations and dispatcher services; minor using statement ordering issue
DependencyInjectionConfig.cs (Application) Removed Paramore.Darker query processor and handler registrations; Paramore.Darker package now unused
ServiceProviderQueryProcessor.cs Removed custom query processor implementation for Paramore.Darker
ListStatusTypesQuery/Handler.cs Removed duplicate query implementation
ListOrdersQuery/Handler.cs Removed duplicate query implementation
ListCategoriesQuery/Handler.cs Removed duplicate query implementation
GetOrderByIdQuery/Handler.cs Removed duplicate query implementation
Update/Create/Close/Assign/ChangeOrderStatus Command/Handler.cs Removed duplicate command implementations
*Events.cs (multiple files) Removed Brighter event wrapper classes
IDomainEventDispatcher.cs (Shared) Added interface to Shared layer with proper namespace
IBrighterEventMapper.cs (Shared) Added interface to Shared layer with Portuguese documentation
BrighterEventMapper.cs (Shared) Moved to Shared layer with formatting improvements
BrighterDomainEventDispatcher.cs (Shared) Moved to Shared layer; contains redundant System.Threading using
EChamado.Shared.csproj Added Paramore.Brighter package reference (needed for new Shared classes)

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

Comment on lines 1 to 15
using EChamado.Server.Application.Common;
using EChamado.Server.Application.Common.Behaviours;
using EChamado.Server.Application.Common.Messaging;
using EChamado.Server.Application.Orders.QueryHandlers;
using EChamado.Server.Application.Orders.Queries;
using EChamado.Server.Application.Services;
using EChamado.Server.Application.Services.AI;
using EChamado.Server.Application.Services.AI.Configuration;
using EChamado.Server.Application.Services.AI.Interfaces;
using EChamado.Server.Application.Services.AI.Providers;
using EChamado.Server.Application.UseCases.Categories.ViewModels;
using EChamado.Server.Application.UseCases.Orders.ViewModels;
using EChamado.Server.Application.UseCases.StatusTypes.ViewModels;
using EChamado.Server.Domain.Services.Interface;
using FluentValidation;
using MediatR;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection;
using Paramore.Brighter;
using Paramore.Brighter.Extensions.DependencyInjection;
using Paramore.Darker;
using System.Reflection;
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The Paramore.Darker package reference is now unused after this revert. All query handlers and the ServiceProviderQueryProcessor that used Paramore.Darker have been removed. Consider removing the Paramore.Darker package reference from EChamado.Server.Application.csproj to avoid unnecessary dependencies.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,34 @@
using Paramore.Brighter;
using System.Threading;
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The using System.Threading; directive is redundant. Since the project has ImplicitUsings enabled (as seen in EChamado.Shared.csproj), the System.Threading namespace is already included implicitly, and CancellationToken is available without this explicit using statement. Consider removing this line to reduce unnecessary imports.

Suggested change
using System.Threading;

Copilot uses AI. Check for mistakes.
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using EChamado.Server.Infrastructure.Services;
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The using statement for EChamado.Server.Infrastructure.Services is not in alphabetical order. It should be placed between lines 5 and 6 (after EChamado.Server.Infrastructure.Email and before EChamado.Server.Infrastructure.Persistence) to maintain consistent using statement ordering.

Copilot uses AI. Check for mistakes.
Comment on lines +21 to +32
foreach (var de in domainEvents)
{
var req = _mapper.Map(de);
if (req is null) continue;

// Se for Event, Publish. Se for Command, Send.
// Mantém compatível com padrões do Brighter.
if (req is Event)
await _processor.PublishAsync(req, cancellationToken: ct);
else
await _processor.SendAsync(req, cancellationToken: ct);
}
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

This foreach loop immediately maps its iteration variable to another variable - consider mapping the sequence explicitly using '.Select(...)'.

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Feb 5, 2026

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