CSC/ECE 517 Fall 2020 - E2066. Refactor lottery controller.rb
This page provides a description of the Expertiza based OSS project.
Introduction
About Lottery Controller
The lottery controller assigns teams to topics based on the priorities the team gave to each signup topic during the bidding process. When the lottery controller is called to run its method run_intelligent_assignment, a web service is sent the bidding data from each team and returns a new list of teams, each of which is close to the maximum team size specified for the assignment. The web service coalesces teams that have similar bid data and then assigns those coalesced teams to topics, giving each team their top bid on a topic that hasn't been assigned yet. Teams with larger team sizes and more bids are assigned their topics first.
Motivation
This class contains logic to merge bids. It also contains code that creates teams, add and removes users from team. These methods are more suited to being model methods. The As much as possible, the controller should only contain standard crud actions.
Task Identified
- Fix bug which created multiple bids for same topic, team and priority
- Call existing AssignmentTeam.rb method to create team and team node, instead of creating them separately (DRY principle)
- Call existing Team.rb method to add members in team.
- Remove code that explicitly deletes dependents before deleting object and rely on dependent destroy instead.
- Move logic to delete empty teams belonging to an assignment into assignment.rb.
- Move logic for creation of team with members to Team.rb.
- Move logic that merges bids of different users to Bid.rb
Files Affected
- app/controllers/lottery_controller.rb
- app/models/assignment.rb
- app/models/bid.rb
- app/models/team.rb
- spec/controllers/lottery_controller_spec.rb
- spec/models/assignment_spec.rb
- spec/models/assignment_team_spec.rb
- spec/models/assignment_team_spec.rb