CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 83: Line 83:
##Check waitlist empty for topic
##Check waitlist empty for topic
##Check if team has any waitlists  
##Check if team has any waitlists  
##Get the number of waitlisted teams for all topics in an assignment


===Refactoring and Design Patterns===
===Refactoring and Design Patterns===
Line 121: Line 122:
##team is deleted
##team is deleted
##student gets added to a new team, then the old team's waitlist should be dropped
##student gets added to a new team, then the old team's waitlist should be dropped
##Get the number of waitlisted teams for all topics in an assignment
 


=== RSpec Unit Tests ===
=== RSpec Unit Tests ===

Revision as of 22:43, 6 April 2022

Problem Statement

Whenever a team requests for a topic, there are two things that can happen.

The topic is available:

In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ).

The topic is unavailable:

In this case, the team is waitlisted for the topic. When any other team drops this topic, then a waitlisted team will be assigned for this topic.

Feature Overview

Issues with existing functionality

Overview of Major Changes

Proposed design and Plan of action

General Design Goals

UML Diagram

Class Diagram

Changes to the signed_up_teams Table

signed_up_teams table consists of a mapping of team_id, topic_id, is_waitlisted. This table was being used for multiple purposes, one to store the signed up teams and also the waitlisted teams for a topic.
We plan on retiring/removing the waitlist flag from the signed_up_teams table and separating this functionality.
All existing references to the is_waitlisted flag will be rewritten to make use of the new table.
Managing entries and enforcing constraints will be easier to implement and extend if required.

Files and methods to be refactored

  1. signed_up_team.rb
    1. All references to is_waitlisted should be removed and waitlists must be determined by using the new waitlist_team table.
  2. waitlist.rb
    1. This class must be scrapped away and we will use a separate helper class to add all the logic of waitlisting which will be called by other methods.
  3. sign_up_sheet_controller.rb
    1. switch_original_topic_to_approved_suggested_topic
      1. Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table
      2. Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.
  4. sign_up_sheet.rb
    1. cancel_all_wailists (typo in code) - This method currently does 2 things, it cancels waitlist and also updates the signed_up_team topic which needs to be split
    2. create_SignUpTeam
      1. It checks if topic has slots if yes it adds to signed up team, else creates a signup as waitlist
      2. This method should use the new table and call the helper functions of waitlist to perform actions on waitlists
  5. sign_up_topic.rb
    1. users_on_waiting_list - Move method to fetch all users on waitlist for a topic to waitlist_teams method.
    2. assign_to_first_waiting_team - The same functionality is being called in multiple places, it should be made DRY and moved to the waitlist_teams model
    3. reassign_topic - Use methods that perform actions on waitlist that should be moved to waitlist_helper, also use transactions to make it atomic.
    4. update_waitlisted_users - Move method to waitlist_teams model and use the new table
    5. find_slots_waitlisted - Move method to waitlist_teams model
    6. find_waitlisted_topics - Move method to waitlist_teams model
  6. suggestion_controller.rb
    1. notification
    2. Clean waitlist functionality should be moved to a method in waitlist_teams model. team id should be passed as a parameter to delete the waitlist for that team.
  7. invitation.rb
    1. remove_waitlists_for_team
      1. Removing from waitlist and adding to team to sign up should be as a single transaction
      2. There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet
      3. All functionality should be moved to waitlist_helper and implemented in a robust and dry manner

Adding new waitlist_teams Table

  1. Add a new table waitlist_teams
  2. The attributes for the table are team_id(refers to the teams table), topic_id (refers to the sign_up_topics table)
  3. This table only stores the waitlisted teams for each topic.
  4. The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.
  5. The waitlist_helper class will perform the following operations
    1. Delete all waitlists for team
    2. Purge all waitlists for topic
    3. Add team to waitlist
    4. Delete specific team from waitlist
    5. Get all waitlisted topics for team
    6. Get all waitlisted teams for topic
    7. Get first team in waitlist for topic
    8. Check waitlist empty for topic
    9. Check if team has any waitlists
    10. Get the number of waitlisted teams for all topics in an assignment

Refactoring and Design Patterns

Since our goal is to fix existing functionalities we will not be updating the existing design patterns being employed in the code. Yet, we would like to discuss what makes these refactoring important. Refactoring is a systematic process of improving code without creating new functionality. Thus, a key to the success of our project is ensuring everything that was working before our changes work even after our changes have been added. To ensure this, we will continue to test the system after each issue has been fixed. This will allow us to ensure two things:

  • We are only changing what we set out to change when fixing a particular issue.
  • We are not breaking what was working before we deployed our fix.

We believe at the end our changes will increase the quality of Expertiza and improve the experience for users an developers alike.

Migrating existing waitlists to use new table

Since the signed_up_teams table will no longer be used to store the waitlists we will move all the entries for waitlisted teams to the new table so that all the existing waitlists don't get affected.
We plan on writing a migration script to move the waitlists from signed_up_teams table to waitlist_teams table.
This will ensure minimal regression breakages and retain existing functionalities.

Specific Tasks Completed

will be added for the final submission

Implementation

will be added for the final submission

Testing

Video Demonstration

will be added for the final submission

Testing Goals and Test Objects

Drawing from the project objectives:

  1. Ways to get added to the waitlist for a topic
    1. Team requests a topic that has no slot available.
    2. When capacity/max choosers for a topic is increased
    3. When a student gets added to a team that already has a signed up topic
  2. Ways to get off a waitlist
    1. team gets the topic they are waiting for ( all other waitlists are dropped for the team)
    2. team drops off the waitlist
    3. instructor drops team from the waitlist
    4. a drop-topic deadline passes
    5. team is deleted
    6. student gets added to a new team, then the old team's waitlist should be dropped


RSpec Unit Tests

Test cases provided here, will add RSpec code blocks for the final submission

  • Student Waitlist
Scenario: Getting added to the waitlist for a topic 
 Given: Logged in as a Student
  When: The topic for an assignment has no available slots
   And: Student tries to signup for a topic
  Then: The team that the student is a part of should be added to the waitlist for the topic.
Scenario: Getting enrolled in a topic 
 Given: Logged in as a Student
  When: The topic for an assignment has available slots
   And: Student tries to signup for a topic
  Then: The team that the student is a part of should be enrolled for the topic.
Scenario: All waitlisted topics getting dropped
 Given: Logged in as a Student
  When: Student gets enrolled into a course for which he was waitlisted before.
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.
Scenario: All waitlisted teams getting dropped
 Given: Logged in as a Student
  When: The deadline for a topic passes.
  Then: All the waitlisted teams for that particular topic must be dropped.
Scenario: Getting enrolled in a topic
 Given: Logged in as a Student
  When: The enrolled team for a topic drops
  Then: The team that was waitlisted earlier for the topics must be enrolled.

Regression Testing

In order to ensure complete coverage, testing of the changes done between the end of last semester and this project will be done to ensure that old test cases still pass.

  1. Make sure all existing waitlist functionality still passes

Conclusions and Future Work

Comprehensive Testing and Scope

  • will be added for final submission

Conclusion

will be added for final submission

Useful Links

Pull request

Deployed application with changes

Forked repository

Contributors

Students

  • Krishna Saurabh Vankadaru (kvankad)
  • Samson Reddy Mulkur (smulkur)
  • Akhil Kumar Mengani (amengan)
  • Sai Naga Vamshi Chidara (schidar)

Mentor

  • Naman Shrimali (nshrima)