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

From Expertiza_Wiki
Jump to navigation Jump to search
 
(19 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Team ==
== Team Members ==


* Mentor - Krishna Saurabh Vankadaru
* Ajith Kanumuri
* Sai Venkata Varun Danda
* Suhas Adidela
* Saketh Vangala
* Ravi Chandu Bollepalli
* Surya Prakash Susarla
* Mentor - Dinesh Pasupuleti
* PR Request:- https://github.com/expertiza/reimplementation-back-end/pull/34
* PR Request:- https://github.com/expertiza/reimplementation-back-end/pull/125
* Project Board:- https://github.com/users/ajith05/projects/1/views/1


== Project Description ==
== 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.
 
The main goal of this project is to reimplement essential Ruby on Rails model classes—SignUpTeam, SignUpTopic, and SignUpSheet—from the Expertiza repository in a new repository. Each of these model classes plays a critical role in managing topics and team sign-ups within course assignments, and the reimplementation aims to bring them into alignment with Rails best practices and the DRY (Don't Repeat Yourself) principle.
 
The SignUpTeam model represents a team that has signed up for a specific topic within an assignment. This model manages team-specific data and oversees interactions that occur during the sign-up process. The SignUpTopic model, on the other hand, represents the topics available for sign-up within an assignment, managing essential details like slot availability and assigning teams to open topics. Lastly, the SignUpSheet class serves as a module, storing the methods needed to create and manage instances of SignUpTeam for assignment topics.
 
Since this project is being implemented from scratch, a range of components have been developed to ensure the functionality is both streamlined and maintainable. To guarantee the reliability of each part of the reimplementation, unit test cases have been created to verify the integrity of the new design and implementation.


== Issue Description ==
== Issue Description ==


* Thorough RSpec tests are required for the reimplemented models.  
* Comprehensive RSpec tests are essential for all reimplemented models to ensure correctness and reliability in functionality.
* Change all references of sign_up_teams to signed_up_teams.
 
* Fix all code review comments.
* Update all references from `sign_up_teams` to `signed_up_teams` throughout the codebase to maintain consistency with the new naming convention.
* 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.
* Address all code review feedback to improve code quality and alignment with best practices.
* 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.
* Currently, there is no specific waitlist model to manage waitlisting, upgrading, or handling multiple registrations. This functionality needs to be considered and integrated effectively.
* 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.
* Refactor methods with readability issues to make the code more maintainable and easier to understand.
 
* Optimize ambiguous class and instance methods to enhance reusability and improve the overall structure of the code.
 
* The `SignedUpTeam` class currently contains methods with multiple responsibilities, such as finding participants and teams, releasing topics, and removing signed-up teams. This violates the Single Responsibility Principle, making the class more challenging to understand and maintain. Separate these responsibilities for improved clarity.
 
* Some methods use complex SQL queries with multiple joins, which can be challenging to read and understand. Simplify these SQL queries by leveraging ActiveRecord's query interface to enhance readability and maintainability.
 
* The codebase has several instances of repeated code, such as finding signed-up teams for a given topic. This repetition violates the DRY principle, making the code harder to maintain and increasing the potential for errors. Consolidate these instances to streamline the code.


== Design Strategy ==
== 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.
* Implemented three model classes: `sign_up_team.rb`, `sign_up_topic.rb`, and `waitlist.rb` to address project requirements.
* sign_up_sheet.rb is removed because the class methods can be refactored into sign_up_topic.rb and waitlist.rb.
* Removed `sign_up_sheet.rb`; refactored its methods into `sign_up_topic.rb` and `waitlist.rb` for modularity.
* In sign_up_team.rb, the following functionality are being implemented:-
* Each model now has a focused role, improving maintainability and clarity.
* In signed_up_team.rb, the following functionality are being implemented:-
 
*;  
*;  
{| class="wikitable" style="margin-left:40px"
{| class="wikitable" style="margin-left:40px"
Line 35: Line 50:
! Method Name !! Status !! Description
! Method Name !! Status !! Description
|-
|-
| delete_team || TODO || It is responsible for deleting the team from the table and delegating any changes in topic.
| drop_off_team_waitlists || Implemented || Removes the team from all waitlists for topics within the assignment.
|-
| serialize_display ||  TODO || It is responsible for serializing content to JSON format.
|}
* Add necessary schema migrations for backward compatibility.
* In sign_up_topic.rb, the following functionality are being implemented:-
*;
{| class="wikitable" style="margin-left:40px"
|-
! Method Name !! Status !! Description
|-
| destroy_topic || TODO || It is used to destroy topic from the table.
|-
|-
| update_topic || TODO || It is used to modify the attributes like description, max_choosers or category in the table.
| find_first_existing_sign_up || Implemented || Finds the first existing sign-up entry for a given topic and team, checking for both active and waitlisted sign-ups.
|-
|-
| find_team_participants || TODO || It is used to retrieve participants assigned to the topic.
| create_signed_up_team || Implemented || Creates a SignedUpTeam instance with specified topic_id and team_id if the topic is available for sign-up.
|-
|-
| count_filled_slots || TODO || It is used to return the number of slots filled for the topic.
| get_team_id || Implemented || Retrieves the team ID associated with a given SignedUpTeam entry.
|-
|-
| count_available_slots || TODO || It is used to return the number of slots available for the topic.
| delete_signed_up_team || Implemented || Deletes the signed-up team entry for a specific topic, managing any dependent records as necessary.
|-
 
| release_topic || TODO || It is used to remove team from the topic and delegate changes to waitlist.
|-
| is_assigned_to_team || TODO || It is used to validate if the topic is assigned to the team
|-
| get_assigned_teams || TODO || It is used to retrieve teams assigned to the topic.
|-
| serialize_to_json || TODO || It is responsible for serializing content to JSON format.
|}
|}
 
* Add necessary schema migrations to rename signup topic to project topic.
* In waitlist.rb, the following functionality are yet to be implemented in next phase:-
* In project_topic.rb, the following functionality are being implemented:-
*;
*;
{| class="wikitable" style="margin-left:40px"
{| class="wikitable" style="margin-left:40px"
Line 71: Line 68:
! Method Name !! Status !! Description
! Method Name !! Status !! Description
|-
|-
| count_waitlisted_teams || TODO || It is used to return the number of waitlisted teams for the particular topic.
| slot_available? || Implemented || Checks if there are available slots for the topic based on the maximum allowed choosers. Returns true if available.
|-
|-
| remove_teams_from_waitlist || TODO || It is used to remove teams from the waitlist and return the removed teams.
| assign_topic_to_team || Implemented || Assigns the topic to a team by updating the sign-up entry to set is_waitlisted as false and assign the topic_id.
|-
|-
| add_teams_to_waitlist || TODO || It is used to add teams to the waitlist of the topic.
| save_waitlist_entry || Implemented || Saves a sign-up entry as a waitlist entry by setting is_waitlisted to true and assigning the topic_id.
|-
|-
| get_waitlisted_teams || TODO || It is used to retrieve the teams added to waitlist for the topic.
| sign_up_team || Implemented || Manages the sign-up process for a team, checking slot availability, assigning the topic, or placing the team on the waitlist as needed
|}
|}
* 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 responess.
* Add tests using ‘shoulda-matchers’ for more exhaustive tests as appropriate.
* Integrate ‘FactoryBot’ for automatic model record generation during testing.
* Add ‘preferene_priority_number’ for backward compatibility during migration.


== Flow Chart ==
Refactoring and Enhancements
[[File:Oss_proj3.drawio_(1).png]]
 
* Refactor instance methods to make them more concise (e.g., rename `slot_available?` to `available?`, `create_signed_up_team` to `sign_up_team`, `drop_off_team_waitlists` to `drop_team_waitlists`).
* Rename the model from “Sign Up Team” to “Signed Up Team” for improved clarity.
* Remove the `is_waitlisted` attribute, utilizing the `Waitlist` model for more efficient waitlist querying.
* Implement tests for error conditions and edge cases to ensure robust error handling.
* Add tests to validate the use of `@counter_cache`, ensuring accurate relation counts.
* Create any required empty models and define necessary model-association relations.
* Integrate waitlist management within `project_topic.rb`, delegating related functionalities to the `Waitlist` model.
* Add cascading delete functionality for related records across models to maintain data integrity.
* Include JSON serializers to format data for REST API responses.
* Use `shoulda-matchers` for comprehensive testing of model validations and associations.
* Integrate `FactoryBot` to automate model record generation in tests, improving test efficiency.
* Introduce `preference_priority_number` to maintain backward compatibility during migrations.
 
== E/R Diagram ==
[[File:oodd.png |1000px|center]]
<p style="text-align: center;">Edit Button Tooltip</p>


== Test Plan ==
== 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.
* Upgrade RSpec test cases for `signed_up_team.rb` to validate `delete_signed_up_team` and `get_team_participants` methods.
* Create RSpec test cases for waitlist.rb to validate adding teams to waitlist, remove teams from waitlist and query status of team's waitlist.
* Enhance and expand RSpec test cases for `project_topic.rb` to validate participant retrieval, slot availability, and assignment status handling.
* Add general RSpec test cases for error handling and validate JSON serialization.
* Develop RSpec test cases for `waitlist.rb` to validate adding teams to the waitlist, removing teams from the waitlist, and querying the waitlist status of a team.
* Test Cases for signup_team.rb model
* Add general RSpec test cases for error handling and ensure correct JSON serialization of data..
[[File:Test signup team1.png|900px]]
* Test Cases for signed_up_team.rb model
[[File:Signedup_team_rspec.png|900px]]
* Test Cases for waitlist.rb model
* Test Cases for waitlist.rb model
[[File:Test wait1.png|900px]]
[[File:Waitlist_rspec.png|900px]]
[[File:Test wait2.png|900px]]
* Test Cases for signup_topic.rb
[[File:Test wait3.png|900px]]
[[File:Signup_topic_rspec.png|900px]]
[[File:Test wait4.png|900px]]

Latest revision as of 02:05, 30 October 2024

Team Members

Project Description

The main goal of this project is to reimplement essential Ruby on Rails model classes—SignUpTeam, SignUpTopic, and SignUpSheet—from the Expertiza repository in a new repository. Each of these model classes plays a critical role in managing topics and team sign-ups within course assignments, and the reimplementation aims to bring them into alignment with Rails best practices and the DRY (Don't Repeat Yourself) principle.

The SignUpTeam model represents a team that has signed up for a specific topic within an assignment. This model manages team-specific data and oversees interactions that occur during the sign-up process. The SignUpTopic model, on the other hand, represents the topics available for sign-up within an assignment, managing essential details like slot availability and assigning teams to open topics. Lastly, the SignUpSheet class serves as a module, storing the methods needed to create and manage instances of SignUpTeam for assignment topics.

Since this project is being implemented from scratch, a range of components have been developed to ensure the functionality is both streamlined and maintainable. To guarantee the reliability of each part of the reimplementation, unit test cases have been created to verify the integrity of the new design and implementation.

Issue Description

  • Comprehensive RSpec tests are essential for all reimplemented models to ensure correctness and reliability in functionality.
  • Update all references from `sign_up_teams` to `signed_up_teams` throughout the codebase to maintain consistency with the new naming convention.
  • Address all code review feedback to improve code quality and alignment with best practices.
  • Currently, there is no specific waitlist model to manage waitlisting, upgrading, or handling multiple registrations. This functionality needs to be considered and integrated effectively.
  • Refactor methods with readability issues to make the code more maintainable and easier to understand.
  • Optimize ambiguous class and instance methods to enhance reusability and improve the overall structure of the code.
  • The `SignedUpTeam` class currently contains methods with multiple responsibilities, such as finding participants and teams, releasing topics, and removing signed-up teams. This violates the Single Responsibility Principle, making the class more challenging to understand and maintain. Separate these responsibilities for improved clarity.
  • Some methods use complex SQL queries with multiple joins, which can be challenging to read and understand. Simplify these SQL queries by leveraging ActiveRecord's query interface to enhance readability and maintainability.
  • The codebase has several instances of repeated code, such as finding signed-up teams for a given topic. This repetition violates the DRY principle, making the code harder to maintain and increasing the potential for errors. Consolidate these instances to streamline the code.

Design Strategy

  • Implemented three model classes: `sign_up_team.rb`, `sign_up_topic.rb`, and `waitlist.rb` to address project requirements.
  • Removed `sign_up_sheet.rb`; refactored its methods into `sign_up_topic.rb` and `waitlist.rb` for modularity.
  • Each model now has a focused role, improving maintainability and clarity.
  • In signed_up_team.rb, the following functionality are being implemented:-
Method Name Status Description
drop_off_team_waitlists Implemented Removes the team from all waitlists for topics within the assignment.
find_first_existing_sign_up Implemented Finds the first existing sign-up entry for a given topic and team, checking for both active and waitlisted sign-ups.
create_signed_up_team Implemented Creates a SignedUpTeam instance with specified topic_id and team_id if the topic is available for sign-up.
get_team_id Implemented Retrieves the team ID associated with a given SignedUpTeam entry.
delete_signed_up_team Implemented Deletes the signed-up team entry for a specific topic, managing any dependent records as necessary.
  • Add necessary schema migrations to rename signup topic to project topic.
  • In project_topic.rb, the following functionality are being implemented:-
Method Name Status Description
slot_available? Implemented Checks if there are available slots for the topic based on the maximum allowed choosers. Returns true if available.
assign_topic_to_team Implemented Assigns the topic to a team by updating the sign-up entry to set is_waitlisted as false and assign the topic_id.
save_waitlist_entry Implemented Saves a sign-up entry as a waitlist entry by setting is_waitlisted to true and assigning the topic_id.
sign_up_team Implemented Manages the sign-up process for a team, checking slot availability, assigning the topic, or placing the team on the waitlist as needed

Refactoring and Enhancements

  • Refactor instance methods to make them more concise (e.g., rename `slot_available?` to `available?`, `create_signed_up_team` to `sign_up_team`, `drop_off_team_waitlists` to `drop_team_waitlists`).
  • Rename the model from “Sign Up Team” to “Signed Up Team” for improved clarity.
  • Remove the `is_waitlisted` attribute, utilizing the `Waitlist` model for more efficient waitlist querying.
  • Implement tests for error conditions and edge cases to ensure robust error handling.
  • Add tests to validate the use of `@counter_cache`, ensuring accurate relation counts.
  • Create any required empty models and define necessary model-association relations.
  • Integrate waitlist management within `project_topic.rb`, delegating related functionalities to the `Waitlist` model.
  • Add cascading delete functionality for related records across models to maintain data integrity.
  • Include JSON serializers to format data for REST API responses.
  • Use `shoulda-matchers` for comprehensive testing of model validations and associations.
  • Integrate `FactoryBot` to automate model record generation in tests, improving test efficiency.
  • Introduce `preference_priority_number` to maintain backward compatibility during migrations.

E/R Diagram

Edit Button Tooltip

Test Plan

  • Upgrade RSpec test cases for `signed_up_team.rb` to validate `delete_signed_up_team` and `get_team_participants` methods.
  • Enhance and expand RSpec test cases for `project_topic.rb` to validate participant retrieval, slot availability, and assignment status handling.
  • Develop RSpec test cases for `waitlist.rb` to validate adding teams to the waitlist, removing teams from the waitlist, and querying the waitlist status of a team.
  • Add general RSpec test cases for error handling and ensure correct JSON serialization of data..
  • Test Cases for signed_up_team.rb model

  • Test Cases for waitlist.rb model

  • Test Cases for signup_topic.rb