Skip to content

Conversation

@manak-sharma20
Copy link

@manak-sharma20 manak-sharma20 commented Nov 18, 2025

… for cleaner controller and better maintainability

📌 Summary

This PR introduces a new EventCopierService that centralizes the event-copying logic previously located inside the events/view controller. This refactor reduces controller bloat, improves maintainability, and follows Ember’s best practice of moving business logic into services.

🔧 What Was Changed
✅ Added EventCopierService

A new service (app/services/event-copier.js) was created to handle:

The API request for copying events

Success notifications

Error notifications

The service exposes three methods:

copy(eventId) — performs the POST request

success() — shows a success toast

error() — shows an error toast

✅ Updated Controller to Use the Service

The events/view controller now delegates work to the service instead of handling:

API logic

Toast notifications

Error handling

This significantly simplifies the controller, improving readability and reducing responsibilities.

🎯 Why This Refactor?
Before

The controller contained:

Network request code

Notifications

State management

Routing logic

This violated the Single Responsibility Principle and made testing difficult.

After

Business logic is encapsulated in a dedicated, testable service, and the controller is much cleaner.

🧪 Testing

Verified that copying an event still works end-to-end.

Confirmed success and error notifications behave correctly.

Checked integration with loader, notify, and l10n services.

🚀 Benefits

Cleaner, more maintainable architecture

Easier unit testing of the copy logic

Better separation of concerns

More reusable and scalable design

Summary by Sourcery

Extract copyEvent logic into a dedicated EventCopierService to centralize API requests and notifications, simplifying the events/view controller and improving maintainability.

Enhancements:

  • Add EventCopierService with copy, success, and error methods for handling event duplication
  • Update events/view controller to delegate API and notification logic to EventCopierService

… for cleaner controller and better maintainability
@vercel
Copy link

vercel bot commented Nov 18, 2025

@manak-sharma20 is attempting to deploy a commit to the eventyay Team on Vercel.

A member of the Team first needs to authorize it.

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 18, 2025

Reviewer's Guide

Refactor extracts event-copying logic from the events/view controller into a new EventCopierService to improve separation of concerns, reduce controller complexity, and centralize API calls and notifications.

Class diagram for the new EventCopierService

classDiagram
class EventCopierService {
  +loader : LoaderService
  +notify : NotifyService
  +l10n : L10nService
  +copy(eventId)
  +success()
  +error()
}
EventCopierService --> LoaderService : uses
EventCopierService --> NotifyService : uses
EventCopierService --> L10nService : uses
Loading

Class diagram for updated events/view controller responsibilities

classDiagram
class EventsViewController {
  -delegates event copying to EventCopierService
  -simplified logic
}
EventsViewController --> EventCopierService : delegates copy logic
Loading

File-Level Changes

Change Details Files
Created EventCopierService to encapsulate event copying logic
  • Injected loader, notify, and l10n services
  • Implemented async copy(eventId) making POST request
  • Added success() and error() notification methods
app/services/event-copier.js
Updated events/view controller to use the new service
  • Replaced inline POST request with service.copy()
  • Removed direct success and error notification code
  • Simplified controller action by delegating business logic
app/controllers/events/view.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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.

1 participant