CSC/ECE 517 Spring 2023 - E2339. Reimplement signed up team.rb, sign up topic.rb, sign up sheet.rb (Project 4)

From Expertiza_Wiki
Revision as of 01:17, 30 October 2024 by Skanumu2 (talk | contribs) (→‎Team)
Jump to navigation Jump to search

Team

Project Description

The objective of the project is to reimplement the following Ruby on Rails model classes in the existing project:- SignUpTeam, SignUpTopic and SignUpSheet. SignUpTeam model class represents a signed-up team for a particular sign-up topic in a specific assignment. SignUpTopic model class represents a topic that can be signed up for in a course assignment. SignUpSheet class stores the logic for creating a signed_up_team for a topic for a particular assignment. This class is being used as a module having all class methods.

The task is to reimplement the existing code present in these model files and implement them in a new repository. Since the project is implemented from scratch, there are various aspects of the project that have to be implemented and therefore unit test cases are implemented to test the implementation.

Issue Description

  • Thorough RSpec tests are required for the reimplemented models.
  • Change all references of sign_up_teams to signed_up_teams.
  • Fix all code review comments.
  • There is no designated waitlist model to handle scenarios regarding waitlisting, upgrading and handling multiple registrations.
  • Some methods have readability concerns that needs to be refactored.
  • There are ambiguous class and instance methods that can be optimized for better reusability.
  • The SignedUpTeam class has methods that handle multiple responsibilities, including finding participants and teams, releasing topics, and removing signed up teams. This violates the single responsibility principle and makes the class harder to understand and maintain.
  • Some of the queries in the class use complex SQL statements and multiple joins, which can make them hard to read and understand. These complex SQL queries in the code could be simplified and made more readable by using ActiveRecord's query interface instead.
  • The same code is repeated in multiple methods, such as the code to find signed up teams for a given topic. This violates the Don't Repeat Yourself (DRY) principle and can make the code harder to maintain.

Design Strategy

  • To tackle the mentioned problem, three model class files namely sign_up_team.rb, sign_up_topic.rb and waitlist.rb are implemented.
  • sign_up_sheet.rb is removed because the class methods can be refactored into signup_topic.rb and waitlist.rb.
  • In signed_up_team.rb, the following functionality are being implemented:-
Method Name Status Description
destroy Implemented It is responsible for deleting the team from the table and delegating any changes in topic.
get_team_participants Implemented It is responsible to get participants in the team signed up for a given topic.
create_signed_up_team Implemented It is responsible for creating a SignedUpTeam instance with given topic_id and team_id if topic is available.
  • Add necessary schema migrations for backward compatibility.
  • In signup_topic.rb, the following functionality are being implemented:-
Method Name Status Description
destroy_topic Implemented It is used to destroy topic from the table.
update_topic Implemented It is used to modify the attributes like description, max_choosers or category in the table.
get_team_participants Implemented It is used to fetch participants of the team assigned to the topic.
count_filled_slots Implemented It is used to return the number of slots filled for the topic.
count_available_slots Implemented It is used to return the number of slots available for the topic.
release_team Implemented It is used to promote 1 team from the waitlist and assign the topic.
is_assigned_to_team Implemented It is used to validate if the topic is assigned to the team
get_assigned_teams Implemented It is used to retrieve all teams assigned to the topic.
is_available Implemented It is used to check if the given topic is available for selection by signed_up_teams
as_json Implemented It is responsible for serializing content of SignupTopic instance to JSON format.
  • In waitlist.rb, the following functionality are yet to be implemented in next phase:-
Method Name Status Description
count_waitlisted_teams Implemented It is used to return the number of waitlisted teams for the particular topic.
promote_teams_from_waitlist Implemented It is used to promote first N teams from the waitlist and assigns them to the topic.
  • Refactor instance methods to be more succinct (ex: find_if_topic_available to available, create_sign_up_team to sign_up_team, drop_sign_up_team to drop_team)
  • Rename model from “Sign Up Team” to “Signed Up Team” for better clarity.
  • Remove is_waitlisted attribute in favor of better querying from the Waitlist model.
  • Add tests for error conditions and exit handling.
  • Add tests to validate usage of @counter_cache used to count relations.
  • Create empty models (if non-existent) and add necessary model-association relations.
  • Integrate and delegate waitlist handling from sign_up_topic.
  • Add cascading deletes for relations to other models as appropriate.
  • Add JSON serializers for REST API responses.
  • Add tests using ‘shoulda-matchers’ for more exhaustive tests as appropriate.
  • Integrate ‘FactoryBot’ for automatic model record generation during testing.
  • Add ‘preference_priority_number’ for backward compatibility during migration.

E/R Diagram

Test Plan

  • Upgrade RSpec test cases for sign_up_team.rb to validate delete_team and get_participants.
  • Upgrade and add RSpec test cases for sign_up_topic.rb to find participants, handle slot availability and assignment status.
  • Create RSpec test cases for waitlist.rb to validate adding teams to waitlist, remove teams from waitlist and query status of team's waitlist.
  • Add general RSpec test cases for error handling and validate JSON serialization.
  • Test Cases for signed_up_team.rb model

  • Test Cases for waitlist.rb model

  • Test Cases for signup_topic.rb