CSC/ECE 517 Fall 2020 - E2066. Refactor lottery controller.rb

From Expertiza_Wiki
Revision as of 00:51, 11 October 2020 by Cmehta (talk | contribs)
Jump to navigation Jump to search

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

  1. Fix bug which created multiple bids for same topic, team and priority
  2. Call existing AssignmentTeam.rb method to create team and team node, instead of creating them separately (DRY principle)
  3. Call existing Team.rb method to add members in team.
  4. Remove code that explicitly deletes dependents before deleting object and rely on dependent destroy instead.
  5. Move logic to delete empty teams belonging to an assignment into assignment.rb.
  6. Move logic for creation of team with members to Team.rb.
  7. Move logic that merges bids of different users to Bid.rb

Implementations

Files Modified

  • 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