-
Notifications
You must be signed in to change notification settings - Fork 1.8k
refactor(events/view): extract copyEvent logic into dedicated service… #9203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
refactor(events/view): extract copyEvent logic into dedicated service… #9203
Conversation
… for cleaner controller and better maintainability
|
@manak-sharma20 is attempting to deploy a commit to the eventyay Team on Vercel. A member of the Team first needs to authorize it. |
Reviewer's GuideRefactor 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 EventCopierServiceclassDiagram
class EventCopierService {
+loader : LoaderService
+notify : NotifyService
+l10n : L10nService
+copy(eventId)
+success()
+error()
}
EventCopierService --> LoaderService : uses
EventCopierService --> NotifyService : uses
EventCopierService --> L10nService : uses
Class diagram for updated events/view controller responsibilitiesclassDiagram
class EventsViewController {
-delegates event copying to EventCopierService
-simplified logic
}
EventsViewController --> EventCopierService : delegates copy logic
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
… 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: