<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Amengan</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Amengan"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Amengan"/>
	<updated>2026-09-12T22:56:11Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=145296</id>
		<title>CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=145296"/>
		<updated>2022-04-25T23:44:41Z</updated>

		<summary type="html">&lt;p&gt;Amengan: /* Conclusions and Future Work */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
&lt;br /&gt;
Waitlist feature is utilized during subject assignment in an assignment. For example, during the topic allocation of the Final Project (and design doc), each team had the opportunity to sign up for a topic in which they were interested or to add to a waitlist of a topic in which they were not interested. When a team is added to the queue, many circumstances emerge. The waitlist feature currently does not adhere to the open-closed design paradigm. As a result, our task in this project is to resolve these issues by rewriting the waitlist functionality.&lt;br /&gt;
&lt;br /&gt;
Whenever a team requests for a topic, there are two things that can happen. &lt;br /&gt;
&lt;br /&gt;
* '''The topic is available''': In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ). This is pretty straightforward.&lt;br /&gt;
&lt;br /&gt;
* '''The topic is unavailable''': In this case, the team is waitlisted for the topic. When any other team drops this topic, a waitlisted team will be assigned for this topic. &lt;br /&gt;
&lt;br /&gt;
Our task is to simplify the way we are handling the second case. For each topic, we will have to have a waitlist object associated with it. If a team has requested for a topic that is not available, the team would just be queued on to the waitlist for this topic. In the waitlist object, we will have to maintain the team_id and the topic id for which this team will be waitlisted. In the current implementation, the waitlisting functionality is scattered across multiple files. All this has to be consolidated and placed in fewer number of places ( model file and helper class ).&lt;br /&gt;
&lt;br /&gt;
=== Issues with existing functionality ===&lt;br /&gt;
The current implementation has multiple models and controllers ( sign_up_topic.rb, waitlist.rb, invitation.rb, lottery_controller.rb, suggestion_controller.rb and signed_up_team.rb etc ) perform actions that indirectly affect the waitlist ( adding or removing teams from waitlist ). As a result, modifying the waitlist is being performed by multiple models and controllers. So, there is a lot of redundancy associated with basic waitlist operations in multiple files.&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
&lt;br /&gt;
To simplify waitlist functionality, to reduce code redundancy and to fix the Single-responsibility principle that is being violated, we will rewrite or move the functions/methods to multiple controllers and model files that manipulate waitlists of a topic. All these classes will now just invoke methods of waitlist.rb. The following files contains the waitlist functionality, so we plan to either refactor or add the functionality.&lt;br /&gt;
&lt;br /&gt;
1) ''signed_up_team.rb''&lt;br /&gt;
&lt;br /&gt;
2) ''waitlist.rb''&lt;br /&gt;
&lt;br /&gt;
3) ''sign_up_sheet_controller.rb''&lt;br /&gt;
&lt;br /&gt;
4) ''sign_up_sheet.rb''&lt;br /&gt;
&lt;br /&gt;
5) ''sign_up_topic.rb''&lt;br /&gt;
&lt;br /&gt;
6) ''suggestion_controller.rb''&lt;br /&gt;
&lt;br /&gt;
7) ''invitation.rb''&lt;br /&gt;
&lt;br /&gt;
== Proposed design ==&lt;br /&gt;
&lt;br /&gt;
=== General Design Goals ===&lt;br /&gt;
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 be testing the existing features so that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
Our goal is to make the experiza system more reliable and have code that is consistent with the standards of object-oriented design.&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
In this Unified Modeling Language (UML), we summarize the details of the system's users and their interactions with the system. &amp;lt;br&amp;gt;&lt;br /&gt;
We have two users to the system '''Student''' and '''Instructor'''. The interactions these users have with the system are stated below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Student Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. Student should be able to perform an action to add their own team to the waitlist.  &amp;lt;br&amp;gt;&lt;br /&gt;
2. Student should be able to drop their own team from the waitlist but not others team.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Instructor Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1.  Delete or purge on the waitlist items are those actions that have to be performed by the instructor/admin and student should not be given access to delete action.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Instructor should be able to add any team to the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Instructor should be able to drop any team from the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
4. Instructor should be able to fetch the details of the teams in a waitlist for a particular topic.&amp;lt;br&amp;gt;&lt;br /&gt;
5. Instructor should be able to fetch the details of the topics in which a team is waitlisted. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_uml_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
Tables associated with '''waitlist_teams''' table are&amp;lt;br&amp;gt;&lt;br /&gt;
1. teams&amp;lt;br&amp;gt;&lt;br /&gt;
2. signed_up_teams&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
waitlist_teams table is referred by the signed_up_teams and teams table as Foreign Key Relationship.&lt;br /&gt;
&lt;br /&gt;
'''team_id''' : foreign key in waitlists_team table which is a reference to the teams table &amp;lt;br&amp;gt;&lt;br /&gt;
'''topic_id''' : foreign key in waitlists_team table which is a reference to the signed_up_teams table &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These relationships along with the attributes of the classes are depicted in the class diagram below.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Waitlists_class_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
== Plan of action ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we will be doing in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Update the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactoring files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Add new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrate the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Add/Move the business logic to ''waitlist_teams.rb'' file&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 1.Changes to the signed_up_teams Table ===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
We plan on retiring/removing the waitlist flag from the signed_up_teams table and separating this functionality. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag will be rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods to be refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag should be removed and waitlists must be determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##This class must be scrapped away and we will use a separate model class 'WaitlistTeam' which will contain the business logic for managing and modifying waitlisted teams. We also plan on using a helper class 'WaitlistTeamHelper' to add the logic of waitlisting which is called in multiple places across the code. The helper class will help avoid redundant code and make sure the code is implemented in a DRY manner. &lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##switch_original_topic_to_approved_suggested_topic&lt;br /&gt;
###Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table&lt;br /&gt;
###Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##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&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
###It checks if topic has slots if yes it adds to signed up team, else creates a signup as waitlist&lt;br /&gt;
###This method should use the new table and call the helper functions of waitlist to perform actions on waitlists&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Move method to fetch all users on waitlist for a topic to waitlist_teams method.&lt;br /&gt;
##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&lt;br /&gt;
##reassign_topic - Use methods that perform actions on waitlist that should be moved to waitlist_helper, also use transactions to make it atomic.&lt;br /&gt;
##update_waitlisted_users - Move method to waitlist_teams model and use the new table&lt;br /&gt;
##find_slots_waitlisted - Move method to waitlist_teams model&lt;br /&gt;
##find_waitlisted_topics - Move method to waitlist_teams model&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification&lt;br /&gt;
##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.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team&lt;br /&gt;
###Removing from waitlist and adding to team to sign up should be as a single transaction&lt;br /&gt;
###There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet&lt;br /&gt;
###All functionality should be moved to waitlist_helper and implemented in a robust and dry manner&lt;br /&gt;
&lt;br /&gt;
===3. Adding new waitlist_teams Table ===&lt;br /&gt;
We plan to add a new table ''waitlist_teams''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The attributes for the table are team_id(refers to the ''teams'' table), topic_id (refers to the ''sign_up_topics'' table)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This table only stores the waitlisted teams for each topic.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Having separated tables for signups and waitlists will help in managing entries and enforcing constraints and make it easier to implement and extend functionality if required.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
The waitlist_helper class will perform the following operations &lt;br /&gt;
#Delete all waitlists for team&lt;br /&gt;
#Purge all waitlists for topic &lt;br /&gt;
#Add team to waitlist&lt;br /&gt;
#Delete specific team from waitlist&lt;br /&gt;
#Get all waitlisted topics for team&lt;br /&gt;
#Get all waitlisted teams for topic&lt;br /&gt;
#Get first team in waitlist for topic&lt;br /&gt;
#Check waitlist empty for topic&lt;br /&gt;
#Check if team has any waitlists &lt;br /&gt;
#Get the number of waitlisted teams for all topics in an assignment&lt;br /&gt;
&lt;br /&gt;
=== 4. Migrating existing waitlists to use new table===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt; &lt;br /&gt;
We plan on writing a migration script to move the waitlists from signed_up_teams table to waitlist_teams table.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This will ensure minimal regression breakages and retain existing functionalities.&lt;br /&gt;
=== 5. Specific Tasks Completed ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
'''1. Adding Waitlist Teams Table, Validations and Model file:''' &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/1/files (Adding waitlist_teams table) &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/2/files (Migration script changes to add unique constraint on waitlist_teams table and remove id column) &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/4/files (Schema changes) &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/3/files (Validations)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''2. Migration Scripts''' &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/10/files (Migrate existing data in signed_up_teams to waitlist_teams) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''3. Business Logic Changes''' &amp;lt;br&amp;gt;&lt;br /&gt;
Adding new methods for add, delete, signup of waitlist teams in WaitlistTeam.rb.&amp;lt;br&amp;gt;&lt;br /&gt;
Changes to existing method calls in model files&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/5/files (WaitlistTeam model methods like CRUD etc) &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/11/files (Methods to handle deletion cases) &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/12 (Check if team is waitlisted before a topic signup) &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/13 (Release waitlist and signup when a user joins another team and there are no other users in the old team) &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/14/files (Synchronize waitlist features in other files) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''4. RSpec''' &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/13 (RSpec changes to test model methods) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
=== Video Demonstration ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
=== Testing Goals and Test Objects ===&lt;br /&gt;
&lt;br /&gt;
''Drawing from the project objectives:''&lt;br /&gt;
#Ways to get added to the waitlist for a topic&lt;br /&gt;
##Team requests a topic that has no slot available.&lt;br /&gt;
##When capacity/max choosers for a topic is increased&lt;br /&gt;
##When a student gets added to a team that already has a signed up topic&lt;br /&gt;
#Ways to get off a waitlist&lt;br /&gt;
##team gets the topic they are waiting for ( all other waitlists are dropped for the team)&lt;br /&gt;
##team drops off the waitlist&lt;br /&gt;
##instructor drops team from the waitlist&lt;br /&gt;
##a drop-topic deadline passes&lt;br /&gt;
##team is deleted&lt;br /&gt;
##student gets added to a new team, then the old team's waitlist should be dropped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RSpec Unit Tests ===&lt;br /&gt;
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''&lt;br /&gt;
*Student Waitlist&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting added to the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has no available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be added to the waitlist for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be enrolled for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted topics getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: Student gets enrolled into a course for which he was waitlisted before.&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted teams getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The deadline for a topic passes.&lt;br /&gt;
  Then: All the waitlisted teams for that particular topic must be dropped.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The enrolled team for a topic drops&lt;br /&gt;
  Then: The team that was waitlisted earlier for the topics must be enrolled.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
'''Student's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Student_waitlist_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Instructor's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_signup_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''Instructor's View With Waitlists'''&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlist.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Test 1:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to add their team to the waitlist by clicking on '''Check''' icon (see the image above) if the team has not signed up in any topic.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 2:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to drop the team from the waitlist by clicking on '''Delete''' icon (see the image above) if they are no longer interested in it.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 3:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to add a student to the topic by clicking on '''Check''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 4:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to delete a student to the topic by clicking on '''Delete''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 5:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the students signup for a topic in the page displayed. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 6:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the topics available &lt;br /&gt;
&lt;br /&gt;
''' Test 7:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view waitlisted and signed up teams for all the topics in the assignment&lt;br /&gt;
&lt;br /&gt;
''' Test 8:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to drop waitlisted team for a topics in the assignment&lt;br /&gt;
&lt;br /&gt;
we will be adding more test cases as the project progress.&lt;br /&gt;
&lt;br /&gt;
=== Regression Testing ===&lt;br /&gt;
''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 ''&lt;br /&gt;
''old test cases still pass.''&lt;br /&gt;
&lt;br /&gt;
# Make sure all existing waitlist functionality still passes&lt;br /&gt;
&lt;br /&gt;
== Conclusions and Future Work ==&lt;br /&gt;
=== Comprehensive Testing and Scope ===&lt;br /&gt;
* ''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
'''Conclusion:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Following is the summary of what we have done in this project so far:&amp;lt;br&amp;gt;&lt;br /&gt;
1. Adding new table waitlist_teams to store waitlist teams for a topic and migration script for transferring the waitlist data from signed_up_teams.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Changed the existing functionality to store the new waitlists data in this new table&amp;lt;br&amp;gt;&lt;br /&gt;
3. Existing waitlist business logic implementation is not in waitlist model class so we created a new model file and rewritten the code for waitlist functionality.&amp;lt;br&amp;gt;&lt;br /&gt;
4. There are number of methods in other model classes which are referencing waitlist functionality. We have changed all those references to the new methods that we have implemented.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Future Work:'''&amp;lt;br&amp;gt;&lt;br /&gt;
1. We created a new table that will store the team in waitlist for a topic. Earlier there was only table (signed_up_teams) to keep track of signed up teams and waitlist teams. This table has is_waitlist column to figure out if the entry is for a sign up or waitlist. With the Introduction of new table for waitlist_teams this column now seems unreasonable and it will not impact the functionality. Though we have script to migrate the existing waitlist data to new table, the column is_waitlist is not removed yet. Teams working on it further can work on it and remove all the references of is_waitlist column. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Teams can work on writing more test cases for waitlist functionality because there are various flows in which this functionality is touched Examples: Accept Invitation, Leaving team etc.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
Pull request&lt;br /&gt;
&lt;br /&gt;
Deployed application with changes&lt;br /&gt;
&lt;br /&gt;
Forked repository&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
=== Students ===&lt;br /&gt;
*Krishna Saurabh Vankadaru (''kvankad'')&lt;br /&gt;
*Samson Reddy Mulkur (''smulkur'')&lt;br /&gt;
*Akhil Kumar Mengani (''amengan'')&lt;br /&gt;
*Sai Naga Vamshi Chidara (''schidar'')&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
*Naman Shrimali (''nshrima'')&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=145250</id>
		<title>CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=145250"/>
		<updated>2022-04-25T21:46:04Z</updated>

		<summary type="html">&lt;p&gt;Amengan: /* Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
&lt;br /&gt;
Waitlist feature is utilized during subject assignment in an assignment. For example, during the topic allocation of the Final Project (and design doc), each team had the opportunity to sign up for a topic in which they were interested or to add to a waitlist of a topic in which they were not interested. When a team is added to the queue, many circumstances emerge. The waitlist feature currently does not adhere to the open-closed design paradigm. As a result, our task in this project is to resolve these issues by rewriting the waitlist functionality.&lt;br /&gt;
&lt;br /&gt;
Whenever a team requests for a topic, there are two things that can happen. &lt;br /&gt;
&lt;br /&gt;
* '''The topic is available''': In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ). This is pretty straightforward.&lt;br /&gt;
&lt;br /&gt;
* '''The topic is unavailable''': In this case, the team is waitlisted for the topic. When any other team drops this topic, a waitlisted team will be assigned for this topic. &lt;br /&gt;
&lt;br /&gt;
Our task is to simplify the way we are handling the second case. For each topic, we will have to have a waitlist object associated with it. If a team has requested for a topic that is not available, the team would just be queued on to the waitlist for this topic. In the waitlist object, we will have to maintain the team_id and the topic id for which this team will be waitlisted. In the current implementation, the waitlisting functionality is scattered across multiple files. All this has to be consolidated and placed in fewer number of places ( model file and helper class ).&lt;br /&gt;
&lt;br /&gt;
=== Issues with existing functionality ===&lt;br /&gt;
The current implementation has multiple models and controllers ( sign_up_topic.rb, waitlist.rb, invitation.rb, lottery_controller.rb, suggestion_controller.rb and signed_up_team.rb etc ) perform actions that indirectly affect the waitlist ( adding or removing teams from waitlist ). As a result, modifying the waitlist is being performed by multiple models and controllers. So, there is a lot of redundancy associated with basic waitlist operations in multiple files.&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
&lt;br /&gt;
To simplify waitlist functionality, to reduce code redundancy and to fix the Single-responsibility principle that is being violated, we will rewrite or move the functions/methods to multiple controllers and model files that manipulate waitlists of a topic. All these classes will now just invoke methods of waitlist.rb. The following files contains the waitlist functionality, so we plan to either refactor or add the functionality.&lt;br /&gt;
&lt;br /&gt;
1) ''signed_up_team.rb''&lt;br /&gt;
&lt;br /&gt;
2) ''waitlist.rb''&lt;br /&gt;
&lt;br /&gt;
3) ''sign_up_sheet_controller.rb''&lt;br /&gt;
&lt;br /&gt;
4) ''sign_up_sheet.rb''&lt;br /&gt;
&lt;br /&gt;
5) ''sign_up_topic.rb''&lt;br /&gt;
&lt;br /&gt;
6) ''suggestion_controller.rb''&lt;br /&gt;
&lt;br /&gt;
7) ''invitation.rb''&lt;br /&gt;
&lt;br /&gt;
== Proposed design ==&lt;br /&gt;
&lt;br /&gt;
=== General Design Goals ===&lt;br /&gt;
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 be testing the existing features so that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
Our goal is to make the experiza system more reliable and have code that is consistent with the standards of object-oriented design.&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
In this Unified Modeling Language (UML), we summarize the details of the system's users and their interactions with the system. &amp;lt;br&amp;gt;&lt;br /&gt;
We have two users to the system '''Student''' and '''Instructor'''. The interactions these users have with the system are stated below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Student Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. Student should be able to perform an action to add their own team to the waitlist.  &amp;lt;br&amp;gt;&lt;br /&gt;
2. Student should be able to drop their own team from the waitlist but not others team.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Instructor Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1.  Delete or purge on the waitlist items are those actions that have to be performed by the instructor/admin and student should not be given access to delete action.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Instructor should be able to add any team to the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Instructor should be able to drop any team from the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
4. Instructor should be able to fetch the details of the teams in a waitlist for a particular topic.&amp;lt;br&amp;gt;&lt;br /&gt;
5. Instructor should be able to fetch the details of the topics in which a team is waitlisted. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_uml_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
Tables associated with '''waitlist_teams''' table are&amp;lt;br&amp;gt;&lt;br /&gt;
1. teams&amp;lt;br&amp;gt;&lt;br /&gt;
2. signed_up_teams&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
waitlist_teams table is referred by the signed_up_teams and teams table as Foreign Key Relationship.&lt;br /&gt;
&lt;br /&gt;
'''team_id''' : foreign key in waitlists_team table which is a reference to the teams table &amp;lt;br&amp;gt;&lt;br /&gt;
'''topic_id''' : foreign key in waitlists_team table which is a reference to the signed_up_teams table &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These relationships along with the attributes of the classes are depicted in the class diagram below.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Waitlists_class_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
== Plan of action ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we will be doing in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Update the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactoring files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Add new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrate the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Add/Move the business logic to ''waitlist_teams.rb'' file&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 1.Changes to the signed_up_teams Table ===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
We plan on retiring/removing the waitlist flag from the signed_up_teams table and separating this functionality. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag will be rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods to be refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag should be removed and waitlists must be determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##This class must be scrapped away and we will use a separate model class 'WaitlistTeam' which will contain the business logic for managing and modifying waitlisted teams. We also plan on using a helper class 'WaitlistTeamHelper' to add the logic of waitlisting which is called in multiple places across the code. The helper class will help avoid redundant code and make sure the code is implemented in a DRY manner. &lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##switch_original_topic_to_approved_suggested_topic&lt;br /&gt;
###Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table&lt;br /&gt;
###Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##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&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
###It checks if topic has slots if yes it adds to signed up team, else creates a signup as waitlist&lt;br /&gt;
###This method should use the new table and call the helper functions of waitlist to perform actions on waitlists&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Move method to fetch all users on waitlist for a topic to waitlist_teams method.&lt;br /&gt;
##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&lt;br /&gt;
##reassign_topic - Use methods that perform actions on waitlist that should be moved to waitlist_helper, also use transactions to make it atomic.&lt;br /&gt;
##update_waitlisted_users - Move method to waitlist_teams model and use the new table&lt;br /&gt;
##find_slots_waitlisted - Move method to waitlist_teams model&lt;br /&gt;
##find_waitlisted_topics - Move method to waitlist_teams model&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification&lt;br /&gt;
##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.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team&lt;br /&gt;
###Removing from waitlist and adding to team to sign up should be as a single transaction&lt;br /&gt;
###There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet&lt;br /&gt;
###All functionality should be moved to waitlist_helper and implemented in a robust and dry manner&lt;br /&gt;
&lt;br /&gt;
===3. Adding new waitlist_teams Table ===&lt;br /&gt;
We plan to add a new table ''waitlist_teams''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The attributes for the table are team_id(refers to the ''teams'' table), topic_id (refers to the ''sign_up_topics'' table)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This table only stores the waitlisted teams for each topic.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Having separated tables for signups and waitlists will help in managing entries and enforcing constraints and make it easier to implement and extend functionality if required.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
The waitlist_helper class will perform the following operations &lt;br /&gt;
#Delete all waitlists for team&lt;br /&gt;
#Purge all waitlists for topic &lt;br /&gt;
#Add team to waitlist&lt;br /&gt;
#Delete specific team from waitlist&lt;br /&gt;
#Get all waitlisted topics for team&lt;br /&gt;
#Get all waitlisted teams for topic&lt;br /&gt;
#Get first team in waitlist for topic&lt;br /&gt;
#Check waitlist empty for topic&lt;br /&gt;
#Check if team has any waitlists &lt;br /&gt;
#Get the number of waitlisted teams for all topics in an assignment&lt;br /&gt;
&lt;br /&gt;
=== 4. Migrating existing waitlists to use new table===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt; &lt;br /&gt;
We plan on writing a migration script to move the waitlists from signed_up_teams table to waitlist_teams table.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This will ensure minimal regression breakages and retain existing functionalities.&lt;br /&gt;
=== 5. Specific Tasks Completed ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
'''1. Adding Waitlist Teams Table, Validations and Model file:''' &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/1/files (Adding waitlist_teams table) &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/2/files (Migration script changes to add unique constraint on waitlist_teams table and remove id column) &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/4/files (Schema changes) &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/3/files (Validations)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''2. Migration Scripts''' &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/10/files (Migrate existing data in signed_up_teams to waitlist_teams) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''3. Business Logic Changes''' &amp;lt;br&amp;gt;&lt;br /&gt;
Adding new methods for add, delete, signup of waitlist teams in WaitlistTeam.rb.&amp;lt;br&amp;gt;&lt;br /&gt;
Changes to existing method calls in model files&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/5/files (WaitlistTeam model methods like CRUD etc) &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/11/files (Methods to handle deletion cases) &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/12 (Check if team is waitlisted before a topic signup) &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/13 (Release waitlist and signup when a user joins another team and there are no other users in the old team) &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/14/files (Synchronize waitlist features in other files) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''4. RSpec''' &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/akhilkumarmengani/expertiza/pull/13 (RSpec changes to test model methods) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
=== Video Demonstration ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
=== Testing Goals and Test Objects ===&lt;br /&gt;
&lt;br /&gt;
''Drawing from the project objectives:''&lt;br /&gt;
#Ways to get added to the waitlist for a topic&lt;br /&gt;
##Team requests a topic that has no slot available.&lt;br /&gt;
##When capacity/max choosers for a topic is increased&lt;br /&gt;
##When a student gets added to a team that already has a signed up topic&lt;br /&gt;
#Ways to get off a waitlist&lt;br /&gt;
##team gets the topic they are waiting for ( all other waitlists are dropped for the team)&lt;br /&gt;
##team drops off the waitlist&lt;br /&gt;
##instructor drops team from the waitlist&lt;br /&gt;
##a drop-topic deadline passes&lt;br /&gt;
##team is deleted&lt;br /&gt;
##student gets added to a new team, then the old team's waitlist should be dropped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RSpec Unit Tests ===&lt;br /&gt;
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''&lt;br /&gt;
*Student Waitlist&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting added to the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has no available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be added to the waitlist for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be enrolled for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted topics getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: Student gets enrolled into a course for which he was waitlisted before.&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted teams getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The deadline for a topic passes.&lt;br /&gt;
  Then: All the waitlisted teams for that particular topic must be dropped.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The enrolled team for a topic drops&lt;br /&gt;
  Then: The team that was waitlisted earlier for the topics must be enrolled.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
'''Student's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Student_waitlist_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Instructor's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_signup_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''Instructor's View With Waitlists'''&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlist.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Test 1:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to add their team to the waitlist by clicking on '''Check''' icon (see the image above) if the team has not signed up in any topic.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 2:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to drop the team from the waitlist by clicking on '''Delete''' icon (see the image above) if they are no longer interested in it.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 3:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to add a student to the topic by clicking on '''Check''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 4:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to delete a student to the topic by clicking on '''Delete''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 5:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the students signup for a topic in the page displayed. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 6:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the topics available &lt;br /&gt;
&lt;br /&gt;
''' Test 7:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view waitlisted and signed up teams for all the topics in the assignment&lt;br /&gt;
&lt;br /&gt;
''' Test 8:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to drop waitlisted team for a topics in the assignment&lt;br /&gt;
&lt;br /&gt;
we will be adding more test cases as the project progress.&lt;br /&gt;
&lt;br /&gt;
=== Regression Testing ===&lt;br /&gt;
''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 ''&lt;br /&gt;
''old test cases still pass.''&lt;br /&gt;
&lt;br /&gt;
# Make sure all existing waitlist functionality still passes&lt;br /&gt;
&lt;br /&gt;
== Conclusions and Future Work ==&lt;br /&gt;
=== Comprehensive Testing and Scope ===&lt;br /&gt;
* ''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
Pull request&lt;br /&gt;
&lt;br /&gt;
Deployed application with changes&lt;br /&gt;
&lt;br /&gt;
Forked repository&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
=== Students ===&lt;br /&gt;
*Krishna Saurabh Vankadaru (''kvankad'')&lt;br /&gt;
*Samson Reddy Mulkur (''smulkur'')&lt;br /&gt;
*Akhil Kumar Mengani (''amengan'')&lt;br /&gt;
*Sai Naga Vamshi Chidara (''schidar'')&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
*Naman Shrimali (''nshrima'')&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144881</id>
		<title>CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144881"/>
		<updated>2022-04-12T02:25:34Z</updated>

		<summary type="html">&lt;p&gt;Amengan: /* Plan of action */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
&lt;br /&gt;
Waitlist feature is utilized during subject assignment in an assignment. For example, during the topic allocation of the Final Project (and design doc), each team had the opportunity to sign up for a topic in which they were interested or to add to a waitlist of a topic in which they were not interested. When a team is added to the queue, many circumstances emerge. The waitlist feature currently does not adhere to the open-closed design paradigm. As a result, our task in this project is to resolve these issues by rewriting the waitlist functionality.&lt;br /&gt;
&lt;br /&gt;
Whenever a team requests for a topic, there are two things that can happen. &lt;br /&gt;
&lt;br /&gt;
* '''The topic is available''': In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ). This is pretty straightforward.&lt;br /&gt;
&lt;br /&gt;
* '''The topic is unavailable''': In this case, the team is waitlisted for the topic. When any other team drops this topic, a waitlisted team will be assigned for this topic. &lt;br /&gt;
&lt;br /&gt;
Our task is to simplify the way we are handling the second case. For each topic, we will have to have a waitlist object associated with it. If a team has requested for a topic that is not available, the team would just be queued on to the waitlist for this topic. In the waitlist object, we will have to maintain the team_id and the topic id for which this team will be waitlisted. In the current implementation, the waitlisting functionality is scattered across multiple files. All this has to be consolidated and placed in fewer number of places ( model file and helper class ).&lt;br /&gt;
&lt;br /&gt;
=== Issues with existing functionality ===&lt;br /&gt;
The current implementation has multiple models and controllers ( sign_up_topic.rb, waitlist.rb, invitation.rb, lottery_controller.rb, suggestion_controller.rb and signed_up_team.rb etc ) perform actions that indirectly affect the waitlist ( adding or removing teams from waitlist ). As a result, modifying the waitlist is being performed by multiple models and controllers. So, there is a lot of redundancy associated with basic waitlist operations in multiple files.&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
&lt;br /&gt;
To simplify waitlist functionality, to reduce code redundancy and to fix the Single-responsibility principle that is being violated, we will rewrite or move the functions/methods to multiple controllers and model files that manipulate waitlists of a topic. All these classes will now just invoke methods of waitlist.rb. The following files contains the waitlist functionality, so we plan to either refactor or add the functionality.&lt;br /&gt;
&lt;br /&gt;
1) ''signed_up_team.rb''&lt;br /&gt;
&lt;br /&gt;
2) ''waitlist.rb''&lt;br /&gt;
&lt;br /&gt;
3) ''sign_up_sheet_controller.rb''&lt;br /&gt;
&lt;br /&gt;
4) ''sign_up_sheet.rb''&lt;br /&gt;
&lt;br /&gt;
5) ''sign_up_topic.rb''&lt;br /&gt;
&lt;br /&gt;
6) ''suggestion_controller.rb''&lt;br /&gt;
&lt;br /&gt;
7) ''invitation.rb''&lt;br /&gt;
&lt;br /&gt;
== Proposed design ==&lt;br /&gt;
&lt;br /&gt;
=== General Design Goals ===&lt;br /&gt;
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 be testing the existing features so that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
Our goal is to make the experiza system more reliable and have code that is consistent with the standards of object-oriented design.&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
In this Unified Modeling Language (UML), we summarize the details of the system's users and their interactions with the system. &amp;lt;br&amp;gt;&lt;br /&gt;
We have two users to the system '''Student''' and '''Instructor'''. The interactions these users have with the system are stated below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Student Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. Student should be able to perform an action to add their own team to the waitlist.  &amp;lt;br&amp;gt;&lt;br /&gt;
2. Student should be able to drop their own team from the waitlist but not others team.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Instructor Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1.  Delete or purge on the waitlist items are those actions that have to be performed by the instructor/admin and student should not be given access to delete action.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Instructor should be able to add any team to the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Instructor should be able to drop any team from the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
4. Instructor should be able to fetch the details of the teams in a waitlist for a particular topic.&amp;lt;br&amp;gt;&lt;br /&gt;
5. Instructor should be able to fetch the details of the topics in which a team is waitlisted. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_uml_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
Tables associated with '''waitlist_teams''' table are&amp;lt;br&amp;gt;&lt;br /&gt;
1. teams&amp;lt;br&amp;gt;&lt;br /&gt;
2. signed_up_teams&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
waitlist_teams table is referred by the signed_up_teams and teams table as Foreign Key Relationship.&lt;br /&gt;
&lt;br /&gt;
'''team_id''' : foreign key in waitlists_team table which is a reference to the teams table &amp;lt;br&amp;gt;&lt;br /&gt;
'''topic_id''' : foreign key in waitlists_team table which is a reference to the signed_up_teams table &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These relationships along with the attributes of the classes are depicted in the class diagram below.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Waitlists_class_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
== Plan of action ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we will be doing in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Update the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactoring files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Add new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrate the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Add/Move the business logic to ''waitlist_teams.rb'' file&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 1.Changes to the signed_up_teams Table ===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
We plan on retiring/removing the waitlist flag from the signed_up_teams table and separating this functionality. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag will be rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods to be refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to is_waitlisted should be removed and waitlists must be determined by using the new waitlist_team table.&lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##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. &lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##switch_original_topic_to_approved_suggested_topic&lt;br /&gt;
###Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table&lt;br /&gt;
###Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##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&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
###It checks if topic has slots if yes it adds to signed up team, else creates a signup as waitlist&lt;br /&gt;
###This method should use the new table and call the helper functions of waitlist to perform actions on waitlists&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Move method to fetch all users on waitlist for a topic to waitlist_teams method.&lt;br /&gt;
##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&lt;br /&gt;
##reassign_topic - Use methods that perform actions on waitlist that should be moved to waitlist_helper, also use transactions to make it atomic.&lt;br /&gt;
##update_waitlisted_users - Move method to waitlist_teams model and use the new table&lt;br /&gt;
##find_slots_waitlisted - Move method to waitlist_teams model&lt;br /&gt;
##find_waitlisted_topics - Move method to waitlist_teams model&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification&lt;br /&gt;
##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.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team&lt;br /&gt;
###Removing from waitlist and adding to team to sign up should be as a single transaction&lt;br /&gt;
###There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet&lt;br /&gt;
###All functionality should be moved to waitlist_helper and implemented in a robust and dry manner&lt;br /&gt;
&lt;br /&gt;
===3. Adding new waitlist_teams Table ===&lt;br /&gt;
We plan to add a new table ''waitlist_teams''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The attributes for the table are team_id(refers to the ''teams'' table), topic_id (refers to the ''sign_up_topics'' table)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This table only stores the waitlisted teams for each topic.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Having separated tables for signups and waitlists will help in managing entries and enforcing constraints and make it easier to implement and extend functionality if required.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
The waitlist_helper class will perform the following operations &lt;br /&gt;
#Delete all waitlists for team&lt;br /&gt;
#Purge all waitlists for topic &lt;br /&gt;
#Add team to waitlist&lt;br /&gt;
#Delete specific team from waitlist&lt;br /&gt;
#Get all waitlisted topics for team&lt;br /&gt;
#Get all waitlisted teams for topic&lt;br /&gt;
#Get first team in waitlist for topic&lt;br /&gt;
#Check waitlist empty for topic&lt;br /&gt;
#Check if team has any waitlists &lt;br /&gt;
#Get the number of waitlisted teams for all topics in an assignment&lt;br /&gt;
&lt;br /&gt;
=== 4. Migrating existing waitlists to use new table===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt; &lt;br /&gt;
We plan on writing a migration script to move the waitlists from signed_up_teams table to waitlist_teams table.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This will ensure minimal regression breakages and retain existing functionalities.&lt;br /&gt;
=== 5. Specific Tasks Completed ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
=== Video Demonstration ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
=== Testing Goals and Test Objects ===&lt;br /&gt;
&lt;br /&gt;
''Drawing from the project objectives:''&lt;br /&gt;
#Ways to get added to the waitlist for a topic&lt;br /&gt;
##Team requests a topic that has no slot available.&lt;br /&gt;
##When capacity/max choosers for a topic is increased&lt;br /&gt;
##When a student gets added to a team that already has a signed up topic&lt;br /&gt;
#Ways to get off a waitlist&lt;br /&gt;
##team gets the topic they are waiting for ( all other waitlists are dropped for the team)&lt;br /&gt;
##team drops off the waitlist&lt;br /&gt;
##instructor drops team from the waitlist&lt;br /&gt;
##a drop-topic deadline passes&lt;br /&gt;
##team is deleted&lt;br /&gt;
##student gets added to a new team, then the old team's waitlist should be dropped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RSpec Unit Tests ===&lt;br /&gt;
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''&lt;br /&gt;
*Student Waitlist&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting added to the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has no available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be added to the waitlist for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be enrolled for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted topics getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: Student gets enrolled into a course for which he was waitlisted before.&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted teams getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The deadline for a topic passes.&lt;br /&gt;
  Then: All the waitlisted teams for that particular topic must be dropped.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The enrolled team for a topic drops&lt;br /&gt;
  Then: The team that was waitlisted earlier for the topics must be enrolled.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
'''Student's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Student_waitlist_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Instructor's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_signup_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''Instructor's View With Waitlists'''&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlist.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Test 1:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to add their team to the waitlist by clicking on '''Check''' icon (see the image above) if the team has not signed up in any topic.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 2:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to drop the team from the waitlist by clicking on '''Delete''' icon (see the image above) if they are no longer interested in it.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 3:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to add a student to the topic by clicking on '''Check''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 4:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to delete a student to the topic by clicking on '''Delete''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 5:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the students signup for a topic in the page displayed. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 6:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the topics available &lt;br /&gt;
&lt;br /&gt;
''' Test 7:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view waitlisted and signed up teams for all the topics in the assignment&lt;br /&gt;
&lt;br /&gt;
''' Test 8:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to drop waitlisted team for a topics in the assignment&lt;br /&gt;
&lt;br /&gt;
we will be adding more test cases as the project progress.&lt;br /&gt;
&lt;br /&gt;
=== Regression Testing ===&lt;br /&gt;
''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 ''&lt;br /&gt;
''old test cases still pass.''&lt;br /&gt;
&lt;br /&gt;
# Make sure all existing waitlist functionality still passes&lt;br /&gt;
&lt;br /&gt;
== Conclusions and Future Work ==&lt;br /&gt;
=== Comprehensive Testing and Scope ===&lt;br /&gt;
* ''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
Pull request&lt;br /&gt;
&lt;br /&gt;
Deployed application with changes&lt;br /&gt;
&lt;br /&gt;
Forked repository&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
=== Students ===&lt;br /&gt;
*Krishna Saurabh Vankadaru (''kvankad'')&lt;br /&gt;
*Samson Reddy Mulkur (''smulkur'')&lt;br /&gt;
*Akhil Kumar Mengani (''amengan'')&lt;br /&gt;
*Sai Naga Vamshi Chidara (''schidar'')&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
*Naman Shrimali (''nshrima'')&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144878</id>
		<title>CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144878"/>
		<updated>2022-04-12T02:23:01Z</updated>

		<summary type="html">&lt;p&gt;Amengan: /* Plan of action */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
&lt;br /&gt;
Waitlist feature is utilized during subject assignment in an assignment. For example, during the topic allocation of the Final Project (and design doc), each team had the opportunity to sign up for a topic in which they were interested or to add to a waitlist of a topic in which they were not interested. When a team is added to the queue, many circumstances emerge. The waitlist feature currently does not adhere to the open-closed design paradigm. As a result, our task in this project is to resolve these issues by rewriting the waitlist functionality.&lt;br /&gt;
&lt;br /&gt;
Whenever a team requests for a topic, there are two things that can happen. &lt;br /&gt;
&lt;br /&gt;
* '''The topic is available''': In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ). This is pretty straightforward.&lt;br /&gt;
&lt;br /&gt;
* '''The topic is unavailable''': In this case, the team is waitlisted for the topic. When any other team drops this topic, a waitlisted team will be assigned for this topic. &lt;br /&gt;
&lt;br /&gt;
Our task is to simplify the way we are handling the second case. For each topic, we will have to have a waitlist object associated with it. If a team has requested for a topic that is not available, the team would just be queued on to the waitlist for this topic. In the waitlist object, we will have to maintain the team_id and the topic id for which this team will be waitlisted. In the current implementation, the waitlisting functionality is scattered across multiple files. All this has to be consolidated and placed in fewer number of places ( model file and helper class ).&lt;br /&gt;
&lt;br /&gt;
=== Issues with existing functionality ===&lt;br /&gt;
The current implementation has multiple models and controllers ( sign_up_topic.rb, waitlist.rb, invitation.rb, lottery_controller.rb, suggestion_controller.rb and signed_up_team.rb etc ) perform actions that indirectly affect the waitlist ( adding or removing teams from waitlist ). As a result, modifying the waitlist is being performed by multiple models and controllers. So, there is a lot of redundancy associated with basic waitlist operations in multiple files.&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
&lt;br /&gt;
To simplify waitlist functionality, to reduce code redundancy and to fix the Single-responsibility principle that is being violated, we will rewrite or move the functions/methods to multiple controllers and model files that manipulate waitlists of a topic. All these classes will now just invoke methods of waitlist.rb. The following files contains the waitlist functionality, so we plan to either refactor or add the functionality.&lt;br /&gt;
&lt;br /&gt;
1) ''signed_up_team.rb''&lt;br /&gt;
&lt;br /&gt;
2) ''waitlist.rb''&lt;br /&gt;
&lt;br /&gt;
3) ''sign_up_sheet_controller.rb''&lt;br /&gt;
&lt;br /&gt;
4) ''sign_up_sheet.rb''&lt;br /&gt;
&lt;br /&gt;
5) ''sign_up_topic.rb''&lt;br /&gt;
&lt;br /&gt;
6) ''suggestion_controller.rb''&lt;br /&gt;
&lt;br /&gt;
7) ''invitation.rb''&lt;br /&gt;
&lt;br /&gt;
== Proposed design ==&lt;br /&gt;
&lt;br /&gt;
=== General Design Goals ===&lt;br /&gt;
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 be testing the existing features so that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
Our goal is to make the experiza system more reliable and have code that is consistent with the standards of object-oriented design.&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
In this Unified Modeling Language (UML), we summarize the details of the system's users and their interactions with the system. &amp;lt;br&amp;gt;&lt;br /&gt;
We have two users to the system '''Student''' and '''Instructor'''. The interactions these users have with the system are stated below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Student Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. Student should be able to perform an action to add their own team to the waitlist.  &amp;lt;br&amp;gt;&lt;br /&gt;
2. Student should be able to drop their own team from the waitlist but not others team.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Instructor Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1.  Delete or purge on the waitlist items are those actions that have to be performed by the instructor/admin and student should not be given access to delete action.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Instructor should be able to add any team to the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Instructor should be able to drop any team from the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
4. Instructor should be able to fetch the details of the teams in a waitlist for a particular topic.&amp;lt;br&amp;gt;&lt;br /&gt;
5. Instructor should be able to fetch the details of the topics in which a team is waitlisted. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_uml_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
Tables associated with '''waitlist_teams''' table are&amp;lt;br&amp;gt;&lt;br /&gt;
1. teams&amp;lt;br&amp;gt;&lt;br /&gt;
2. signed_up_teams&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
waitlist_teams table is referred by the signed_up_teams and teams table as Foreign Key Relationship.&lt;br /&gt;
&lt;br /&gt;
'''team_id''' : foreign key in waitlists_team table which is a reference to the teams table &amp;lt;br&amp;gt;&lt;br /&gt;
'''topic_id''' : foreign key in waitlists_team table which is a reference to the signed_up_teams table &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These relationships along with the attributes of the classes are depicted in the class diagram below.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Waitlists_class_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
== Plan of action ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we will be doing in this project :&lt;br /&gt;
1. Update the SIGNED_UP_TEAMS table.&lt;br /&gt;
2. Refactoring files that contains waitlist functionality&lt;br /&gt;
3. Add new WAITLIST_TEAMS table using scaffold.&lt;br /&gt;
4. Migrate the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table.&lt;br /&gt;
5. Add/Move the business logic to ''waitlist_teams.rb'' file&lt;br /&gt;
&lt;br /&gt;
=== Changes to the signed_up_teams Table ===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
We plan on retiring/removing the waitlist flag from the signed_up_teams table and separating this functionality. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag will be rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Files and methods to be refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to is_waitlisted should be removed and waitlists must be determined by using the new waitlist_team table.&lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##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. &lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##switch_original_topic_to_approved_suggested_topic&lt;br /&gt;
###Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table&lt;br /&gt;
###Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##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&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
###It checks if topic has slots if yes it adds to signed up team, else creates a signup as waitlist&lt;br /&gt;
###This method should use the new table and call the helper functions of waitlist to perform actions on waitlists&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Move method to fetch all users on waitlist for a topic to waitlist_teams method.&lt;br /&gt;
##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&lt;br /&gt;
##reassign_topic - Use methods that perform actions on waitlist that should be moved to waitlist_helper, also use transactions to make it atomic.&lt;br /&gt;
##update_waitlisted_users - Move method to waitlist_teams model and use the new table&lt;br /&gt;
##find_slots_waitlisted - Move method to waitlist_teams model&lt;br /&gt;
##find_waitlisted_topics - Move method to waitlist_teams model&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification&lt;br /&gt;
##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.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team&lt;br /&gt;
###Removing from waitlist and adding to team to sign up should be as a single transaction&lt;br /&gt;
###There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet&lt;br /&gt;
###All functionality should be moved to waitlist_helper and implemented in a robust and dry manner&lt;br /&gt;
&lt;br /&gt;
===Adding new waitlist_teams Table ===&lt;br /&gt;
We plan to add a new table ''waitlist_teams''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The attributes for the table are team_id(refers to the ''teams'' table), topic_id (refers to the ''sign_up_topics'' table)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This table only stores the waitlisted teams for each topic.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Having separated tables for signups and waitlists will help in managing entries and enforcing constraints and make it easier to implement and extend functionality if required.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
The waitlist_helper class will perform the following operations &lt;br /&gt;
#Delete all waitlists for team&lt;br /&gt;
#Purge all waitlists for topic &lt;br /&gt;
#Add team to waitlist&lt;br /&gt;
#Delete specific team from waitlist&lt;br /&gt;
#Get all waitlisted topics for team&lt;br /&gt;
#Get all waitlisted teams for topic&lt;br /&gt;
#Get first team in waitlist for topic&lt;br /&gt;
#Check waitlist empty for topic&lt;br /&gt;
#Check if team has any waitlists &lt;br /&gt;
#Get the number of waitlisted teams for all topics in an assignment&lt;br /&gt;
&lt;br /&gt;
===Migrating existing waitlists to use new table===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt; &lt;br /&gt;
We plan on writing a migration script to move the waitlists from signed_up_teams table to waitlist_teams table.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This will ensure minimal regression breakages and retain existing functionalities.&lt;br /&gt;
=== Specific Tasks Completed ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
=== Video Demonstration ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
=== Testing Goals and Test Objects ===&lt;br /&gt;
&lt;br /&gt;
''Drawing from the project objectives:''&lt;br /&gt;
#Ways to get added to the waitlist for a topic&lt;br /&gt;
##Team requests a topic that has no slot available.&lt;br /&gt;
##When capacity/max choosers for a topic is increased&lt;br /&gt;
##When a student gets added to a team that already has a signed up topic&lt;br /&gt;
#Ways to get off a waitlist&lt;br /&gt;
##team gets the topic they are waiting for ( all other waitlists are dropped for the team)&lt;br /&gt;
##team drops off the waitlist&lt;br /&gt;
##instructor drops team from the waitlist&lt;br /&gt;
##a drop-topic deadline passes&lt;br /&gt;
##team is deleted&lt;br /&gt;
##student gets added to a new team, then the old team's waitlist should be dropped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RSpec Unit Tests ===&lt;br /&gt;
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''&lt;br /&gt;
*Student Waitlist&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting added to the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has no available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be added to the waitlist for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be enrolled for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted topics getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: Student gets enrolled into a course for which he was waitlisted before.&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted teams getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The deadline for a topic passes.&lt;br /&gt;
  Then: All the waitlisted teams for that particular topic must be dropped.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The enrolled team for a topic drops&lt;br /&gt;
  Then: The team that was waitlisted earlier for the topics must be enrolled.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
'''Student's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Student_waitlist_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Instructor's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_signup_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''Instructor's View With Waitlists'''&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlist.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Test 1:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to add their team to the waitlist by clicking on '''Check''' icon (see the image above) if the team has not signed up in any topic.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 2:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to drop the team from the waitlist by clicking on '''Delete''' icon (see the image above) if they are no longer interested in it.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 3:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to add a student to the topic by clicking on '''Check''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 4:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to delete a student to the topic by clicking on '''Delete''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 5:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the students signup for a topic in the page displayed. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 6:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the topics available &lt;br /&gt;
&lt;br /&gt;
''' Test 7:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view waitlisted and signed up teams for all the topics in the assignment&lt;br /&gt;
&lt;br /&gt;
''' Test 8:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to drop waitlisted team for a topics in the assignment&lt;br /&gt;
&lt;br /&gt;
we will be adding more test cases as the project progress.&lt;br /&gt;
&lt;br /&gt;
=== Regression Testing ===&lt;br /&gt;
''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 ''&lt;br /&gt;
''old test cases still pass.''&lt;br /&gt;
&lt;br /&gt;
# Make sure all existing waitlist functionality still passes&lt;br /&gt;
&lt;br /&gt;
== Conclusions and Future Work ==&lt;br /&gt;
=== Comprehensive Testing and Scope ===&lt;br /&gt;
* ''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
Pull request&lt;br /&gt;
&lt;br /&gt;
Deployed application with changes&lt;br /&gt;
&lt;br /&gt;
Forked repository&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
=== Students ===&lt;br /&gt;
*Krishna Saurabh Vankadaru (''kvankad'')&lt;br /&gt;
*Samson Reddy Mulkur (''smulkur'')&lt;br /&gt;
*Akhil Kumar Mengani (''amengan'')&lt;br /&gt;
*Sai Naga Vamshi Chidara (''schidar'')&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
*Naman Shrimali (''nshrima'')&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144874</id>
		<title>CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144874"/>
		<updated>2022-04-12T02:17:46Z</updated>

		<summary type="html">&lt;p&gt;Amengan: /* Issues with existing functionality */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
&lt;br /&gt;
Waitlist feature is utilized during subject assignment in an assignment. For example, during the topic allocation of the Final Project (and design doc), each team had the opportunity to sign up for a topic in which they were interested or to add to a waitlist of a topic in which they were not interested. When a team is added to the queue, many circumstances emerge. The waitlist feature currently does not adhere to the open-closed design paradigm. As a result, our task in this project is to resolve these issues by rewriting the waitlist functionality.&lt;br /&gt;
&lt;br /&gt;
Whenever a team requests for a topic, there are two things that can happen. &lt;br /&gt;
&lt;br /&gt;
* '''The topic is available''': In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ). This is pretty straightforward.&lt;br /&gt;
&lt;br /&gt;
* '''The topic is unavailable''': In this case, the team is waitlisted for the topic. When any other team drops this topic, a waitlisted team will be assigned for this topic. &lt;br /&gt;
&lt;br /&gt;
Our task is to simplify the way we are handling the second case. For each topic, we will have to have a waitlist object associated with it. If a team has requested for a topic that is not available, the team would just be queued on to the waitlist for this topic. In the waitlist object, we will have to maintain the team_id and the topic id for which this team will be waitlisted. In the current implementation, the waitlisting functionality is scattered across multiple files. All this has to be consolidated and placed in fewer number of places ( model file and helper class ).&lt;br /&gt;
&lt;br /&gt;
=== Issues with existing functionality ===&lt;br /&gt;
The current implementation has multiple models and controllers ( sign_up_topic.rb, waitlist.rb, invitation.rb, lottery_controller.rb, suggestion_controller.rb and signed_up_team.rb etc ) perform actions that indirectly affect the waitlist ( adding or removing teams from waitlist ). As a result, modifying the waitlist is being performed by multiple models and controllers. So, there is a lot of redundancy associated with basic waitlist operations in multiple files.&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
&lt;br /&gt;
To simplify waitlist functionality, to reduce code redundancy and to fix the Single-responsibility principle that is being violated, we will rewrite or move the functions/methods to multiple controllers and model files that manipulate waitlists of a topic. All these classes will now just invoke methods of waitlist.rb. The following files contains the waitlist functionality, so we plan to either refactor or add the functionality.&lt;br /&gt;
&lt;br /&gt;
1) ''signed_up_team.rb''&lt;br /&gt;
&lt;br /&gt;
2) ''waitlist.rb''&lt;br /&gt;
&lt;br /&gt;
3) ''sign_up_sheet_controller.rb''&lt;br /&gt;
&lt;br /&gt;
4) ''sign_up_sheet.rb''&lt;br /&gt;
&lt;br /&gt;
5) ''sign_up_topic.rb''&lt;br /&gt;
&lt;br /&gt;
6) ''suggestion_controller.rb''&lt;br /&gt;
&lt;br /&gt;
7) ''invitation.rb''&lt;br /&gt;
&lt;br /&gt;
== Proposed design ==&lt;br /&gt;
&lt;br /&gt;
=== General Design Goals ===&lt;br /&gt;
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 be testing the existing features so that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
Our goal is to make the experiza system more reliable and have code that is consistent with the standards of object-oriented design.&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
In this Unified Modeling Language (UML), we summarize the details of the system's users and their interactions with the system. &amp;lt;br&amp;gt;&lt;br /&gt;
We have two users to the system '''Student''' and '''Instructor'''. The interactions these users have with the system are stated below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Student Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. Student should be able to perform an action to add their own team to the waitlist.  &amp;lt;br&amp;gt;&lt;br /&gt;
2. Student should be able to drop their own team from the waitlist but not others team.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Instructor Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1.  Delete or purge on the waitlist items are those actions that have to be performed by the instructor/admin and student should not be given access to delete action.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Instructor should be able to add any team to the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Instructor should be able to drop any team from the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
4. Instructor should be able to fetch the details of the teams in a waitlist for a particular topic.&amp;lt;br&amp;gt;&lt;br /&gt;
5. Instructor should be able to fetch the details of the topics in which a team is waitlisted. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_uml_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
Tables associated with '''waitlist_teams''' table:&amp;lt;br&amp;gt;&lt;br /&gt;
1. teams&amp;lt;br&amp;gt;&lt;br /&gt;
2. signed_up_teams&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
waitlist_teams table is referred by the signed_up_teams and teams table as Foreign Key Relationship.&lt;br /&gt;
&lt;br /&gt;
'''team_id''' : foreign key in waitlists_team table referenced by teams table &amp;lt;br&amp;gt;&lt;br /&gt;
'''topic_id''' : foreign key in waitlists_team table reference by signed_up_teams table &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_class_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
== Plan of action ==&lt;br /&gt;
&lt;br /&gt;
=== Changes to the signed_up_teams Table ===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
We plan on retiring/removing the waitlist flag from the signed_up_teams table and separating this functionality. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag will be rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Files and methods to be refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to is_waitlisted should be removed and waitlists must be determined by using the new waitlist_team table.&lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##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. &lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##switch_original_topic_to_approved_suggested_topic&lt;br /&gt;
###Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table&lt;br /&gt;
###Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##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&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
###It checks if topic has slots if yes it adds to signed up team, else creates a signup as waitlist&lt;br /&gt;
###This method should use the new table and call the helper functions of waitlist to perform actions on waitlists&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Move method to fetch all users on waitlist for a topic to waitlist_teams method.&lt;br /&gt;
##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&lt;br /&gt;
##reassign_topic - Use methods that perform actions on waitlist that should be moved to waitlist_helper, also use transactions to make it atomic.&lt;br /&gt;
##update_waitlisted_users - Move method to waitlist_teams model and use the new table&lt;br /&gt;
##find_slots_waitlisted - Move method to waitlist_teams model&lt;br /&gt;
##find_waitlisted_topics - Move method to waitlist_teams model&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification&lt;br /&gt;
##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.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team&lt;br /&gt;
###Removing from waitlist and adding to team to sign up should be as a single transaction&lt;br /&gt;
###There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet&lt;br /&gt;
###All functionality should be moved to waitlist_helper and implemented in a robust and dry manner&lt;br /&gt;
&lt;br /&gt;
===Adding new waitlist_teams Table ===&lt;br /&gt;
We plan to add a new table ''waitlist_teams''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The attributes for the table are team_id(refers to the ''teams'' table), topic_id (refers to the ''sign_up_topics'' table)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This table only stores the waitlisted teams for each topic.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Having separated tables for signups and waitlists will help in managing entries and enforcing constraints and make it easier to implement and extend functionality if required.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
The waitlist_helper class will perform the following operations &lt;br /&gt;
#Delete all waitlists for team&lt;br /&gt;
#Purge all waitlists for topic &lt;br /&gt;
#Add team to waitlist&lt;br /&gt;
#Delete specific team from waitlist&lt;br /&gt;
#Get all waitlisted topics for team&lt;br /&gt;
#Get all waitlisted teams for topic&lt;br /&gt;
#Get first team in waitlist for topic&lt;br /&gt;
#Check waitlist empty for topic&lt;br /&gt;
#Check if team has any waitlists &lt;br /&gt;
#Get the number of waitlisted teams for all topics in an assignment&lt;br /&gt;
&lt;br /&gt;
===Migrating existing waitlists to use new table===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt; &lt;br /&gt;
We plan on writing a migration script to move the waitlists from signed_up_teams table to waitlist_teams table.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This will ensure minimal regression breakages and retain existing functionalities.&lt;br /&gt;
=== Specific Tasks Completed ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
=== Video Demonstration ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
=== Testing Goals and Test Objects ===&lt;br /&gt;
&lt;br /&gt;
''Drawing from the project objectives:''&lt;br /&gt;
#Ways to get added to the waitlist for a topic&lt;br /&gt;
##Team requests a topic that has no slot available.&lt;br /&gt;
##When capacity/max choosers for a topic is increased&lt;br /&gt;
##When a student gets added to a team that already has a signed up topic&lt;br /&gt;
#Ways to get off a waitlist&lt;br /&gt;
##team gets the topic they are waiting for ( all other waitlists are dropped for the team)&lt;br /&gt;
##team drops off the waitlist&lt;br /&gt;
##instructor drops team from the waitlist&lt;br /&gt;
##a drop-topic deadline passes&lt;br /&gt;
##team is deleted&lt;br /&gt;
##student gets added to a new team, then the old team's waitlist should be dropped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RSpec Unit Tests ===&lt;br /&gt;
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''&lt;br /&gt;
*Student Waitlist&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting added to the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has no available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be added to the waitlist for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be enrolled for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted topics getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: Student gets enrolled into a course for which he was waitlisted before.&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted teams getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The deadline for a topic passes.&lt;br /&gt;
  Then: All the waitlisted teams for that particular topic must be dropped.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The enrolled team for a topic drops&lt;br /&gt;
  Then: The team that was waitlisted earlier for the topics must be enrolled.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
'''Student's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Student_waitlist_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Instructor's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_signup_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''Instructor's View With Waitlists'''&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlist.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Test 1:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to add their team to the waitlist by clicking on '''Check''' icon (see the image above) if the team has not signed up in any topic.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 2:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to drop the team from the waitlist by clicking on '''Delete''' icon (see the image above) if they are no longer interested in it.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 3:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to add a student to the topic by clicking on '''Check''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 4:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to delete a student to the topic by clicking on '''Delete''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 5:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the students signup for a topic in the page displayed. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 6:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the topics available &lt;br /&gt;
&lt;br /&gt;
''' Test 7:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view waitlisted and signed up teams for all the topics in the assignment&lt;br /&gt;
&lt;br /&gt;
''' Test 8:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to drop waitlisted team for a topics in the assignment&lt;br /&gt;
&lt;br /&gt;
we will be adding more test cases as the project progress.&lt;br /&gt;
&lt;br /&gt;
=== Regression Testing ===&lt;br /&gt;
''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 ''&lt;br /&gt;
''old test cases still pass.''&lt;br /&gt;
&lt;br /&gt;
# Make sure all existing waitlist functionality still passes&lt;br /&gt;
&lt;br /&gt;
== Conclusions and Future Work ==&lt;br /&gt;
=== Comprehensive Testing and Scope ===&lt;br /&gt;
* ''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
Pull request&lt;br /&gt;
&lt;br /&gt;
Deployed application with changes&lt;br /&gt;
&lt;br /&gt;
Forked repository&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
=== Students ===&lt;br /&gt;
*Krishna Saurabh Vankadaru (''kvankad'')&lt;br /&gt;
*Samson Reddy Mulkur (''smulkur'')&lt;br /&gt;
*Akhil Kumar Mengani (''amengan'')&lt;br /&gt;
*Sai Naga Vamshi Chidara (''schidar'')&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
*Naman Shrimali (''nshrima'')&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144871</id>
		<title>CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144871"/>
		<updated>2022-04-12T02:17:22Z</updated>

		<summary type="html">&lt;p&gt;Amengan: /* Solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
&lt;br /&gt;
Waitlist feature is utilized during subject assignment in an assignment. For example, during the topic allocation of the Final Project (and design doc), each team had the opportunity to sign up for a topic in which they were interested or to add to a waitlist of a topic in which they were not interested. When a team is added to the queue, many circumstances emerge. The waitlist feature currently does not adhere to the open-closed design paradigm. As a result, our task in this project is to resolve these issues by rewriting the waitlist functionality.&lt;br /&gt;
&lt;br /&gt;
Whenever a team requests for a topic, there are two things that can happen. &lt;br /&gt;
&lt;br /&gt;
* '''The topic is available''': In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ). This is pretty straightforward.&lt;br /&gt;
&lt;br /&gt;
* '''The topic is unavailable''': In this case, the team is waitlisted for the topic. When any other team drops this topic, a waitlisted team will be assigned for this topic. &lt;br /&gt;
&lt;br /&gt;
Our task is to simplify the way we are handling the second case. For each topic, we will have to have a waitlist object associated with it. If a team has requested for a topic that is not available, the team would just be queued on to the waitlist for this topic. In the waitlist object, we will have to maintain the team_id and the topic id for which this team will be waitlisted. In the current implementation, the waitlisting functionality is scattered across multiple files. All this has to be consolidated and placed in fewer number of places ( model file and helper class ).&lt;br /&gt;
&lt;br /&gt;
=== Issues with existing functionality ===&lt;br /&gt;
The current implementation has multiple models and controllers ( sign_up_topic.rb, waitlist.rb, invitation.rb, lottery_controller.rb, suggestion_controller.rb and signed_up_team.rb etc ) perform actions that indirectly affect the waitlist ( adding or removing teams from waitlist ). As a result, modifying the waitlist is being performed by multiple models and controllers. So, there is a lot of redundancy associated with basic waitlist operations in multiple files.&lt;br /&gt;
&lt;br /&gt;
''Italic text''== Solution ==&lt;br /&gt;
&lt;br /&gt;
To simplify waitlist functionality, to reduce code redundancy and to fix the Single-responsibility principle that is being violated, we will rewrite or move the functions/methods to multiple controllers and model files that manipulate waitlists of a topic. All these classes will now just invoke methods of waitlist.rb. The following files contains the waitlist functionality, so we plan to either refactor or add the functionality.&lt;br /&gt;
&lt;br /&gt;
1) ''signed_up_team.rb''&lt;br /&gt;
&lt;br /&gt;
2) ''waitlist.rb''&lt;br /&gt;
&lt;br /&gt;
3) ''sign_up_sheet_controller.rb''&lt;br /&gt;
&lt;br /&gt;
4) ''sign_up_sheet.rb''&lt;br /&gt;
&lt;br /&gt;
5) ''sign_up_topic.rb''&lt;br /&gt;
&lt;br /&gt;
6) ''suggestion_controller.rb''&lt;br /&gt;
&lt;br /&gt;
7) ''invitation.rb''&lt;br /&gt;
&lt;br /&gt;
== Proposed design ==&lt;br /&gt;
&lt;br /&gt;
=== General Design Goals ===&lt;br /&gt;
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 be testing the existing features so that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
Our goal is to make the experiza system more reliable and have code that is consistent with the standards of object-oriented design.&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
In this Unified Modeling Language (UML), we summarize the details of the system's users and their interactions with the system. &amp;lt;br&amp;gt;&lt;br /&gt;
We have two users to the system '''Student''' and '''Instructor'''. The interactions these users have with the system are stated below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Student Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. Student should be able to perform an action to add their own team to the waitlist.  &amp;lt;br&amp;gt;&lt;br /&gt;
2. Student should be able to drop their own team from the waitlist but not others team.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Instructor Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1.  Delete or purge on the waitlist items are those actions that have to be performed by the instructor/admin and student should not be given access to delete action.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Instructor should be able to add any team to the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Instructor should be able to drop any team from the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
4. Instructor should be able to fetch the details of the teams in a waitlist for a particular topic.&amp;lt;br&amp;gt;&lt;br /&gt;
5. Instructor should be able to fetch the details of the topics in which a team is waitlisted. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_uml_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
Tables associated with '''waitlist_teams''' table:&amp;lt;br&amp;gt;&lt;br /&gt;
1. teams&amp;lt;br&amp;gt;&lt;br /&gt;
2. signed_up_teams&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
waitlist_teams table is referred by the signed_up_teams and teams table as Foreign Key Relationship.&lt;br /&gt;
&lt;br /&gt;
'''team_id''' : foreign key in waitlists_team table referenced by teams table &amp;lt;br&amp;gt;&lt;br /&gt;
'''topic_id''' : foreign key in waitlists_team table reference by signed_up_teams table &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_class_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
== Plan of action ==&lt;br /&gt;
&lt;br /&gt;
=== Changes to the signed_up_teams Table ===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
We plan on retiring/removing the waitlist flag from the signed_up_teams table and separating this functionality. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag will be rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Files and methods to be refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to is_waitlisted should be removed and waitlists must be determined by using the new waitlist_team table.&lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##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. &lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##switch_original_topic_to_approved_suggested_topic&lt;br /&gt;
###Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table&lt;br /&gt;
###Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##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&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
###It checks if topic has slots if yes it adds to signed up team, else creates a signup as waitlist&lt;br /&gt;
###This method should use the new table and call the helper functions of waitlist to perform actions on waitlists&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Move method to fetch all users on waitlist for a topic to waitlist_teams method.&lt;br /&gt;
##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&lt;br /&gt;
##reassign_topic - Use methods that perform actions on waitlist that should be moved to waitlist_helper, also use transactions to make it atomic.&lt;br /&gt;
##update_waitlisted_users - Move method to waitlist_teams model and use the new table&lt;br /&gt;
##find_slots_waitlisted - Move method to waitlist_teams model&lt;br /&gt;
##find_waitlisted_topics - Move method to waitlist_teams model&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification&lt;br /&gt;
##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.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team&lt;br /&gt;
###Removing from waitlist and adding to team to sign up should be as a single transaction&lt;br /&gt;
###There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet&lt;br /&gt;
###All functionality should be moved to waitlist_helper and implemented in a robust and dry manner&lt;br /&gt;
&lt;br /&gt;
===Adding new waitlist_teams Table ===&lt;br /&gt;
We plan to add a new table ''waitlist_teams''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The attributes for the table are team_id(refers to the ''teams'' table), topic_id (refers to the ''sign_up_topics'' table)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This table only stores the waitlisted teams for each topic.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Having separated tables for signups and waitlists will help in managing entries and enforcing constraints and make it easier to implement and extend functionality if required.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
The waitlist_helper class will perform the following operations &lt;br /&gt;
#Delete all waitlists for team&lt;br /&gt;
#Purge all waitlists for topic &lt;br /&gt;
#Add team to waitlist&lt;br /&gt;
#Delete specific team from waitlist&lt;br /&gt;
#Get all waitlisted topics for team&lt;br /&gt;
#Get all waitlisted teams for topic&lt;br /&gt;
#Get first team in waitlist for topic&lt;br /&gt;
#Check waitlist empty for topic&lt;br /&gt;
#Check if team has any waitlists &lt;br /&gt;
#Get the number of waitlisted teams for all topics in an assignment&lt;br /&gt;
&lt;br /&gt;
===Migrating existing waitlists to use new table===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt; &lt;br /&gt;
We plan on writing a migration script to move the waitlists from signed_up_teams table to waitlist_teams table.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This will ensure minimal regression breakages and retain existing functionalities.&lt;br /&gt;
=== Specific Tasks Completed ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
=== Video Demonstration ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
=== Testing Goals and Test Objects ===&lt;br /&gt;
&lt;br /&gt;
''Drawing from the project objectives:''&lt;br /&gt;
#Ways to get added to the waitlist for a topic&lt;br /&gt;
##Team requests a topic that has no slot available.&lt;br /&gt;
##When capacity/max choosers for a topic is increased&lt;br /&gt;
##When a student gets added to a team that already has a signed up topic&lt;br /&gt;
#Ways to get off a waitlist&lt;br /&gt;
##team gets the topic they are waiting for ( all other waitlists are dropped for the team)&lt;br /&gt;
##team drops off the waitlist&lt;br /&gt;
##instructor drops team from the waitlist&lt;br /&gt;
##a drop-topic deadline passes&lt;br /&gt;
##team is deleted&lt;br /&gt;
##student gets added to a new team, then the old team's waitlist should be dropped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RSpec Unit Tests ===&lt;br /&gt;
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''&lt;br /&gt;
*Student Waitlist&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting added to the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has no available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be added to the waitlist for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be enrolled for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted topics getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: Student gets enrolled into a course for which he was waitlisted before.&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted teams getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The deadline for a topic passes.&lt;br /&gt;
  Then: All the waitlisted teams for that particular topic must be dropped.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The enrolled team for a topic drops&lt;br /&gt;
  Then: The team that was waitlisted earlier for the topics must be enrolled.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
'''Student's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Student_waitlist_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Instructor's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_signup_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''Instructor's View With Waitlists'''&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlist.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Test 1:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to add their team to the waitlist by clicking on '''Check''' icon (see the image above) if the team has not signed up in any topic.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 2:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to drop the team from the waitlist by clicking on '''Delete''' icon (see the image above) if they are no longer interested in it.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 3:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to add a student to the topic by clicking on '''Check''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 4:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to delete a student to the topic by clicking on '''Delete''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 5:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the students signup for a topic in the page displayed. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 6:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the topics available &lt;br /&gt;
&lt;br /&gt;
''' Test 7:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view waitlisted and signed up teams for all the topics in the assignment&lt;br /&gt;
&lt;br /&gt;
''' Test 8:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to drop waitlisted team for a topics in the assignment&lt;br /&gt;
&lt;br /&gt;
we will be adding more test cases as the project progress.&lt;br /&gt;
&lt;br /&gt;
=== Regression Testing ===&lt;br /&gt;
''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 ''&lt;br /&gt;
''old test cases still pass.''&lt;br /&gt;
&lt;br /&gt;
# Make sure all existing waitlist functionality still passes&lt;br /&gt;
&lt;br /&gt;
== Conclusions and Future Work ==&lt;br /&gt;
=== Comprehensive Testing and Scope ===&lt;br /&gt;
* ''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
Pull request&lt;br /&gt;
&lt;br /&gt;
Deployed application with changes&lt;br /&gt;
&lt;br /&gt;
Forked repository&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
=== Students ===&lt;br /&gt;
*Krishna Saurabh Vankadaru (''kvankad'')&lt;br /&gt;
*Samson Reddy Mulkur (''smulkur'')&lt;br /&gt;
*Akhil Kumar Mengani (''amengan'')&lt;br /&gt;
*Sai Naga Vamshi Chidara (''schidar'')&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
*Naman Shrimali (''nshrima'')&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144865</id>
		<title>CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144865"/>
		<updated>2022-04-12T02:10:08Z</updated>

		<summary type="html">&lt;p&gt;Amengan: /* Solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
&lt;br /&gt;
Waitlist feature is utilized during subject assignment in an assignment. For example, during the topic allocation of the Final Project (and design doc), each team had the opportunity to sign up for a topic in which they were interested or to add to a waitlist of a topic in which they were not interested. When a team is added to the queue, many circumstances emerge. The waitlist feature currently does not adhere to the open-closed design paradigm. As a result, our task in this project is to resolve these issues by rewriting the waitlist functionality.&lt;br /&gt;
&lt;br /&gt;
Whenever a team requests for a topic, there are two things that can happen. &lt;br /&gt;
&lt;br /&gt;
* '''The topic is available''': In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ). This is pretty straightforward.&lt;br /&gt;
&lt;br /&gt;
* '''The topic is unavailable''': In this case, the team is waitlisted for the topic. When any other team drops this topic, a waitlisted team will be assigned for this topic. &lt;br /&gt;
&lt;br /&gt;
Our task is to simplify the way we are handling the second case. For each topic, we will have to have a waitlist object associated with it. If a team has requested for a topic that is not available, the team would just be queued on to the waitlist for this topic. In the waitlist object, we will have to maintain the team_id and the topic id for which this team will be waitlisted. In the current implementation, the waitlisting functionality is scattered across multiple files. All this has to be consolidated and placed in fewer number of places ( model file and helper class ).&lt;br /&gt;
&lt;br /&gt;
=== Issues with existing functionality ===&lt;br /&gt;
The current implementation has multiple models and controllers ( sign_up_topic.rb, waitlist.rb, invitation.rb, lottery_controller.rb, suggestion_controller.rb and signed_up_team.rb etc ) perform actions that indirectly affect the waitlist ( adding or removing teams from waitlist ). As a result, modifying the waitlist is being performed by multiple models and controllers. So, there is a lot of redundancy associated with basic waitlist operations in multiple files.&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
To simplify waitlist functionality and to reduce code redundancy, we will be moving all the functions present in multiple controllers and model files that manipulate waitlists to waitlist.rb. All these classes will now just invoke methods of waitlist.rb. The list of files and methods which will be modified are &lt;br /&gt;
&lt;br /&gt;
1) signed_up_team.rb&lt;br /&gt;
&lt;br /&gt;
2) waitlist.rb&lt;br /&gt;
&lt;br /&gt;
3) sign_up_sheet_controller.rb&lt;br /&gt;
&lt;br /&gt;
4) sign_up_sheet.rb&lt;br /&gt;
&lt;br /&gt;
5) sign_up_topic.rb&lt;br /&gt;
&lt;br /&gt;
6) suggestion_controller.rb&lt;br /&gt;
&lt;br /&gt;
7) invitation.rb&lt;br /&gt;
&lt;br /&gt;
== Proposed design ==&lt;br /&gt;
&lt;br /&gt;
=== General Design Goals ===&lt;br /&gt;
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 be testing the existing features so that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
Our goal is to make the experiza system more reliable and have code that is consistent with the standards of object-oriented design.&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
In this Unified Modeling Language (UML), we summarize the details of the system's users and their interactions with the system. &amp;lt;br&amp;gt;&lt;br /&gt;
We have two users to the system '''Student''' and '''Instructor'''. The interactions these users have with the system are stated below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Student Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. Student should be able to perform an action to add their own team to the waitlist.  &amp;lt;br&amp;gt;&lt;br /&gt;
2. Student should be able to drop their own team from the waitlist but not others team.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Instructor Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1.  Delete or purge on the waitlist items are those actions that have to be performed by the instructor/admin and student should not be given access to delete action.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Instructor should be able to add any team to the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Instructor should be able to drop any team from the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
4. Instructor should be able to fetch the details of the teams in a waitlist for a particular topic.&amp;lt;br&amp;gt;&lt;br /&gt;
5. Instructor should be able to fetch the details of the topics in which a team is waitlisted. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_uml_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
Tables associated with '''waitlist_teams''' table:&amp;lt;br&amp;gt;&lt;br /&gt;
1. teams&amp;lt;br&amp;gt;&lt;br /&gt;
2. signed_up_teams&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
waitlist_teams table is referred by the signed_up_teams and teams table as Foreign Key Relationship.&lt;br /&gt;
&lt;br /&gt;
'''team_id''' : foreign key in waitlists_team table referenced by teams table &amp;lt;br&amp;gt;&lt;br /&gt;
'''topic_id''' : foreign key in waitlists_team table reference by signed_up_teams table &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_class_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
== Plan of action ==&lt;br /&gt;
&lt;br /&gt;
=== Changes to the signed_up_teams Table ===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
We plan on retiring/removing the waitlist flag from the signed_up_teams table and separating this functionality. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag will be rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Files and methods to be refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to is_waitlisted should be removed and waitlists must be determined by using the new waitlist_team table.&lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##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. &lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##switch_original_topic_to_approved_suggested_topic&lt;br /&gt;
###Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table&lt;br /&gt;
###Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##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&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
###It checks if topic has slots if yes it adds to signed up team, else creates a signup as waitlist&lt;br /&gt;
###This method should use the new table and call the helper functions of waitlist to perform actions on waitlists&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Move method to fetch all users on waitlist for a topic to waitlist_teams method.&lt;br /&gt;
##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&lt;br /&gt;
##reassign_topic - Use methods that perform actions on waitlist that should be moved to waitlist_helper, also use transactions to make it atomic.&lt;br /&gt;
##update_waitlisted_users - Move method to waitlist_teams model and use the new table&lt;br /&gt;
##find_slots_waitlisted - Move method to waitlist_teams model&lt;br /&gt;
##find_waitlisted_topics - Move method to waitlist_teams model&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification&lt;br /&gt;
##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.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team&lt;br /&gt;
###Removing from waitlist and adding to team to sign up should be as a single transaction&lt;br /&gt;
###There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet&lt;br /&gt;
###All functionality should be moved to waitlist_helper and implemented in a robust and dry manner&lt;br /&gt;
&lt;br /&gt;
===Adding new waitlist_teams Table ===&lt;br /&gt;
We plan to add a new table ''waitlist_teams''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The attributes for the table are team_id(refers to the ''teams'' table), topic_id (refers to the ''sign_up_topics'' table)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This table only stores the waitlisted teams for each topic.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Having separated tables for signups and waitlists will help in managing entries and enforcing constraints and make it easier to implement and extend functionality if required.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
The waitlist_helper class will perform the following operations &lt;br /&gt;
#Delete all waitlists for team&lt;br /&gt;
#Purge all waitlists for topic &lt;br /&gt;
#Add team to waitlist&lt;br /&gt;
#Delete specific team from waitlist&lt;br /&gt;
#Get all waitlisted topics for team&lt;br /&gt;
#Get all waitlisted teams for topic&lt;br /&gt;
#Get first team in waitlist for topic&lt;br /&gt;
#Check waitlist empty for topic&lt;br /&gt;
#Check if team has any waitlists &lt;br /&gt;
#Get the number of waitlisted teams for all topics in an assignment&lt;br /&gt;
&lt;br /&gt;
===Migrating existing waitlists to use new table===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt; &lt;br /&gt;
We plan on writing a migration script to move the waitlists from signed_up_teams table to waitlist_teams table.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This will ensure minimal regression breakages and retain existing functionalities.&lt;br /&gt;
=== Specific Tasks Completed ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
=== Video Demonstration ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
=== Testing Goals and Test Objects ===&lt;br /&gt;
&lt;br /&gt;
''Drawing from the project objectives:''&lt;br /&gt;
#Ways to get added to the waitlist for a topic&lt;br /&gt;
##Team requests a topic that has no slot available.&lt;br /&gt;
##When capacity/max choosers for a topic is increased&lt;br /&gt;
##When a student gets added to a team that already has a signed up topic&lt;br /&gt;
#Ways to get off a waitlist&lt;br /&gt;
##team gets the topic they are waiting for ( all other waitlists are dropped for the team)&lt;br /&gt;
##team drops off the waitlist&lt;br /&gt;
##instructor drops team from the waitlist&lt;br /&gt;
##a drop-topic deadline passes&lt;br /&gt;
##team is deleted&lt;br /&gt;
##student gets added to a new team, then the old team's waitlist should be dropped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RSpec Unit Tests ===&lt;br /&gt;
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''&lt;br /&gt;
*Student Waitlist&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting added to the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has no available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be added to the waitlist for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be enrolled for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted topics getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: Student gets enrolled into a course for which he was waitlisted before.&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted teams getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The deadline for a topic passes.&lt;br /&gt;
  Then: All the waitlisted teams for that particular topic must be dropped.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The enrolled team for a topic drops&lt;br /&gt;
  Then: The team that was waitlisted earlier for the topics must be enrolled.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
'''Student's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Student_waitlist_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Instructor's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_signup_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''Instructor's View With Waitlists'''&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlist.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Test 1:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to add their team to the waitlist by clicking on '''Check''' icon (see the image above) if the team has not signed up in any topic.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 2:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to drop the team from the waitlist by clicking on '''Delete''' icon (see the image above) if they are no longer interested in it.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 3:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to add a student to the topic by clicking on '''Check''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 4:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to delete a student to the topic by clicking on '''Delete''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 5:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the students signup for a topic in the page displayed. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 6:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the topics available &lt;br /&gt;
&lt;br /&gt;
''' Test 7:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view waitlisted and signed up teams for all the topics in the assignment&lt;br /&gt;
&lt;br /&gt;
''' Test 8:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to drop waitlisted team for a topics in the assignment&lt;br /&gt;
&lt;br /&gt;
we will be adding more test cases as the project progress.&lt;br /&gt;
&lt;br /&gt;
=== Regression Testing ===&lt;br /&gt;
''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 ''&lt;br /&gt;
''old test cases still pass.''&lt;br /&gt;
&lt;br /&gt;
# Make sure all existing waitlist functionality still passes&lt;br /&gt;
&lt;br /&gt;
== Conclusions and Future Work ==&lt;br /&gt;
=== Comprehensive Testing and Scope ===&lt;br /&gt;
* ''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
Pull request&lt;br /&gt;
&lt;br /&gt;
Deployed application with changes&lt;br /&gt;
&lt;br /&gt;
Forked repository&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
=== Students ===&lt;br /&gt;
*Krishna Saurabh Vankadaru (''kvankad'')&lt;br /&gt;
*Samson Reddy Mulkur (''smulkur'')&lt;br /&gt;
*Akhil Kumar Mengani (''amengan'')&lt;br /&gt;
*Sai Naga Vamshi Chidara (''schidar'')&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
*Naman Shrimali (''nshrima'')&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144864</id>
		<title>CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144864"/>
		<updated>2022-04-12T02:09:56Z</updated>

		<summary type="html">&lt;p&gt;Amengan: /* Overview of Major Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
&lt;br /&gt;
Waitlist feature is utilized during subject assignment in an assignment. For example, during the topic allocation of the Final Project (and design doc), each team had the opportunity to sign up for a topic in which they were interested or to add to a waitlist of a topic in which they were not interested. When a team is added to the queue, many circumstances emerge. The waitlist feature currently does not adhere to the open-closed design paradigm. As a result, our task in this project is to resolve these issues by rewriting the waitlist functionality.&lt;br /&gt;
&lt;br /&gt;
Whenever a team requests for a topic, there are two things that can happen. &lt;br /&gt;
&lt;br /&gt;
* '''The topic is available''': In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ). This is pretty straightforward.&lt;br /&gt;
&lt;br /&gt;
* '''The topic is unavailable''': In this case, the team is waitlisted for the topic. When any other team drops this topic, a waitlisted team will be assigned for this topic. &lt;br /&gt;
&lt;br /&gt;
Our task is to simplify the way we are handling the second case. For each topic, we will have to have a waitlist object associated with it. If a team has requested for a topic that is not available, the team would just be queued on to the waitlist for this topic. In the waitlist object, we will have to maintain the team_id and the topic id for which this team will be waitlisted. In the current implementation, the waitlisting functionality is scattered across multiple files. All this has to be consolidated and placed in fewer number of places ( model file and helper class ).&lt;br /&gt;
&lt;br /&gt;
=== Issues with existing functionality ===&lt;br /&gt;
The current implementation has multiple models and controllers ( sign_up_topic.rb, waitlist.rb, invitation.rb, lottery_controller.rb, suggestion_controller.rb and signed_up_team.rb etc ) perform actions that indirectly affect the waitlist ( adding or removing teams from waitlist ). As a result, modifying the waitlist is being performed by multiple models and controllers. So, there is a lot of redundancy associated with basic waitlist operations in multiple files.&lt;br /&gt;
&lt;br /&gt;
=== Solution ===&lt;br /&gt;
To simplify waitlist functionality and to reduce code redundancy, we will be moving all the functions present in multiple controllers and model files that manipulate waitlists to waitlist.rb. All these classes will now just invoke methods of waitlist.rb. The list of files and methods which will be modified are &lt;br /&gt;
&lt;br /&gt;
1) signed_up_team.rb&lt;br /&gt;
&lt;br /&gt;
2) waitlist.rb&lt;br /&gt;
&lt;br /&gt;
3) sign_up_sheet_controller.rb&lt;br /&gt;
&lt;br /&gt;
4) sign_up_sheet.rb&lt;br /&gt;
&lt;br /&gt;
5) sign_up_topic.rb&lt;br /&gt;
&lt;br /&gt;
6) suggestion_controller.rb&lt;br /&gt;
&lt;br /&gt;
7) invitation.rb&lt;br /&gt;
&lt;br /&gt;
== Proposed design ==&lt;br /&gt;
&lt;br /&gt;
=== General Design Goals ===&lt;br /&gt;
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 be testing the existing features so that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
Our goal is to make the experiza system more reliable and have code that is consistent with the standards of object-oriented design.&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
In this Unified Modeling Language (UML), we summarize the details of the system's users and their interactions with the system. &amp;lt;br&amp;gt;&lt;br /&gt;
We have two users to the system '''Student''' and '''Instructor'''. The interactions these users have with the system are stated below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Student Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. Student should be able to perform an action to add their own team to the waitlist.  &amp;lt;br&amp;gt;&lt;br /&gt;
2. Student should be able to drop their own team from the waitlist but not others team.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Instructor Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1.  Delete or purge on the waitlist items are those actions that have to be performed by the instructor/admin and student should not be given access to delete action.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Instructor should be able to add any team to the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Instructor should be able to drop any team from the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
4. Instructor should be able to fetch the details of the teams in a waitlist for a particular topic.&amp;lt;br&amp;gt;&lt;br /&gt;
5. Instructor should be able to fetch the details of the topics in which a team is waitlisted. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_uml_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
Tables associated with '''waitlist_teams''' table:&amp;lt;br&amp;gt;&lt;br /&gt;
1. teams&amp;lt;br&amp;gt;&lt;br /&gt;
2. signed_up_teams&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
waitlist_teams table is referred by the signed_up_teams and teams table as Foreign Key Relationship.&lt;br /&gt;
&lt;br /&gt;
'''team_id''' : foreign key in waitlists_team table referenced by teams table &amp;lt;br&amp;gt;&lt;br /&gt;
'''topic_id''' : foreign key in waitlists_team table reference by signed_up_teams table &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_class_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
== Plan of action ==&lt;br /&gt;
&lt;br /&gt;
=== Changes to the signed_up_teams Table ===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
We plan on retiring/removing the waitlist flag from the signed_up_teams table and separating this functionality. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag will be rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Files and methods to be refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to is_waitlisted should be removed and waitlists must be determined by using the new waitlist_team table.&lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##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. &lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##switch_original_topic_to_approved_suggested_topic&lt;br /&gt;
###Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table&lt;br /&gt;
###Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##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&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
###It checks if topic has slots if yes it adds to signed up team, else creates a signup as waitlist&lt;br /&gt;
###This method should use the new table and call the helper functions of waitlist to perform actions on waitlists&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Move method to fetch all users on waitlist for a topic to waitlist_teams method.&lt;br /&gt;
##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&lt;br /&gt;
##reassign_topic - Use methods that perform actions on waitlist that should be moved to waitlist_helper, also use transactions to make it atomic.&lt;br /&gt;
##update_waitlisted_users - Move method to waitlist_teams model and use the new table&lt;br /&gt;
##find_slots_waitlisted - Move method to waitlist_teams model&lt;br /&gt;
##find_waitlisted_topics - Move method to waitlist_teams model&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification&lt;br /&gt;
##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.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team&lt;br /&gt;
###Removing from waitlist and adding to team to sign up should be as a single transaction&lt;br /&gt;
###There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet&lt;br /&gt;
###All functionality should be moved to waitlist_helper and implemented in a robust and dry manner&lt;br /&gt;
&lt;br /&gt;
===Adding new waitlist_teams Table ===&lt;br /&gt;
We plan to add a new table ''waitlist_teams''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The attributes for the table are team_id(refers to the ''teams'' table), topic_id (refers to the ''sign_up_topics'' table)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This table only stores the waitlisted teams for each topic.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Having separated tables for signups and waitlists will help in managing entries and enforcing constraints and make it easier to implement and extend functionality if required.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
The waitlist_helper class will perform the following operations &lt;br /&gt;
#Delete all waitlists for team&lt;br /&gt;
#Purge all waitlists for topic &lt;br /&gt;
#Add team to waitlist&lt;br /&gt;
#Delete specific team from waitlist&lt;br /&gt;
#Get all waitlisted topics for team&lt;br /&gt;
#Get all waitlisted teams for topic&lt;br /&gt;
#Get first team in waitlist for topic&lt;br /&gt;
#Check waitlist empty for topic&lt;br /&gt;
#Check if team has any waitlists &lt;br /&gt;
#Get the number of waitlisted teams for all topics in an assignment&lt;br /&gt;
&lt;br /&gt;
===Migrating existing waitlists to use new table===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt; &lt;br /&gt;
We plan on writing a migration script to move the waitlists from signed_up_teams table to waitlist_teams table.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This will ensure minimal regression breakages and retain existing functionalities.&lt;br /&gt;
=== Specific Tasks Completed ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
=== Video Demonstration ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
=== Testing Goals and Test Objects ===&lt;br /&gt;
&lt;br /&gt;
''Drawing from the project objectives:''&lt;br /&gt;
#Ways to get added to the waitlist for a topic&lt;br /&gt;
##Team requests a topic that has no slot available.&lt;br /&gt;
##When capacity/max choosers for a topic is increased&lt;br /&gt;
##When a student gets added to a team that already has a signed up topic&lt;br /&gt;
#Ways to get off a waitlist&lt;br /&gt;
##team gets the topic they are waiting for ( all other waitlists are dropped for the team)&lt;br /&gt;
##team drops off the waitlist&lt;br /&gt;
##instructor drops team from the waitlist&lt;br /&gt;
##a drop-topic deadline passes&lt;br /&gt;
##team is deleted&lt;br /&gt;
##student gets added to a new team, then the old team's waitlist should be dropped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RSpec Unit Tests ===&lt;br /&gt;
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''&lt;br /&gt;
*Student Waitlist&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting added to the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has no available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be added to the waitlist for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be enrolled for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted topics getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: Student gets enrolled into a course for which he was waitlisted before.&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted teams getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The deadline for a topic passes.&lt;br /&gt;
  Then: All the waitlisted teams for that particular topic must be dropped.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The enrolled team for a topic drops&lt;br /&gt;
  Then: The team that was waitlisted earlier for the topics must be enrolled.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
'''Student's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Student_waitlist_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Instructor's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_signup_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''Instructor's View With Waitlists'''&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlist.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Test 1:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to add their team to the waitlist by clicking on '''Check''' icon (see the image above) if the team has not signed up in any topic.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 2:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to drop the team from the waitlist by clicking on '''Delete''' icon (see the image above) if they are no longer interested in it.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 3:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to add a student to the topic by clicking on '''Check''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 4:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to delete a student to the topic by clicking on '''Delete''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 5:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the students signup for a topic in the page displayed. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 6:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the topics available &lt;br /&gt;
&lt;br /&gt;
''' Test 7:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view waitlisted and signed up teams for all the topics in the assignment&lt;br /&gt;
&lt;br /&gt;
''' Test 8:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to drop waitlisted team for a topics in the assignment&lt;br /&gt;
&lt;br /&gt;
we will be adding more test cases as the project progress.&lt;br /&gt;
&lt;br /&gt;
=== Regression Testing ===&lt;br /&gt;
''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 ''&lt;br /&gt;
''old test cases still pass.''&lt;br /&gt;
&lt;br /&gt;
# Make sure all existing waitlist functionality still passes&lt;br /&gt;
&lt;br /&gt;
== Conclusions and Future Work ==&lt;br /&gt;
=== Comprehensive Testing and Scope ===&lt;br /&gt;
* ''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
Pull request&lt;br /&gt;
&lt;br /&gt;
Deployed application with changes&lt;br /&gt;
&lt;br /&gt;
Forked repository&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
=== Students ===&lt;br /&gt;
*Krishna Saurabh Vankadaru (''kvankad'')&lt;br /&gt;
*Samson Reddy Mulkur (''smulkur'')&lt;br /&gt;
*Akhil Kumar Mengani (''amengan'')&lt;br /&gt;
*Sai Naga Vamshi Chidara (''schidar'')&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
*Naman Shrimali (''nshrima'')&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144863</id>
		<title>CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144863"/>
		<updated>2022-04-12T02:08:26Z</updated>

		<summary type="html">&lt;p&gt;Amengan: /* Proposed design and Plan of action */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
&lt;br /&gt;
Waitlist feature is utilized during subject assignment in an assignment. For example, during the topic allocation of the Final Project (and design doc), each team had the opportunity to sign up for a topic in which they were interested or to add to a waitlist of a topic in which they were not interested. When a team is added to the queue, many circumstances emerge. The waitlist feature currently does not adhere to the open-closed design paradigm. As a result, our task in this project is to resolve these issues by rewriting the waitlist functionality.&lt;br /&gt;
&lt;br /&gt;
Whenever a team requests for a topic, there are two things that can happen. &lt;br /&gt;
&lt;br /&gt;
* '''The topic is available''': In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ). This is pretty straightforward.&lt;br /&gt;
&lt;br /&gt;
* '''The topic is unavailable''': In this case, the team is waitlisted for the topic. When any other team drops this topic, a waitlisted team will be assigned for this topic. &lt;br /&gt;
&lt;br /&gt;
Our task is to simplify the way we are handling the second case. For each topic, we will have to have a waitlist object associated with it. If a team has requested for a topic that is not available, the team would just be queued on to the waitlist for this topic. In the waitlist object, we will have to maintain the team_id and the topic id for which this team will be waitlisted. In the current implementation, the waitlisting functionality is scattered across multiple files. All this has to be consolidated and placed in fewer number of places ( model file and helper class ).&lt;br /&gt;
&lt;br /&gt;
=== Issues with existing functionality ===&lt;br /&gt;
The current implementation has multiple models and controllers ( sign_up_topic.rb, waitlist.rb, invitation.rb, lottery_controller.rb, suggestion_controller.rb and signed_up_team.rb etc ) perform actions that indirectly affect the waitlist ( adding or removing teams from waitlist ). As a result, modifying the waitlist is being performed by multiple models and controllers. So, there is a lot of redundancy associated with basic waitlist operations in multiple files.&lt;br /&gt;
&lt;br /&gt;
=== Overview of Major Changes ===&lt;br /&gt;
To simplify waitlist functionality and to reduce code redundancy, we will be moving all the functions present in multiple controllers and model files that manipulate waitlists to waitlist.rb. All these classes will now just invoke methods of waitlist.rb. The list of files and methods which will be modified are &lt;br /&gt;
&lt;br /&gt;
1) signed_up_team.rb&lt;br /&gt;
&lt;br /&gt;
2) waitlist.rb&lt;br /&gt;
&lt;br /&gt;
3) sign_up_sheet_controller.rb&lt;br /&gt;
&lt;br /&gt;
4) sign_up_sheet.rb&lt;br /&gt;
&lt;br /&gt;
5) sign_up_topic.rb&lt;br /&gt;
&lt;br /&gt;
6) suggestion_controller.rb&lt;br /&gt;
&lt;br /&gt;
7) invitation.rb&lt;br /&gt;
&lt;br /&gt;
== Proposed design ==&lt;br /&gt;
&lt;br /&gt;
=== General Design Goals ===&lt;br /&gt;
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 be testing the existing features so that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
Our goal is to make the experiza system more reliable and have code that is consistent with the standards of object-oriented design.&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
In this Unified Modeling Language (UML), we summarize the details of the system's users and their interactions with the system. &amp;lt;br&amp;gt;&lt;br /&gt;
We have two users to the system '''Student''' and '''Instructor'''. The interactions these users have with the system are stated below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Student Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. Student should be able to perform an action to add their own team to the waitlist.  &amp;lt;br&amp;gt;&lt;br /&gt;
2. Student should be able to drop their own team from the waitlist but not others team.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Instructor Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1.  Delete or purge on the waitlist items are those actions that have to be performed by the instructor/admin and student should not be given access to delete action.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Instructor should be able to add any team to the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Instructor should be able to drop any team from the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
4. Instructor should be able to fetch the details of the teams in a waitlist for a particular topic.&amp;lt;br&amp;gt;&lt;br /&gt;
5. Instructor should be able to fetch the details of the topics in which a team is waitlisted. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_uml_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
Tables associated with '''waitlist_teams''' table:&amp;lt;br&amp;gt;&lt;br /&gt;
1. teams&amp;lt;br&amp;gt;&lt;br /&gt;
2. signed_up_teams&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
waitlist_teams table is referred by the signed_up_teams and teams table as Foreign Key Relationship.&lt;br /&gt;
&lt;br /&gt;
'''team_id''' : foreign key in waitlists_team table referenced by teams table &amp;lt;br&amp;gt;&lt;br /&gt;
'''topic_id''' : foreign key in waitlists_team table reference by signed_up_teams table &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_class_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
== Plan of action ==&lt;br /&gt;
&lt;br /&gt;
=== Changes to the signed_up_teams Table ===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
We plan on retiring/removing the waitlist flag from the signed_up_teams table and separating this functionality. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag will be rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Files and methods to be refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to is_waitlisted should be removed and waitlists must be determined by using the new waitlist_team table.&lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##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. &lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##switch_original_topic_to_approved_suggested_topic&lt;br /&gt;
###Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table&lt;br /&gt;
###Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##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&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
###It checks if topic has slots if yes it adds to signed up team, else creates a signup as waitlist&lt;br /&gt;
###This method should use the new table and call the helper functions of waitlist to perform actions on waitlists&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Move method to fetch all users on waitlist for a topic to waitlist_teams method.&lt;br /&gt;
##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&lt;br /&gt;
##reassign_topic - Use methods that perform actions on waitlist that should be moved to waitlist_helper, also use transactions to make it atomic.&lt;br /&gt;
##update_waitlisted_users - Move method to waitlist_teams model and use the new table&lt;br /&gt;
##find_slots_waitlisted - Move method to waitlist_teams model&lt;br /&gt;
##find_waitlisted_topics - Move method to waitlist_teams model&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification&lt;br /&gt;
##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.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team&lt;br /&gt;
###Removing from waitlist and adding to team to sign up should be as a single transaction&lt;br /&gt;
###There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet&lt;br /&gt;
###All functionality should be moved to waitlist_helper and implemented in a robust and dry manner&lt;br /&gt;
&lt;br /&gt;
===Adding new waitlist_teams Table ===&lt;br /&gt;
We plan to add a new table ''waitlist_teams''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The attributes for the table are team_id(refers to the ''teams'' table), topic_id (refers to the ''sign_up_topics'' table)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This table only stores the waitlisted teams for each topic.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Having separated tables for signups and waitlists will help in managing entries and enforcing constraints and make it easier to implement and extend functionality if required.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
The waitlist_helper class will perform the following operations &lt;br /&gt;
#Delete all waitlists for team&lt;br /&gt;
#Purge all waitlists for topic &lt;br /&gt;
#Add team to waitlist&lt;br /&gt;
#Delete specific team from waitlist&lt;br /&gt;
#Get all waitlisted topics for team&lt;br /&gt;
#Get all waitlisted teams for topic&lt;br /&gt;
#Get first team in waitlist for topic&lt;br /&gt;
#Check waitlist empty for topic&lt;br /&gt;
#Check if team has any waitlists &lt;br /&gt;
#Get the number of waitlisted teams for all topics in an assignment&lt;br /&gt;
&lt;br /&gt;
===Migrating existing waitlists to use new table===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt; &lt;br /&gt;
We plan on writing a migration script to move the waitlists from signed_up_teams table to waitlist_teams table.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This will ensure minimal regression breakages and retain existing functionalities.&lt;br /&gt;
=== Specific Tasks Completed ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
=== Video Demonstration ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
=== Testing Goals and Test Objects ===&lt;br /&gt;
&lt;br /&gt;
''Drawing from the project objectives:''&lt;br /&gt;
#Ways to get added to the waitlist for a topic&lt;br /&gt;
##Team requests a topic that has no slot available.&lt;br /&gt;
##When capacity/max choosers for a topic is increased&lt;br /&gt;
##When a student gets added to a team that already has a signed up topic&lt;br /&gt;
#Ways to get off a waitlist&lt;br /&gt;
##team gets the topic they are waiting for ( all other waitlists are dropped for the team)&lt;br /&gt;
##team drops off the waitlist&lt;br /&gt;
##instructor drops team from the waitlist&lt;br /&gt;
##a drop-topic deadline passes&lt;br /&gt;
##team is deleted&lt;br /&gt;
##student gets added to a new team, then the old team's waitlist should be dropped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RSpec Unit Tests ===&lt;br /&gt;
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''&lt;br /&gt;
*Student Waitlist&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting added to the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has no available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be added to the waitlist for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be enrolled for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted topics getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: Student gets enrolled into a course for which he was waitlisted before.&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted teams getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The deadline for a topic passes.&lt;br /&gt;
  Then: All the waitlisted teams for that particular topic must be dropped.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The enrolled team for a topic drops&lt;br /&gt;
  Then: The team that was waitlisted earlier for the topics must be enrolled.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
'''Student's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Student_waitlist_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Instructor's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_signup_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''Instructor's View With Waitlists'''&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlist.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Test 1:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to add their team to the waitlist by clicking on '''Check''' icon (see the image above) if the team has not signed up in any topic.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 2:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to drop the team from the waitlist by clicking on '''Delete''' icon (see the image above) if they are no longer interested in it.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 3:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to add a student to the topic by clicking on '''Check''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 4:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to delete a student to the topic by clicking on '''Delete''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 5:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the students signup for a topic in the page displayed. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 6:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the topics available &lt;br /&gt;
&lt;br /&gt;
''' Test 7:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view waitlisted and signed up teams for all the topics in the assignment&lt;br /&gt;
&lt;br /&gt;
''' Test 8:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to drop waitlisted team for a topics in the assignment&lt;br /&gt;
&lt;br /&gt;
we will be adding more test cases as the project progress.&lt;br /&gt;
&lt;br /&gt;
=== Regression Testing ===&lt;br /&gt;
''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 ''&lt;br /&gt;
''old test cases still pass.''&lt;br /&gt;
&lt;br /&gt;
# Make sure all existing waitlist functionality still passes&lt;br /&gt;
&lt;br /&gt;
== Conclusions and Future Work ==&lt;br /&gt;
=== Comprehensive Testing and Scope ===&lt;br /&gt;
* ''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
Pull request&lt;br /&gt;
&lt;br /&gt;
Deployed application with changes&lt;br /&gt;
&lt;br /&gt;
Forked repository&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
=== Students ===&lt;br /&gt;
*Krishna Saurabh Vankadaru (''kvankad'')&lt;br /&gt;
*Samson Reddy Mulkur (''smulkur'')&lt;br /&gt;
*Akhil Kumar Mengani (''amengan'')&lt;br /&gt;
*Sai Naga Vamshi Chidara (''schidar'')&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
*Naman Shrimali (''nshrima'')&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144861</id>
		<title>CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144861"/>
		<updated>2022-04-12T02:07:06Z</updated>

		<summary type="html">&lt;p&gt;Amengan: /* Problem Statement */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
&lt;br /&gt;
Waitlist feature is utilized during subject assignment in an assignment. For example, during the topic allocation of the Final Project (and design doc), each team had the opportunity to sign up for a topic in which they were interested or to add to a waitlist of a topic in which they were not interested. When a team is added to the queue, many circumstances emerge. The waitlist feature currently does not adhere to the open-closed design paradigm. As a result, our task in this project is to resolve these issues by rewriting the waitlist functionality.&lt;br /&gt;
&lt;br /&gt;
Whenever a team requests for a topic, there are two things that can happen. &lt;br /&gt;
&lt;br /&gt;
* '''The topic is available''': In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ). This is pretty straightforward.&lt;br /&gt;
&lt;br /&gt;
* '''The topic is unavailable''': In this case, the team is waitlisted for the topic. When any other team drops this topic, a waitlisted team will be assigned for this topic. &lt;br /&gt;
&lt;br /&gt;
Our task is to simplify the way we are handling the second case. For each topic, we will have to have a waitlist object associated with it. If a team has requested for a topic that is not available, the team would just be queued on to the waitlist for this topic. In the waitlist object, we will have to maintain the team_id and the topic id for which this team will be waitlisted. In the current implementation, the waitlisting functionality is scattered across multiple files. All this has to be consolidated and placed in fewer number of places ( model file and helper class ).&lt;br /&gt;
&lt;br /&gt;
=== Issues with existing functionality ===&lt;br /&gt;
The current implementation has multiple models and controllers ( sign_up_topic.rb, waitlist.rb, invitation.rb, lottery_controller.rb, suggestion_controller.rb and signed_up_team.rb etc ) perform actions that indirectly affect the waitlist ( adding or removing teams from waitlist ). As a result, modifying the waitlist is being performed by multiple models and controllers. So, there is a lot of redundancy associated with basic waitlist operations in multiple files.&lt;br /&gt;
&lt;br /&gt;
=== Overview of Major Changes ===&lt;br /&gt;
To simplify waitlist functionality and to reduce code redundancy, we will be moving all the functions present in multiple controllers and model files that manipulate waitlists to waitlist.rb. All these classes will now just invoke methods of waitlist.rb. The list of files and methods which will be modified are &lt;br /&gt;
&lt;br /&gt;
1) signed_up_team.rb&lt;br /&gt;
&lt;br /&gt;
2) waitlist.rb&lt;br /&gt;
&lt;br /&gt;
3) sign_up_sheet_controller.rb&lt;br /&gt;
&lt;br /&gt;
4) sign_up_sheet.rb&lt;br /&gt;
&lt;br /&gt;
5) sign_up_topic.rb&lt;br /&gt;
&lt;br /&gt;
6) suggestion_controller.rb&lt;br /&gt;
&lt;br /&gt;
7) invitation.rb&lt;br /&gt;
&lt;br /&gt;
== Proposed design and Plan of action ==&lt;br /&gt;
&lt;br /&gt;
=== General Design Goals ===&lt;br /&gt;
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 be testing the existing features so that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
Our goal is to make the experiza system more reliable and have code that is consistent with the standards of object-oriented design.&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
In this Unified Modeling Language (UML), we summarize the details of the system's users and their interactions with the system. &amp;lt;br&amp;gt;&lt;br /&gt;
We have two users to the system '''Student''' and '''Instructor'''. The interactions these users have with the system are stated below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Student Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. Student should be able to perform an action to add their own team to the waitlist.  &amp;lt;br&amp;gt;&lt;br /&gt;
2. Student should be able to drop their own team from the waitlist but not others team.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Instructor Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1.  Delete or purge on the waitlist items are those actions that have to be performed by the instructor/admin and student should not be given access to delete action.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Instructor should be able to add any team to the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Instructor should be able to drop any team from the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
4. Instructor should be able to fetch the details of the teams in a waitlist for a particular topic.&amp;lt;br&amp;gt;&lt;br /&gt;
5. Instructor should be able to fetch the details of the topics in which a team is waitlisted. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_uml_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
Tables associated with '''waitlist_teams''' table:&amp;lt;br&amp;gt;&lt;br /&gt;
1. teams&amp;lt;br&amp;gt;&lt;br /&gt;
2. signed_up_teams&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
waitlist_teams table is referred by the signed_up_teams and teams table as Foreign Key Relationship.&lt;br /&gt;
&lt;br /&gt;
'''team_id''' : foreign key in waitlists_team table referenced by teams table &amp;lt;br&amp;gt;&lt;br /&gt;
'''topic_id''' : foreign key in waitlists_team table reference by signed_up_teams table &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_class_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Changes to the signed_up_teams Table ===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
We plan on retiring/removing the waitlist flag from the signed_up_teams table and separating this functionality. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag will be rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Files and methods to be refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to is_waitlisted should be removed and waitlists must be determined by using the new waitlist_team table.&lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##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. &lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##switch_original_topic_to_approved_suggested_topic&lt;br /&gt;
###Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table&lt;br /&gt;
###Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##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&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
###It checks if topic has slots if yes it adds to signed up team, else creates a signup as waitlist&lt;br /&gt;
###This method should use the new table and call the helper functions of waitlist to perform actions on waitlists&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Move method to fetch all users on waitlist for a topic to waitlist_teams method.&lt;br /&gt;
##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&lt;br /&gt;
##reassign_topic - Use methods that perform actions on waitlist that should be moved to waitlist_helper, also use transactions to make it atomic.&lt;br /&gt;
##update_waitlisted_users - Move method to waitlist_teams model and use the new table&lt;br /&gt;
##find_slots_waitlisted - Move method to waitlist_teams model&lt;br /&gt;
##find_waitlisted_topics - Move method to waitlist_teams model&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification&lt;br /&gt;
##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.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team&lt;br /&gt;
###Removing from waitlist and adding to team to sign up should be as a single transaction&lt;br /&gt;
###There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet&lt;br /&gt;
###All functionality should be moved to waitlist_helper and implemented in a robust and dry manner&lt;br /&gt;
&lt;br /&gt;
===Adding new waitlist_teams Table ===&lt;br /&gt;
We plan to add a new table ''waitlist_teams''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The attributes for the table are team_id(refers to the ''teams'' table), topic_id (refers to the ''sign_up_topics'' table)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This table only stores the waitlisted teams for each topic.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Having separated tables for signups and waitlists will help in managing entries and enforcing constraints and make it easier to implement and extend functionality if required.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
The waitlist_helper class will perform the following operations &lt;br /&gt;
#Delete all waitlists for team&lt;br /&gt;
#Purge all waitlists for topic &lt;br /&gt;
#Add team to waitlist&lt;br /&gt;
#Delete specific team from waitlist&lt;br /&gt;
#Get all waitlisted topics for team&lt;br /&gt;
#Get all waitlisted teams for topic&lt;br /&gt;
#Get first team in waitlist for topic&lt;br /&gt;
#Check waitlist empty for topic&lt;br /&gt;
#Check if team has any waitlists &lt;br /&gt;
#Get the number of waitlisted teams for all topics in an assignment&lt;br /&gt;
&lt;br /&gt;
===Migrating existing waitlists to use new table===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt; &lt;br /&gt;
We plan on writing a migration script to move the waitlists from signed_up_teams table to waitlist_teams table.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This will ensure minimal regression breakages and retain existing functionalities.&lt;br /&gt;
=== Specific Tasks Completed ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
=== Video Demonstration ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
=== Testing Goals and Test Objects ===&lt;br /&gt;
&lt;br /&gt;
''Drawing from the project objectives:''&lt;br /&gt;
#Ways to get added to the waitlist for a topic&lt;br /&gt;
##Team requests a topic that has no slot available.&lt;br /&gt;
##When capacity/max choosers for a topic is increased&lt;br /&gt;
##When a student gets added to a team that already has a signed up topic&lt;br /&gt;
#Ways to get off a waitlist&lt;br /&gt;
##team gets the topic they are waiting for ( all other waitlists are dropped for the team)&lt;br /&gt;
##team drops off the waitlist&lt;br /&gt;
##instructor drops team from the waitlist&lt;br /&gt;
##a drop-topic deadline passes&lt;br /&gt;
##team is deleted&lt;br /&gt;
##student gets added to a new team, then the old team's waitlist should be dropped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RSpec Unit Tests ===&lt;br /&gt;
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''&lt;br /&gt;
*Student Waitlist&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting added to the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has no available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be added to the waitlist for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be enrolled for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted topics getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: Student gets enrolled into a course for which he was waitlisted before.&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted teams getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The deadline for a topic passes.&lt;br /&gt;
  Then: All the waitlisted teams for that particular topic must be dropped.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The enrolled team for a topic drops&lt;br /&gt;
  Then: The team that was waitlisted earlier for the topics must be enrolled.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
'''Student's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Student_waitlist_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Instructor's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_signup_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''Instructor's View With Waitlists'''&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlist.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Test 1:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to add their team to the waitlist by clicking on '''Check''' icon (see the image above) if the team has not signed up in any topic.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 2:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to drop the team from the waitlist by clicking on '''Delete''' icon (see the image above) if they are no longer interested in it.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 3:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to add a student to the topic by clicking on '''Check''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 4:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to delete a student to the topic by clicking on '''Delete''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 5:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the students signup for a topic in the page displayed. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 6:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the topics available &lt;br /&gt;
&lt;br /&gt;
''' Test 7:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view waitlisted and signed up teams for all the topics in the assignment&lt;br /&gt;
&lt;br /&gt;
''' Test 8:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to drop waitlisted team for a topics in the assignment&lt;br /&gt;
&lt;br /&gt;
we will be adding more test cases as the project progress.&lt;br /&gt;
&lt;br /&gt;
=== Regression Testing ===&lt;br /&gt;
''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 ''&lt;br /&gt;
''old test cases still pass.''&lt;br /&gt;
&lt;br /&gt;
# Make sure all existing waitlist functionality still passes&lt;br /&gt;
&lt;br /&gt;
== Conclusions and Future Work ==&lt;br /&gt;
=== Comprehensive Testing and Scope ===&lt;br /&gt;
* ''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
Pull request&lt;br /&gt;
&lt;br /&gt;
Deployed application with changes&lt;br /&gt;
&lt;br /&gt;
Forked repository&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
=== Students ===&lt;br /&gt;
*Krishna Saurabh Vankadaru (''kvankad'')&lt;br /&gt;
*Samson Reddy Mulkur (''smulkur'')&lt;br /&gt;
*Akhil Kumar Mengani (''amengan'')&lt;br /&gt;
*Sai Naga Vamshi Chidara (''schidar'')&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
*Naman Shrimali (''nshrima'')&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Instructor_signup_page_2.png&amp;diff=144586</id>
		<title>File:Instructor signup page 2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Instructor_signup_page_2.png&amp;diff=144586"/>
		<updated>2022-04-07T03:49:17Z</updated>

		<summary type="html">&lt;p&gt;Amengan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144568</id>
		<title>CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144568"/>
		<updated>2022-04-07T03:10:54Z</updated>

		<summary type="html">&lt;p&gt;Amengan: /* Manual Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
Whenever a team requests for a topic, there are two things that can happen. &lt;br /&gt;
&lt;br /&gt;
* '''The topic is available''': In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ). This is pretty straightforward.&lt;br /&gt;
&lt;br /&gt;
* '''The topic is unavailable''': In this case, the team is waitlisted for the topic. When any other team drops this topic, a waitlisted team will be assigned for this topic. &lt;br /&gt;
&lt;br /&gt;
Our task is to simplify the way we are handling the second case. For each topic, we will have to have a waitlist object associated with it. If a team has requested for a topic that is not available, the team would just be queued on to the waitlist for this topic. In the waitlist object, we will have to maintain the team_id and the topic id for which this team will be waitlisted. In the current implementation, the waitlisting functionality is scattered across multiple files. All this has to be consolidated and placed in fewer number of places ( model file and helper class ).&lt;br /&gt;
&lt;br /&gt;
=== Issues with existing functionality ===&lt;br /&gt;
The current implementation has multiple models and controllers ( sign_up_topic.rb, waitlist.rb, invitation.rb, lottery_controller.rb, suggestion_controller.rb and signed_up_team.rb etc ) perform actions that indirectly affect the waitlist ( adding or removing teams from waitlist ). As a result, modifying the waitlist is being performed by multiple models and controllers. So, there is a lot of redundancy associated with basic waitlist operations in multiple files.&lt;br /&gt;
&lt;br /&gt;
=== Overview of Major Changes ===&lt;br /&gt;
To simplify waitlist functionality and to reduce code redundancy, we will be moving all the functions present in multiple controllers and model files that manipulate waitlists to waitlist.rb. All these classes will now just invoke methods of waitlist.rb. The list of files and methods which will be modified are &lt;br /&gt;
&lt;br /&gt;
1) signed_up_team.rb&lt;br /&gt;
&lt;br /&gt;
2) waitlist.rb&lt;br /&gt;
&lt;br /&gt;
3) sign_up_sheet_controller.rb&lt;br /&gt;
&lt;br /&gt;
4) sign_up_sheet.rb&lt;br /&gt;
&lt;br /&gt;
5) sign_up_topic.rb&lt;br /&gt;
&lt;br /&gt;
6) suggestion_controller.rb&lt;br /&gt;
&lt;br /&gt;
7) invitation.rb&lt;br /&gt;
&lt;br /&gt;
== Proposed design and Plan of action ==&lt;br /&gt;
&lt;br /&gt;
=== General Design Goals ===&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* We are only changing what we set out to change when fixing a particular issue.&lt;br /&gt;
* We are not breaking what was working before we deployed our fix.&lt;br /&gt;
&lt;br /&gt;
We believe at the end our changes will increase the quality of Expertiza and improve the experience for users an developers alike.&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
In this Unified Modeling Language (UML), we summarize the details of the system's users such as instructors and students and their interactions with the system. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Student Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. Student should be able to perform an action to add their own team to the waitlist.  &amp;lt;br&amp;gt;&lt;br /&gt;
2. Student should be able to drop their own team from the waitlist but not others team.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Instructor Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1.  Delete or purge on the waitlist items are those actions that have to be performed by the instructor/admin and student should not be given access to delete action.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Instructor should be able to add any team to the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Instructor should be able to drop any team from the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
4. Instructor should be able to fetch the details of the teams in a waitlist for a particular topic.&amp;lt;br&amp;gt;&lt;br /&gt;
5. Instructor should be able to fetch the details of the topics in which a team is waitlisted. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_uml_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
Tables associated with '''waitlist_teams''' table:&amp;lt;br&amp;gt;&lt;br /&gt;
1. teams&amp;lt;br&amp;gt;&lt;br /&gt;
2. signed_up_teams&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
waitlist_teams table is referred by the signed_up_teams and teams table as Foreign Key Relationship.&lt;br /&gt;
&lt;br /&gt;
'''team_id''' : foreign key in waitlists_team table referenced by teams table &amp;lt;br&amp;gt;&lt;br /&gt;
'''topic_id''' : foreign key in waitlists_team table reference by signed_up_teams table &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_class_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Changes to the signed_up_teams Table ===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
We plan on retiring/removing the waitlist flag from the signed_up_teams table and separating this functionality. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag will be rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Files and methods to be refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to is_waitlisted should be removed and waitlists must be determined by using the new waitlist_team table.&lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##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. &lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##switch_original_topic_to_approved_suggested_topic&lt;br /&gt;
###Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table&lt;br /&gt;
###Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##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&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
###It checks if topic has slots if yes it adds to signed up team, else creates a signup as waitlist&lt;br /&gt;
###This method should use the new table and call the helper functions of waitlist to perform actions on waitlists&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Move method to fetch all users on waitlist for a topic to waitlist_teams method.&lt;br /&gt;
##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&lt;br /&gt;
##reassign_topic - Use methods that perform actions on waitlist that should be moved to waitlist_helper, also use transactions to make it atomic.&lt;br /&gt;
##update_waitlisted_users - Move method to waitlist_teams model and use the new table&lt;br /&gt;
##find_slots_waitlisted - Move method to waitlist_teams model&lt;br /&gt;
##find_waitlisted_topics - Move method to waitlist_teams model&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification&lt;br /&gt;
##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.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team&lt;br /&gt;
###Removing from waitlist and adding to team to sign up should be as a single transaction&lt;br /&gt;
###There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet&lt;br /&gt;
###All functionality should be moved to waitlist_helper and implemented in a robust and dry manner&lt;br /&gt;
&lt;br /&gt;
===Adding new waitlist_teams Table ===&lt;br /&gt;
We plan to add a new table ''waitlist_teams''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The attributes for the table are team_id(refers to the ''teams'' table), topic_id (refers to the ''sign_up_topics'' table)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This table only stores the waitlisted teams for each topic.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Having separated tables for signups and waitlists will help in managing entries and enforcing constraints and make it easier to implement and extend functionality if required.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
The waitlist_helper class will perform the following operations &lt;br /&gt;
#Delete all waitlists for team&lt;br /&gt;
#Purge all waitlists for topic &lt;br /&gt;
#Add team to waitlist&lt;br /&gt;
#Delete specific team from waitlist&lt;br /&gt;
#Get all waitlisted topics for team&lt;br /&gt;
#Get all waitlisted teams for topic&lt;br /&gt;
#Get first team in waitlist for topic&lt;br /&gt;
#Check waitlist empty for topic&lt;br /&gt;
#Check if team has any waitlists &lt;br /&gt;
#Get the number of waitlisted teams for all topics in an assignment&lt;br /&gt;
&lt;br /&gt;
===Migrating existing waitlists to use new table===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt; &lt;br /&gt;
We plan on writing a migration script to move the waitlists from signed_up_teams table to waitlist_teams table.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This will ensure minimal regression breakages and retain existing functionalities.&lt;br /&gt;
=== Specific Tasks Completed ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
=== Video Demonstration ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
=== Testing Goals and Test Objects ===&lt;br /&gt;
&lt;br /&gt;
''Drawing from the project objectives:''&lt;br /&gt;
#Ways to get added to the waitlist for a topic&lt;br /&gt;
##Team requests a topic that has no slot available.&lt;br /&gt;
##When capacity/max choosers for a topic is increased&lt;br /&gt;
##When a student gets added to a team that already has a signed up topic&lt;br /&gt;
#Ways to get off a waitlist&lt;br /&gt;
##team gets the topic they are waiting for ( all other waitlists are dropped for the team)&lt;br /&gt;
##team drops off the waitlist&lt;br /&gt;
##instructor drops team from the waitlist&lt;br /&gt;
##a drop-topic deadline passes&lt;br /&gt;
##team is deleted&lt;br /&gt;
##student gets added to a new team, then the old team's waitlist should be dropped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RSpec Unit Tests ===&lt;br /&gt;
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''&lt;br /&gt;
*Student Waitlist&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting added to the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has no available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be added to the waitlist for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be enrolled for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted topics getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: Student gets enrolled into a course for which he was waitlisted before.&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted teams getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The deadline for a topic passes.&lt;br /&gt;
  Then: All the waitlisted teams for that particular topic must be dropped.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The enrolled team for a topic drops&lt;br /&gt;
  Then: The team that was waitlisted earlier for the topics must be enrolled.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
'''Student's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Student_waitlist_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Instructor's View'''&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_signup_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Test 1:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to add their team to the waitlist by clicking on '''Check''' icon (see the image above) if the team has not signed up in any topic.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 2:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to drop the team from the waitlist by clicking on '''Delete''' icon (see the image above) if they are no longer interested in it.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 3:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to add a student to the topic by clicking on '''Check''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 4:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to delete a student to the topic by clicking on '''Delete''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 5:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the students signup for a topic in the page displayed. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 6:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to view all the topics available &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
we will be adding more test cases as the project progress.&lt;br /&gt;
&lt;br /&gt;
=== Regression Testing ===&lt;br /&gt;
''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 ''&lt;br /&gt;
''old test cases still pass.''&lt;br /&gt;
&lt;br /&gt;
# Make sure all existing waitlist functionality still passes&lt;br /&gt;
&lt;br /&gt;
== Conclusions and Future Work ==&lt;br /&gt;
=== Comprehensive Testing and Scope ===&lt;br /&gt;
* ''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
Pull request&lt;br /&gt;
&lt;br /&gt;
Deployed application with changes&lt;br /&gt;
&lt;br /&gt;
Forked repository&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
=== Students ===&lt;br /&gt;
*Krishna Saurabh Vankadaru (''kvankad'')&lt;br /&gt;
*Samson Reddy Mulkur (''smulkur'')&lt;br /&gt;
*Akhil Kumar Mengani (''amengan'')&lt;br /&gt;
*Sai Naga Vamshi Chidara (''schidar'')&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
*Naman Shrimali (''nshrima'')&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144565</id>
		<title>CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144565"/>
		<updated>2022-04-07T03:01:33Z</updated>

		<summary type="html">&lt;p&gt;Amengan: /* Manual Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
Whenever a team requests for a topic, there are two things that can happen. &lt;br /&gt;
&lt;br /&gt;
* '''The topic is available''': In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ). This is pretty straightforward.&lt;br /&gt;
&lt;br /&gt;
* '''The topic is unavailable''': In this case, the team is waitlisted for the topic. When any other team drops this topic, a waitlisted team will be assigned for this topic. &lt;br /&gt;
&lt;br /&gt;
Our task is to simplify the way we are handling the second case. For each topic, we will have to have a waitlist object associated with it. If a team has requested for a topic that is not available, the team would just be queued on to the waitlist for this topic. In the waitlist object, we will have to maintain the team_id and the topic id for which this team will be waitlisted. In the current implementation, the waitlisting functionality is scattered across multiple files. All this has to be consolidated and placed in fewer number of places ( model file and helper class ).&lt;br /&gt;
&lt;br /&gt;
=== Issues with existing functionality ===&lt;br /&gt;
The current implementation has multiple models and controllers ( sign_up_topic.rb, waitlist.rb, invitation.rb, lottery_controller.rb, suggestion_controller.rb and signed_up_team.rb etc ) perform actions that indirectly affect the waitlist ( adding or removing teams from waitlist ). As a result, modifying the waitlist is being performed by multiple models and controllers. So, there is a lot of redundancy associated with basic waitlist operations in multiple files.&lt;br /&gt;
&lt;br /&gt;
=== Overview of Major Changes ===&lt;br /&gt;
To simplify waitlist functionality and to reduce code redundancy, we will be moving all the functions present in multiple controllers and model files that manipulate waitlists to waitlist.rb. All these classes will now just invoke methods of waitlist.rb. The list of files and methods which will be modified are &lt;br /&gt;
&lt;br /&gt;
1) signed_up_team.rb&lt;br /&gt;
&lt;br /&gt;
2) waitlist.rb&lt;br /&gt;
&lt;br /&gt;
3) sign_up_sheet_controller.rb&lt;br /&gt;
&lt;br /&gt;
4) sign_up_sheet.rb&lt;br /&gt;
&lt;br /&gt;
5) sign_up_topic.rb&lt;br /&gt;
&lt;br /&gt;
6) suggestion_controller.rb&lt;br /&gt;
&lt;br /&gt;
7) invitation.rb&lt;br /&gt;
&lt;br /&gt;
== Proposed design and Plan of action ==&lt;br /&gt;
&lt;br /&gt;
=== General Design Goals ===&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* We are only changing what we set out to change when fixing a particular issue.&lt;br /&gt;
* We are not breaking what was working before we deployed our fix.&lt;br /&gt;
&lt;br /&gt;
We believe at the end our changes will increase the quality of Expertiza and improve the experience for users an developers alike.&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
In this Unified Modeling Language (UML), we summarize the details of the system's users such as instructors and students and their interactions with the system. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Student Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. Student should be able to perform an action to add their own team to the waitlist.  &amp;lt;br&amp;gt;&lt;br /&gt;
2. Student should be able to drop their own team from the waitlist but not others team.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Instructor Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1.  Delete or purge on the waitlist items are those actions that have to be performed by the instructor/admin and student should not be given access to delete action.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Instructor should be able to add any team to the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Instructor should be able to drop any team from the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
4. Instructor should be able to fetch the details of the teams in a waitlist for a particular topic.&amp;lt;br&amp;gt;&lt;br /&gt;
5. Instructor should be able to fetch the details of the topics in which a team is waitlisted. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_uml_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
Tables associated with '''waitlist_teams''' table:&amp;lt;br&amp;gt;&lt;br /&gt;
1. teams&amp;lt;br&amp;gt;&lt;br /&gt;
2. signed_up_teams&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
waitlist_teams table is referred by the signed_up_teams and teams table as Foreign Key Relationship.&lt;br /&gt;
&lt;br /&gt;
'''team_id''' : foreign key in waitlists_team table referenced by teams table &amp;lt;br&amp;gt;&lt;br /&gt;
'''topic_id''' : foreign key in waitlists_team table reference by signed_up_teams table &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_class_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Changes to the signed_up_teams Table ===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
We plan on retiring/removing the waitlist flag from the signed_up_teams table and separating this functionality. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag will be rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Files and methods to be refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to is_waitlisted should be removed and waitlists must be determined by using the new waitlist_team table.&lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##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. &lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##switch_original_topic_to_approved_suggested_topic&lt;br /&gt;
###Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table&lt;br /&gt;
###Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##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&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
###It checks if topic has slots if yes it adds to signed up team, else creates a signup as waitlist&lt;br /&gt;
###This method should use the new table and call the helper functions of waitlist to perform actions on waitlists&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Move method to fetch all users on waitlist for a topic to waitlist_teams method.&lt;br /&gt;
##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&lt;br /&gt;
##reassign_topic - Use methods that perform actions on waitlist that should be moved to waitlist_helper, also use transactions to make it atomic.&lt;br /&gt;
##update_waitlisted_users - Move method to waitlist_teams model and use the new table&lt;br /&gt;
##find_slots_waitlisted - Move method to waitlist_teams model&lt;br /&gt;
##find_waitlisted_topics - Move method to waitlist_teams model&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification&lt;br /&gt;
##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.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team&lt;br /&gt;
###Removing from waitlist and adding to team to sign up should be as a single transaction&lt;br /&gt;
###There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet&lt;br /&gt;
###All functionality should be moved to waitlist_helper and implemented in a robust and dry manner&lt;br /&gt;
&lt;br /&gt;
===Adding new waitlist_teams Table ===&lt;br /&gt;
We plan to add a new table ''waitlist_teams''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The attributes for the table are team_id(refers to the ''teams'' table), topic_id (refers to the ''sign_up_topics'' table)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This table only stores the waitlisted teams for each topic.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Having separated tables for signups and waitlists will help in managing entries and enforcing constraints and make it easier to implement and extend functionality if required.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
The waitlist_helper class will perform the following operations &lt;br /&gt;
#Delete all waitlists for team&lt;br /&gt;
#Purge all waitlists for topic &lt;br /&gt;
#Add team to waitlist&lt;br /&gt;
#Delete specific team from waitlist&lt;br /&gt;
#Get all waitlisted topics for team&lt;br /&gt;
#Get all waitlisted teams for topic&lt;br /&gt;
#Get first team in waitlist for topic&lt;br /&gt;
#Check waitlist empty for topic&lt;br /&gt;
#Check if team has any waitlists &lt;br /&gt;
#Get the number of waitlisted teams for all topics in an assignment&lt;br /&gt;
&lt;br /&gt;
===Migrating existing waitlists to use new table===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt; &lt;br /&gt;
We plan on writing a migration script to move the waitlists from signed_up_teams table to waitlist_teams table.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This will ensure minimal regression breakages and retain existing functionalities.&lt;br /&gt;
=== Specific Tasks Completed ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
=== Video Demonstration ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
=== Testing Goals and Test Objects ===&lt;br /&gt;
&lt;br /&gt;
''Drawing from the project objectives:''&lt;br /&gt;
#Ways to get added to the waitlist for a topic&lt;br /&gt;
##Team requests a topic that has no slot available.&lt;br /&gt;
##When capacity/max choosers for a topic is increased&lt;br /&gt;
##When a student gets added to a team that already has a signed up topic&lt;br /&gt;
#Ways to get off a waitlist&lt;br /&gt;
##team gets the topic they are waiting for ( all other waitlists are dropped for the team)&lt;br /&gt;
##team drops off the waitlist&lt;br /&gt;
##instructor drops team from the waitlist&lt;br /&gt;
##a drop-topic deadline passes&lt;br /&gt;
##team is deleted&lt;br /&gt;
##student gets added to a new team, then the old team's waitlist should be dropped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RSpec Unit Tests ===&lt;br /&gt;
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''&lt;br /&gt;
*Student Waitlist&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting added to the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has no available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be added to the waitlist for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be enrolled for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted topics getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: Student gets enrolled into a course for which he was waitlisted before.&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted teams getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The deadline for a topic passes.&lt;br /&gt;
  Then: All the waitlisted teams for that particular topic must be dropped.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The enrolled team for a topic drops&lt;br /&gt;
  Then: The team that was waitlisted earlier for the topics must be enrolled.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
Student sees the following page during the topic signup. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Student_waitlist_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
'''Test 1:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to add their team to the waitlist by clicking on '''Check''' icon (see the image above) if the team has not signed up in any topic.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 2:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to drop the team from the waitlist by clicking on '''Delete''' icon (see the image above) if they are no longer interested in it.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instructor sees the following page during the topic signup&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_signup_page.png|900px|]]&lt;br /&gt;
&lt;br /&gt;
'''Test 3:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to add a student to the topic by clicking on '''Check''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 4:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to delete a student to the topic by clicking on '''Delete''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Regression Testing ===&lt;br /&gt;
''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 ''&lt;br /&gt;
''old test cases still pass.''&lt;br /&gt;
&lt;br /&gt;
# Make sure all existing waitlist functionality still passes&lt;br /&gt;
&lt;br /&gt;
== Conclusions and Future Work ==&lt;br /&gt;
=== Comprehensive Testing and Scope ===&lt;br /&gt;
* ''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
Pull request&lt;br /&gt;
&lt;br /&gt;
Deployed application with changes&lt;br /&gt;
&lt;br /&gt;
Forked repository&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
=== Students ===&lt;br /&gt;
*Krishna Saurabh Vankadaru (''kvankad'')&lt;br /&gt;
*Samson Reddy Mulkur (''smulkur'')&lt;br /&gt;
*Akhil Kumar Mengani (''amengan'')&lt;br /&gt;
*Sai Naga Vamshi Chidara (''schidar'')&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
*Naman Shrimali (''nshrima'')&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144564</id>
		<title>CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144564"/>
		<updated>2022-04-07T03:00:56Z</updated>

		<summary type="html">&lt;p&gt;Amengan: /* Manual Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
Whenever a team requests for a topic, there are two things that can happen. &lt;br /&gt;
&lt;br /&gt;
* '''The topic is available''': In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ). This is pretty straightforward.&lt;br /&gt;
&lt;br /&gt;
* '''The topic is unavailable''': In this case, the team is waitlisted for the topic. When any other team drops this topic, a waitlisted team will be assigned for this topic. &lt;br /&gt;
&lt;br /&gt;
Our task is to simplify the way we are handling the second case. For each topic, we will have to have a waitlist object associated with it. If a team has requested for a topic that is not available, the team would just be queued on to the waitlist for this topic. In the waitlist object, we will have to maintain the team_id and the topic id for which this team will be waitlisted. In the current implementation, the waitlisting functionality is scattered across multiple files. All this has to be consolidated and placed in fewer number of places ( model file and helper class ).&lt;br /&gt;
&lt;br /&gt;
=== Issues with existing functionality ===&lt;br /&gt;
The current implementation has multiple models and controllers ( sign_up_topic.rb, waitlist.rb, invitation.rb, lottery_controller.rb, suggestion_controller.rb and signed_up_team.rb etc ) perform actions that indirectly affect the waitlist ( adding or removing teams from waitlist ). As a result, modifying the waitlist is being performed by multiple models and controllers. So, there is a lot of redundancy associated with basic waitlist operations in multiple files.&lt;br /&gt;
&lt;br /&gt;
=== Overview of Major Changes ===&lt;br /&gt;
To simplify waitlist functionality and to reduce code redundancy, we will be moving all the functions present in multiple controllers and model files that manipulate waitlists to waitlist.rb. All these classes will now just invoke methods of waitlist.rb. The list of files and methods which will be modified are &lt;br /&gt;
&lt;br /&gt;
1) signed_up_team.rb&lt;br /&gt;
&lt;br /&gt;
2) waitlist.rb&lt;br /&gt;
&lt;br /&gt;
3) sign_up_sheet_controller.rb&lt;br /&gt;
&lt;br /&gt;
4) sign_up_sheet.rb&lt;br /&gt;
&lt;br /&gt;
5) sign_up_topic.rb&lt;br /&gt;
&lt;br /&gt;
6) suggestion_controller.rb&lt;br /&gt;
&lt;br /&gt;
7) invitation.rb&lt;br /&gt;
&lt;br /&gt;
== Proposed design and Plan of action ==&lt;br /&gt;
&lt;br /&gt;
=== General Design Goals ===&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* We are only changing what we set out to change when fixing a particular issue.&lt;br /&gt;
* We are not breaking what was working before we deployed our fix.&lt;br /&gt;
&lt;br /&gt;
We believe at the end our changes will increase the quality of Expertiza and improve the experience for users an developers alike.&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
In this Unified Modeling Language (UML), we summarize the details of the system's users such as instructors and students and their interactions with the system. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Student Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. Student should be able to perform an action to add their own team to the waitlist.  &amp;lt;br&amp;gt;&lt;br /&gt;
2. Student should be able to drop their own team from the waitlist but not others team.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Instructor Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1.  Delete or purge on the waitlist items are those actions that have to be performed by the instructor/admin and student should not be given access to delete action.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Instructor should be able to add any team to the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Instructor should be able to drop any team from the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
4. Instructor should be able to fetch the details of the teams in a waitlist for a particular topic.&amp;lt;br&amp;gt;&lt;br /&gt;
5. Instructor should be able to fetch the details of the topics in which a team is waitlisted. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_uml_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
Tables associated with '''waitlist_teams''' table:&amp;lt;br&amp;gt;&lt;br /&gt;
1. teams&amp;lt;br&amp;gt;&lt;br /&gt;
2. signed_up_teams&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
waitlist_teams table is referred by the signed_up_teams and teams table as Foreign Key Relationship.&lt;br /&gt;
&lt;br /&gt;
'''team_id''' : foreign key in waitlists_team table referenced by teams table &amp;lt;br&amp;gt;&lt;br /&gt;
'''topic_id''' : foreign key in waitlists_team table reference by signed_up_teams table &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_class_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Changes to the signed_up_teams Table ===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
We plan on retiring/removing the waitlist flag from the signed_up_teams table and separating this functionality. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag will be rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Files and methods to be refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to is_waitlisted should be removed and waitlists must be determined by using the new waitlist_team table.&lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##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. &lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##switch_original_topic_to_approved_suggested_topic&lt;br /&gt;
###Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table&lt;br /&gt;
###Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##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&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
###It checks if topic has slots if yes it adds to signed up team, else creates a signup as waitlist&lt;br /&gt;
###This method should use the new table and call the helper functions of waitlist to perform actions on waitlists&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Move method to fetch all users on waitlist for a topic to waitlist_teams method.&lt;br /&gt;
##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&lt;br /&gt;
##reassign_topic - Use methods that perform actions on waitlist that should be moved to waitlist_helper, also use transactions to make it atomic.&lt;br /&gt;
##update_waitlisted_users - Move method to waitlist_teams model and use the new table&lt;br /&gt;
##find_slots_waitlisted - Move method to waitlist_teams model&lt;br /&gt;
##find_waitlisted_topics - Move method to waitlist_teams model&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification&lt;br /&gt;
##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.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team&lt;br /&gt;
###Removing from waitlist and adding to team to sign up should be as a single transaction&lt;br /&gt;
###There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet&lt;br /&gt;
###All functionality should be moved to waitlist_helper and implemented in a robust and dry manner&lt;br /&gt;
&lt;br /&gt;
===Adding new waitlist_teams Table ===&lt;br /&gt;
We plan to add a new table ''waitlist_teams''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The attributes for the table are team_id(refers to the ''teams'' table), topic_id (refers to the ''sign_up_topics'' table)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This table only stores the waitlisted teams for each topic.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Having separated tables for signups and waitlists will help in managing entries and enforcing constraints and make it easier to implement and extend functionality if required.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
The waitlist_helper class will perform the following operations &lt;br /&gt;
#Delete all waitlists for team&lt;br /&gt;
#Purge all waitlists for topic &lt;br /&gt;
#Add team to waitlist&lt;br /&gt;
#Delete specific team from waitlist&lt;br /&gt;
#Get all waitlisted topics for team&lt;br /&gt;
#Get all waitlisted teams for topic&lt;br /&gt;
#Get first team in waitlist for topic&lt;br /&gt;
#Check waitlist empty for topic&lt;br /&gt;
#Check if team has any waitlists &lt;br /&gt;
#Get the number of waitlisted teams for all topics in an assignment&lt;br /&gt;
&lt;br /&gt;
===Migrating existing waitlists to use new table===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt; &lt;br /&gt;
We plan on writing a migration script to move the waitlists from signed_up_teams table to waitlist_teams table.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This will ensure minimal regression breakages and retain existing functionalities.&lt;br /&gt;
=== Specific Tasks Completed ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
=== Video Demonstration ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
=== Testing Goals and Test Objects ===&lt;br /&gt;
&lt;br /&gt;
''Drawing from the project objectives:''&lt;br /&gt;
#Ways to get added to the waitlist for a topic&lt;br /&gt;
##Team requests a topic that has no slot available.&lt;br /&gt;
##When capacity/max choosers for a topic is increased&lt;br /&gt;
##When a student gets added to a team that already has a signed up topic&lt;br /&gt;
#Ways to get off a waitlist&lt;br /&gt;
##team gets the topic they are waiting for ( all other waitlists are dropped for the team)&lt;br /&gt;
##team drops off the waitlist&lt;br /&gt;
##instructor drops team from the waitlist&lt;br /&gt;
##a drop-topic deadline passes&lt;br /&gt;
##team is deleted&lt;br /&gt;
##student gets added to a new team, then the old team's waitlist should be dropped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RSpec Unit Tests ===&lt;br /&gt;
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''&lt;br /&gt;
*Student Waitlist&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting added to the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has no available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be added to the waitlist for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be enrolled for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted topics getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: Student gets enrolled into a course for which he was waitlisted before.&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted teams getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The deadline for a topic passes.&lt;br /&gt;
  Then: All the waitlisted teams for that particular topic must be dropped.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The enrolled team for a topic drops&lt;br /&gt;
  Then: The team that was waitlisted earlier for the topics must be enrolled.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
Student sees the following page during the topic signup. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Student_waitlist_page.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
'''Test 1:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to add their team to the waitlist by clicking on '''Check''' icon (see the image above) if the team has not signed up in any topic.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Test 2:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to drop the team from the waitlist by clicking on '''Delete''' icon (see the image above) if they are no longer interested in it.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instructor sees the following page during the topic signup&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_signup_page.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
'''Test 3:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to add a student to the topic by clicking on '''Check''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Test 4:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Instructor should be able to delete a student to the topic by clicking on '''Delete''' (see the image above) icon. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Regression Testing ===&lt;br /&gt;
''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 ''&lt;br /&gt;
''old test cases still pass.''&lt;br /&gt;
&lt;br /&gt;
# Make sure all existing waitlist functionality still passes&lt;br /&gt;
&lt;br /&gt;
== Conclusions and Future Work ==&lt;br /&gt;
=== Comprehensive Testing and Scope ===&lt;br /&gt;
* ''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
Pull request&lt;br /&gt;
&lt;br /&gt;
Deployed application with changes&lt;br /&gt;
&lt;br /&gt;
Forked repository&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
=== Students ===&lt;br /&gt;
*Krishna Saurabh Vankadaru (''kvankad'')&lt;br /&gt;
*Samson Reddy Mulkur (''smulkur'')&lt;br /&gt;
*Akhil Kumar Mengani (''amengan'')&lt;br /&gt;
*Sai Naga Vamshi Chidara (''schidar'')&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
*Naman Shrimali (''nshrima'')&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Instructor_signup_page.png&amp;diff=144561</id>
		<title>File:Instructor signup page.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Instructor_signup_page.png&amp;diff=144561"/>
		<updated>2022-04-07T02:57:08Z</updated>

		<summary type="html">&lt;p&gt;Amengan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144560</id>
		<title>CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144560"/>
		<updated>2022-04-07T02:56:52Z</updated>

		<summary type="html">&lt;p&gt;Amengan: /* Manual Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
Whenever a team requests for a topic, there are two things that can happen. &lt;br /&gt;
&lt;br /&gt;
* '''The topic is available''': In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ). This is pretty straightforward.&lt;br /&gt;
&lt;br /&gt;
* '''The topic is unavailable''': In this case, the team is waitlisted for the topic. When any other team drops this topic, a waitlisted team will be assigned for this topic. &lt;br /&gt;
&lt;br /&gt;
Our task is to simplify the way we are handling the second case. For each topic, we will have to have a waitlist object associated with it. If a team has requested for a topic that is not available, the team would just be queued on to the waitlist for this topic. In the waitlist object, we will have to maintain the team_id and the topic id for which this team will be waitlisted. In the current implementation, the waitlisting functionality is scattered across multiple files. All this has to be consolidated and placed in fewer number of places ( model file and helper class ).&lt;br /&gt;
&lt;br /&gt;
=== Issues with existing functionality ===&lt;br /&gt;
The current implementation has multiple models and controllers ( sign_up_topic.rb, waitlist.rb, invitation.rb, lottery_controller.rb, suggestion_controller.rb and signed_up_team.rb etc ) perform actions that indirectly affect the waitlist ( adding or removing teams from waitlist ). As a result, modifying the waitlist is being performed by multiple models and controllers. So, there is a lot of redundancy associated with basic waitlist operations in multiple files.&lt;br /&gt;
&lt;br /&gt;
=== Overview of Major Changes ===&lt;br /&gt;
To simplify waitlist functionality and to reduce code redundancy, we will be moving all the functions present in multiple controllers and model files that manipulate waitlists to waitlist.rb. All these classes will now just invoke methods of waitlist.rb. The list of files and methods which will be modified are &lt;br /&gt;
&lt;br /&gt;
1) signed_up_team.rb&lt;br /&gt;
&lt;br /&gt;
2) waitlist.rb&lt;br /&gt;
&lt;br /&gt;
3) sign_up_sheet_controller.rb&lt;br /&gt;
&lt;br /&gt;
4) sign_up_sheet.rb&lt;br /&gt;
&lt;br /&gt;
5) sign_up_topic.rb&lt;br /&gt;
&lt;br /&gt;
6) suggestion_controller.rb&lt;br /&gt;
&lt;br /&gt;
7) invitation.rb&lt;br /&gt;
&lt;br /&gt;
== Proposed design and Plan of action ==&lt;br /&gt;
&lt;br /&gt;
=== General Design Goals ===&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* We are only changing what we set out to change when fixing a particular issue.&lt;br /&gt;
* We are not breaking what was working before we deployed our fix.&lt;br /&gt;
&lt;br /&gt;
We believe at the end our changes will increase the quality of Expertiza and improve the experience for users an developers alike.&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
In this Unified Modeling Language (UML), we summarize the details of the system's users such as instructors and students and their interactions with the system. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Student Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. Student should be able to perform an action to add their own team to the waitlist.  &amp;lt;br&amp;gt;&lt;br /&gt;
2. Student should be able to drop their own team from the waitlist but not others team.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Instructor Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1.  Delete or purge on the waitlist items are those actions that have to be performed by the instructor/admin and student should not be given access to delete action.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Instructor should be able to add any team to the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Instructor should be able to drop any team from the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
4. Instructor should be able to fetch the details of the teams in a waitlist for a particular topic.&amp;lt;br&amp;gt;&lt;br /&gt;
5. Instructor should be able to fetch the details of the topics in which a team is waitlisted. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_uml_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
Tables associated with '''waitlist_teams''' table:&amp;lt;br&amp;gt;&lt;br /&gt;
1. teams&amp;lt;br&amp;gt;&lt;br /&gt;
2. signed_up_teams&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
waitlist_teams table is referred by the signed_up_teams and teams table as Foreign Key Relationship.&lt;br /&gt;
&lt;br /&gt;
'''team_id''' : foreign key in waitlists_team table referenced by teams table &amp;lt;br&amp;gt;&lt;br /&gt;
'''topic_id''' : foreign key in waitlists_team table reference by signed_up_teams table &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_class_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Changes to the signed_up_teams Table ===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
We plan on retiring/removing the waitlist flag from the signed_up_teams table and separating this functionality. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag will be rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Files and methods to be refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to is_waitlisted should be removed and waitlists must be determined by using the new waitlist_team table.&lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##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. &lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##switch_original_topic_to_approved_suggested_topic&lt;br /&gt;
###Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table&lt;br /&gt;
###Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##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&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
###It checks if topic has slots if yes it adds to signed up team, else creates a signup as waitlist&lt;br /&gt;
###This method should use the new table and call the helper functions of waitlist to perform actions on waitlists&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Move method to fetch all users on waitlist for a topic to waitlist_teams method.&lt;br /&gt;
##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&lt;br /&gt;
##reassign_topic - Use methods that perform actions on waitlist that should be moved to waitlist_helper, also use transactions to make it atomic.&lt;br /&gt;
##update_waitlisted_users - Move method to waitlist_teams model and use the new table&lt;br /&gt;
##find_slots_waitlisted - Move method to waitlist_teams model&lt;br /&gt;
##find_waitlisted_topics - Move method to waitlist_teams model&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification&lt;br /&gt;
##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.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team&lt;br /&gt;
###Removing from waitlist and adding to team to sign up should be as a single transaction&lt;br /&gt;
###There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet&lt;br /&gt;
###All functionality should be moved to waitlist_helper and implemented in a robust and dry manner&lt;br /&gt;
&lt;br /&gt;
===Adding new waitlist_teams Table ===&lt;br /&gt;
We plan to add a new table ''waitlist_teams''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The attributes for the table are team_id(refers to the ''teams'' table), topic_id (refers to the ''sign_up_topics'' table)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This table only stores the waitlisted teams for each topic.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Having separated tables for signups and waitlists will help in managing entries and enforcing constraints and make it easier to implement and extend functionality if required.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
The waitlist_helper class will perform the following operations &lt;br /&gt;
#Delete all waitlists for team&lt;br /&gt;
#Purge all waitlists for topic &lt;br /&gt;
#Add team to waitlist&lt;br /&gt;
#Delete specific team from waitlist&lt;br /&gt;
#Get all waitlisted topics for team&lt;br /&gt;
#Get all waitlisted teams for topic&lt;br /&gt;
#Get first team in waitlist for topic&lt;br /&gt;
#Check waitlist empty for topic&lt;br /&gt;
#Check if team has any waitlists &lt;br /&gt;
#Get the number of waitlisted teams for all topics in an assignment&lt;br /&gt;
&lt;br /&gt;
===Migrating existing waitlists to use new table===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt; &lt;br /&gt;
We plan on writing a migration script to move the waitlists from signed_up_teams table to waitlist_teams table.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This will ensure minimal regression breakages and retain existing functionalities.&lt;br /&gt;
=== Specific Tasks Completed ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
=== Video Demonstration ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
=== Testing Goals and Test Objects ===&lt;br /&gt;
&lt;br /&gt;
''Drawing from the project objectives:''&lt;br /&gt;
#Ways to get added to the waitlist for a topic&lt;br /&gt;
##Team requests a topic that has no slot available.&lt;br /&gt;
##When capacity/max choosers for a topic is increased&lt;br /&gt;
##When a student gets added to a team that already has a signed up topic&lt;br /&gt;
#Ways to get off a waitlist&lt;br /&gt;
##team gets the topic they are waiting for ( all other waitlists are dropped for the team)&lt;br /&gt;
##team drops off the waitlist&lt;br /&gt;
##instructor drops team from the waitlist&lt;br /&gt;
##a drop-topic deadline passes&lt;br /&gt;
##team is deleted&lt;br /&gt;
##student gets added to a new team, then the old team's waitlist should be dropped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RSpec Unit Tests ===&lt;br /&gt;
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''&lt;br /&gt;
*Student Waitlist&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting added to the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has no available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be added to the waitlist for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be enrolled for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted topics getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: Student gets enrolled into a course for which he was waitlisted before.&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted teams getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The deadline for a topic passes.&lt;br /&gt;
  Then: All the waitlisted teams for that particular topic must be dropped.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The enrolled team for a topic drops&lt;br /&gt;
  Then: The team that was waitlisted earlier for the topics must be enrolled.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
Student sees the following page during the topic signup. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Student_waitlist_page.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
'''Test 1:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to add their team to the waitlist by clicking on '''Check''' icon if the team has not signed up in any topic.&lt;br /&gt;
&lt;br /&gt;
'''Test 2:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Student should be able to drop the team from the waitlist by clicking on '''Delete''' icon if they are no longer interested in it.&lt;br /&gt;
&lt;br /&gt;
'''Test 3:'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Regression Testing ===&lt;br /&gt;
''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 ''&lt;br /&gt;
''old test cases still pass.''&lt;br /&gt;
&lt;br /&gt;
# Make sure all existing waitlist functionality still passes&lt;br /&gt;
&lt;br /&gt;
== Conclusions and Future Work ==&lt;br /&gt;
=== Comprehensive Testing and Scope ===&lt;br /&gt;
* ''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
Pull request&lt;br /&gt;
&lt;br /&gt;
Deployed application with changes&lt;br /&gt;
&lt;br /&gt;
Forked repository&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
=== Students ===&lt;br /&gt;
*Krishna Saurabh Vankadaru (''kvankad'')&lt;br /&gt;
*Samson Reddy Mulkur (''smulkur'')&lt;br /&gt;
*Akhil Kumar Mengani (''amengan'')&lt;br /&gt;
*Sai Naga Vamshi Chidara (''schidar'')&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
*Naman Shrimali (''nshrima'')&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Student_waitlist_page.png&amp;diff=144552</id>
		<title>File:Student waitlist page.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Student_waitlist_page.png&amp;diff=144552"/>
		<updated>2022-04-07T02:45:48Z</updated>

		<summary type="html">&lt;p&gt;Amengan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144546</id>
		<title>CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144546"/>
		<updated>2022-04-07T02:42:17Z</updated>

		<summary type="html">&lt;p&gt;Amengan: /* UML Diagram */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
Whenever a team requests for a topic, there are two things that can happen. &lt;br /&gt;
&lt;br /&gt;
* '''The topic is available''': In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ). This is pretty straightforward.&lt;br /&gt;
&lt;br /&gt;
* '''The topic is unavailable''': In this case, the team is waitlisted for the topic. When any other team drops this topic, a waitlisted team will be assigned for this topic. &lt;br /&gt;
&lt;br /&gt;
Our task is to simplify the way we are handling the second case. For each topic, we will have to have a waitlist object associated with it. If a team has requested for a topic that is not available, the team would just be queued on to the waitlist for this topic. In the waitlist object, we will have to maintain the team_id and the topic id for which this team will be waitlisted. In the current implementation, the waitlisting functionality is scattered across multiple files. All this has to be consolidated and placed in fewer number of places ( model file and helper class ).&lt;br /&gt;
&lt;br /&gt;
=== Issues with existing functionality ===&lt;br /&gt;
The current implementation has multiple models and controllers ( sign_up_topic.rb, waitlist.rb, invitation.rb, lottery_controller.rb, suggestion_controller.rb and signed_up_team.rb etc ) perform actions that indirectly affect the waitlist ( adding or removing teams from waitlist ). As a result, modifying the waitlist is being performed by multiple models and controllers. So, there is a lot of redundancy associated with basic waitlist operations in multiple files.&lt;br /&gt;
&lt;br /&gt;
=== Overview of Major Changes ===&lt;br /&gt;
To simplify waitlist functionality and to reduce code redundancy, we will be moving all the functions present in multiple controllers and model files that manipulate waitlists to waitlist.rb. All these classes will now just invoke methods of waitlist.rb. The list of files and methods which will be modified are &lt;br /&gt;
&lt;br /&gt;
1) signed_up_team.rb&lt;br /&gt;
&lt;br /&gt;
2) waitlist.rb&lt;br /&gt;
&lt;br /&gt;
3) sign_up_sheet_controller.rb&lt;br /&gt;
&lt;br /&gt;
4) sign_up_sheet.rb&lt;br /&gt;
&lt;br /&gt;
5) sign_up_topic.rb&lt;br /&gt;
&lt;br /&gt;
6) suggestion_controller.rb&lt;br /&gt;
&lt;br /&gt;
7) invitation.rb&lt;br /&gt;
&lt;br /&gt;
== Proposed design and Plan of action ==&lt;br /&gt;
&lt;br /&gt;
=== General Design Goals ===&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* We are only changing what we set out to change when fixing a particular issue.&lt;br /&gt;
* We are not breaking what was working before we deployed our fix.&lt;br /&gt;
&lt;br /&gt;
We believe at the end our changes will increase the quality of Expertiza and improve the experience for users an developers alike.&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
In this Unified Modeling Language (UML), we summarize the details of the system's users such as instructors and students and their interactions with the system. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Student Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. Student should be able to perform an action to add their own team to the waitlist.  &amp;lt;br&amp;gt;&lt;br /&gt;
2. Student should be able to drop their own team from the waitlist but not others team.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Instructor Interactions''' &amp;lt;br&amp;gt;&lt;br /&gt;
1.  Delete or purge on the waitlist items are those actions that have to be performed by the instructor/admin and student should not be given access to delete action.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Instructor should be able to add any team to the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Instructor should be able to drop any team from the waitlist.&amp;lt;br&amp;gt;&lt;br /&gt;
4. Instructor should be able to fetch the details of the teams in a waitlist for a particular topic.&amp;lt;br&amp;gt;&lt;br /&gt;
5. Instructor should be able to fetch the details of the topics in which a team is waitlisted. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_uml_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
Tables associated with '''waitlist_teams''' table:&amp;lt;br&amp;gt;&lt;br /&gt;
1. teams&amp;lt;br&amp;gt;&lt;br /&gt;
2. signed_up_teams&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
waitlist_teams table is referred by the signed_up_teams and teams table as Foreign Key Relationship.&lt;br /&gt;
&lt;br /&gt;
'''team_id''' : foreign key in waitlists_team table referenced by teams table &amp;lt;br&amp;gt;&lt;br /&gt;
'''topic_id''' : foreign key in waitlists_team table reference by signed_up_teams table &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_class_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Changes to the signed_up_teams Table ===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
We plan on retiring/removing the waitlist flag from the signed_up_teams table and separating this functionality. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag will be rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Files and methods to be refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to is_waitlisted should be removed and waitlists must be determined by using the new waitlist_team table.&lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##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. &lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##switch_original_topic_to_approved_suggested_topic&lt;br /&gt;
###Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table&lt;br /&gt;
###Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##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&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
###It checks if topic has slots if yes it adds to signed up team, else creates a signup as waitlist&lt;br /&gt;
###This method should use the new table and call the helper functions of waitlist to perform actions on waitlists&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Move method to fetch all users on waitlist for a topic to waitlist_teams method.&lt;br /&gt;
##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&lt;br /&gt;
##reassign_topic - Use methods that perform actions on waitlist that should be moved to waitlist_helper, also use transactions to make it atomic.&lt;br /&gt;
##update_waitlisted_users - Move method to waitlist_teams model and use the new table&lt;br /&gt;
##find_slots_waitlisted - Move method to waitlist_teams model&lt;br /&gt;
##find_waitlisted_topics - Move method to waitlist_teams model&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification&lt;br /&gt;
##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.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team&lt;br /&gt;
###Removing from waitlist and adding to team to sign up should be as a single transaction&lt;br /&gt;
###There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet&lt;br /&gt;
###All functionality should be moved to waitlist_helper and implemented in a robust and dry manner&lt;br /&gt;
&lt;br /&gt;
===Adding new waitlist_teams Table ===&lt;br /&gt;
We plan to add a new table ''waitlist_teams''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The attributes for the table are team_id(refers to the ''teams'' table), topic_id (refers to the ''sign_up_topics'' table)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This table only stores the waitlisted teams for each topic.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Having separated tables for signups and waitlists will help in managing entries and enforcing constraints and make it easier to implement and extend functionality if required.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
The waitlist_helper class will perform the following operations &lt;br /&gt;
#Delete all waitlists for team&lt;br /&gt;
#Purge all waitlists for topic &lt;br /&gt;
#Add team to waitlist&lt;br /&gt;
#Delete specific team from waitlist&lt;br /&gt;
#Get all waitlisted topics for team&lt;br /&gt;
#Get all waitlisted teams for topic&lt;br /&gt;
#Get first team in waitlist for topic&lt;br /&gt;
#Check waitlist empty for topic&lt;br /&gt;
#Check if team has any waitlists &lt;br /&gt;
#Get the number of waitlisted teams for all topics in an assignment&lt;br /&gt;
&lt;br /&gt;
===Migrating existing waitlists to use new table===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt; &lt;br /&gt;
We plan on writing a migration script to move the waitlists from signed_up_teams table to waitlist_teams table.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This will ensure minimal regression breakages and retain existing functionalities.&lt;br /&gt;
=== Specific Tasks Completed ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
=== Video Demonstration ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
=== Testing Goals and Test Objects ===&lt;br /&gt;
&lt;br /&gt;
''Drawing from the project objectives:''&lt;br /&gt;
#Ways to get added to the waitlist for a topic&lt;br /&gt;
##Team requests a topic that has no slot available.&lt;br /&gt;
##When capacity/max choosers for a topic is increased&lt;br /&gt;
##When a student gets added to a team that already has a signed up topic&lt;br /&gt;
#Ways to get off a waitlist&lt;br /&gt;
##team gets the topic they are waiting for ( all other waitlists are dropped for the team)&lt;br /&gt;
##team drops off the waitlist&lt;br /&gt;
##instructor drops team from the waitlist&lt;br /&gt;
##a drop-topic deadline passes&lt;br /&gt;
##team is deleted&lt;br /&gt;
##student gets added to a new team, then the old team's waitlist should be dropped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RSpec Unit Tests ===&lt;br /&gt;
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''&lt;br /&gt;
*Student Waitlist&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting added to the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has no available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be added to the waitlist for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be enrolled for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted topics getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: Student gets enrolled into a course for which he was waitlisted before.&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted teams getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The deadline for a topic passes.&lt;br /&gt;
  Then: All the waitlisted teams for that particular topic must be dropped.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The enrolled team for a topic drops&lt;br /&gt;
  Then: The team that was waitlisted earlier for the topics must be enrolled.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Regression Testing ===&lt;br /&gt;
''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 ''&lt;br /&gt;
''old test cases still pass.''&lt;br /&gt;
&lt;br /&gt;
# Make sure all existing waitlist functionality still passes&lt;br /&gt;
&lt;br /&gt;
== Conclusions and Future Work ==&lt;br /&gt;
=== Comprehensive Testing and Scope ===&lt;br /&gt;
* ''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
Pull request&lt;br /&gt;
&lt;br /&gt;
Deployed application with changes&lt;br /&gt;
&lt;br /&gt;
Forked repository&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
=== Students ===&lt;br /&gt;
*Krishna Saurabh Vankadaru (''kvankad'')&lt;br /&gt;
*Samson Reddy Mulkur (''smulkur'')&lt;br /&gt;
*Akhil Kumar Mengani (''amengan'')&lt;br /&gt;
*Sai Naga Vamshi Chidara (''schidar'')&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
*Naman Shrimali (''nshrima'')&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144541</id>
		<title>CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144541"/>
		<updated>2022-04-07T02:33:12Z</updated>

		<summary type="html">&lt;p&gt;Amengan: /* Class Diagram */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
Whenever a team requests for a topic, there are two things that can happen. &lt;br /&gt;
&lt;br /&gt;
* '''The topic is available''': In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ). This is pretty straightforward.&lt;br /&gt;
&lt;br /&gt;
* '''The topic is unavailable''': In this case, the team is waitlisted for the topic. When any other team drops this topic, a waitlisted team will be assigned for this topic. &lt;br /&gt;
&lt;br /&gt;
Our task is to simplify the way we are handling the second case. For each topic, we will have to have a waitlist object associated with it. If a team has requested for a topic that is not available, the team would just be queued on to the waitlist for this topic. In the waitlist object, we will have to maintain the team_id and the topic id for which this team will be waitlisted. In the current implementation, the waitlisting functionality is scattered across multiple files. All this has to be consolidated and placed in fewer number of places ( model file and helper class ).&lt;br /&gt;
&lt;br /&gt;
=== Issues with existing functionality ===&lt;br /&gt;
The current implementation has multiple models and controllers ( sign_up_topic.rb, waitlist.rb, invitation.rb, lottery_controller.rb, suggestion_controller.rb and signed_up_team.rb etc ) perform actions that indirectly affect the waitlist ( adding or removing teams from waitlist ). As a result, modifying the waitlist is being performed by multiple models and controllers. So, there is a lot of redundancy associated with basic waitlist operations in multiple files.&lt;br /&gt;
&lt;br /&gt;
=== Overview of Major Changes ===&lt;br /&gt;
To simplify waitlist functionality and to reduce code redundancy, we will be moving all the functions present in multiple controllers and model files that manipulate waitlists to waitlist.rb. All these classes will now just invoke methods of waitlist.rb. The list of files and methods which will be modified are &lt;br /&gt;
&lt;br /&gt;
1) signed_up_team.rb&lt;br /&gt;
&lt;br /&gt;
2) waitlist.rb&lt;br /&gt;
&lt;br /&gt;
3) sign_up_sheet_controller.rb&lt;br /&gt;
&lt;br /&gt;
4) sign_up_sheet.rb&lt;br /&gt;
&lt;br /&gt;
5) sign_up_topic.rb&lt;br /&gt;
&lt;br /&gt;
6) suggestion_controller.rb&lt;br /&gt;
&lt;br /&gt;
7) invitation.rb&lt;br /&gt;
&lt;br /&gt;
== Proposed design and Plan of action ==&lt;br /&gt;
&lt;br /&gt;
=== General Design Goals ===&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* We are only changing what we set out to change when fixing a particular issue.&lt;br /&gt;
* We are not breaking what was working before we deployed our fix.&lt;br /&gt;
&lt;br /&gt;
We believe at the end our changes will increase the quality of Expertiza and improve the experience for users an developers alike.&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
In this Unified Modeling Language (UML), we summarize the details of the system's users such as instructors and students and their interactions with the system.&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_uml_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
Tables associated with '''waitlist_teams''' table:&amp;lt;br&amp;gt;&lt;br /&gt;
1. teams&amp;lt;br&amp;gt;&lt;br /&gt;
2. signed_up_teams&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
waitlist_teams table is referred by the signed_up_teams and teams table as Foreign Key Relationship.&lt;br /&gt;
&lt;br /&gt;
'''team_id''' : foreign key in waitlists_team table referenced by teams table &amp;lt;br&amp;gt;&lt;br /&gt;
'''topic_id''' : foreign key in waitlists_team table reference by signed_up_teams table &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_class_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Changes to the signed_up_teams Table ===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
We plan on retiring/removing the waitlist flag from the signed_up_teams table and separating this functionality. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag will be rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Files and methods to be refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to is_waitlisted should be removed and waitlists must be determined by using the new waitlist_team table.&lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##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. &lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##switch_original_topic_to_approved_suggested_topic&lt;br /&gt;
###Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table&lt;br /&gt;
###Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##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&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
###It checks if topic has slots if yes it adds to signed up team, else creates a signup as waitlist&lt;br /&gt;
###This method should use the new table and call the helper functions of waitlist to perform actions on waitlists&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Move method to fetch all users on waitlist for a topic to waitlist_teams method.&lt;br /&gt;
##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&lt;br /&gt;
##reassign_topic - Use methods that perform actions on waitlist that should be moved to waitlist_helper, also use transactions to make it atomic.&lt;br /&gt;
##update_waitlisted_users - Move method to waitlist_teams model and use the new table&lt;br /&gt;
##find_slots_waitlisted - Move method to waitlist_teams model&lt;br /&gt;
##find_waitlisted_topics - Move method to waitlist_teams model&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification&lt;br /&gt;
##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.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team&lt;br /&gt;
###Removing from waitlist and adding to team to sign up should be as a single transaction&lt;br /&gt;
###There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet&lt;br /&gt;
###All functionality should be moved to waitlist_helper and implemented in a robust and dry manner&lt;br /&gt;
&lt;br /&gt;
===Adding new waitlist_teams Table ===&lt;br /&gt;
We plan to add a new table ''waitlist_teams''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The attributes for the table are team_id(refers to the ''teams'' table), topic_id (refers to the ''sign_up_topics'' table)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This table only stores the waitlisted teams for each topic.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Having separated tables for signups and waitlists will help in managing entries and enforcing constraints and make it easier to implement and extend functionality if required.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
The waitlist_helper class will perform the following operations &lt;br /&gt;
#Delete all waitlists for team&lt;br /&gt;
#Purge all waitlists for topic &lt;br /&gt;
#Add team to waitlist&lt;br /&gt;
#Delete specific team from waitlist&lt;br /&gt;
#Get all waitlisted topics for team&lt;br /&gt;
#Get all waitlisted teams for topic&lt;br /&gt;
#Get first team in waitlist for topic&lt;br /&gt;
#Check waitlist empty for topic&lt;br /&gt;
#Check if team has any waitlists &lt;br /&gt;
#Get the number of waitlisted teams for all topics in an assignment&lt;br /&gt;
&lt;br /&gt;
===Migrating existing waitlists to use new table===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt; &lt;br /&gt;
We plan on writing a migration script to move the waitlists from signed_up_teams table to waitlist_teams table.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This will ensure minimal regression breakages and retain existing functionalities.&lt;br /&gt;
=== Specific Tasks Completed ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
=== Video Demonstration ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
=== Testing Goals and Test Objects ===&lt;br /&gt;
&lt;br /&gt;
''Drawing from the project objectives:''&lt;br /&gt;
#Ways to get added to the waitlist for a topic&lt;br /&gt;
##Team requests a topic that has no slot available.&lt;br /&gt;
##When capacity/max choosers for a topic is increased&lt;br /&gt;
##When a student gets added to a team that already has a signed up topic&lt;br /&gt;
#Ways to get off a waitlist&lt;br /&gt;
##team gets the topic they are waiting for ( all other waitlists are dropped for the team)&lt;br /&gt;
##team drops off the waitlist&lt;br /&gt;
##instructor drops team from the waitlist&lt;br /&gt;
##a drop-topic deadline passes&lt;br /&gt;
##team is deleted&lt;br /&gt;
##student gets added to a new team, then the old team's waitlist should be dropped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RSpec Unit Tests ===&lt;br /&gt;
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''&lt;br /&gt;
*Student Waitlist&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting added to the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has no available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be added to the waitlist for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be enrolled for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted topics getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: Student gets enrolled into a course for which he was waitlisted before.&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted teams getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The deadline for a topic passes.&lt;br /&gt;
  Then: All the waitlisted teams for that particular topic must be dropped.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The enrolled team for a topic drops&lt;br /&gt;
  Then: The team that was waitlisted earlier for the topics must be enrolled.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Regression Testing ===&lt;br /&gt;
''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 ''&lt;br /&gt;
''old test cases still pass.''&lt;br /&gt;
&lt;br /&gt;
# Make sure all existing waitlist functionality still passes&lt;br /&gt;
&lt;br /&gt;
== Conclusions and Future Work ==&lt;br /&gt;
=== Comprehensive Testing and Scope ===&lt;br /&gt;
* ''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
Pull request&lt;br /&gt;
&lt;br /&gt;
Deployed application with changes&lt;br /&gt;
&lt;br /&gt;
Forked repository&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
=== Students ===&lt;br /&gt;
*Krishna Saurabh Vankadaru (''kvankad'')&lt;br /&gt;
*Samson Reddy Mulkur (''smulkur'')&lt;br /&gt;
*Akhil Kumar Mengani (''amengan'')&lt;br /&gt;
*Sai Naga Vamshi Chidara (''schidar'')&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
*Naman Shrimali (''nshrima'')&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144539</id>
		<title>CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144539"/>
		<updated>2022-04-07T02:27:29Z</updated>

		<summary type="html">&lt;p&gt;Amengan: /* UML Diagram */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
Whenever a team requests for a topic, there are two things that can happen. &lt;br /&gt;
&lt;br /&gt;
* '''The topic is available''': In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ). This is pretty straightforward.&lt;br /&gt;
&lt;br /&gt;
* '''The topic is unavailable''': In this case, the team is waitlisted for the topic. When any other team drops this topic, a waitlisted team will be assigned for this topic. &lt;br /&gt;
&lt;br /&gt;
Our task is to simplify the way we are handling the second case. For each topic, we will have to have a waitlist object associated with it. If a team has requested for a topic that is not available, the team would just be queued on to the waitlist for this topic. In the waitlist object, we will have to maintain the team_id and the topic id for which this team will be waitlisted. In the current implementation, the waitlisting functionality is scattered across multiple files. All this has to be consolidated and placed in fewer number of places ( model file and helper class ).&lt;br /&gt;
&lt;br /&gt;
=== Issues with existing functionality ===&lt;br /&gt;
The current implementation has multiple models and controllers ( sign_up_topic.rb, waitlist.rb, invitation.rb, lottery_controller.rb, suggestion_controller.rb and signed_up_team.rb etc ) perform actions that indirectly affect the waitlist ( adding or removing teams from waitlist ). As a result, modifying the waitlist is being performed by multiple models and controllers. So, there is a lot of redundancy associated with basic waitlist operations in multiple files.&lt;br /&gt;
&lt;br /&gt;
=== Overview of Major Changes ===&lt;br /&gt;
To simplify waitlist functionality and to reduce code redundancy, we will be moving all the functions present in multiple controllers and model files that manipulate waitlists to waitlist.rb. All these classes will now just invoke methods of waitlist.rb. The list of files and methods which will be modified are &lt;br /&gt;
&lt;br /&gt;
1) signed_up_team.rb&lt;br /&gt;
&lt;br /&gt;
2) waitlist.rb&lt;br /&gt;
&lt;br /&gt;
3) sign_up_sheet_controller.rb&lt;br /&gt;
&lt;br /&gt;
4) sign_up_sheet.rb&lt;br /&gt;
&lt;br /&gt;
5) sign_up_topic.rb&lt;br /&gt;
&lt;br /&gt;
6) suggestion_controller.rb&lt;br /&gt;
&lt;br /&gt;
7) invitation.rb&lt;br /&gt;
&lt;br /&gt;
== Proposed design and Plan of action ==&lt;br /&gt;
&lt;br /&gt;
=== General Design Goals ===&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* We are only changing what we set out to change when fixing a particular issue.&lt;br /&gt;
* We are not breaking what was working before we deployed our fix.&lt;br /&gt;
&lt;br /&gt;
We believe at the end our changes will increase the quality of Expertiza and improve the experience for users an developers alike.&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
In this Unified Modeling Language (UML), we summarize the details of the system's users such as instructors and students and their interactions with the system.&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_uml_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_class_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Changes to the signed_up_teams Table ===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
We plan on retiring/removing the waitlist flag from the signed_up_teams table and separating this functionality. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag will be rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Files and methods to be refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to is_waitlisted should be removed and waitlists must be determined by using the new waitlist_team table.&lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##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. &lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##switch_original_topic_to_approved_suggested_topic&lt;br /&gt;
###Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table&lt;br /&gt;
###Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##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&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
###It checks if topic has slots if yes it adds to signed up team, else creates a signup as waitlist&lt;br /&gt;
###This method should use the new table and call the helper functions of waitlist to perform actions on waitlists&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Move method to fetch all users on waitlist for a topic to waitlist_teams method.&lt;br /&gt;
##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&lt;br /&gt;
##reassign_topic - Use methods that perform actions on waitlist that should be moved to waitlist_helper, also use transactions to make it atomic.&lt;br /&gt;
##update_waitlisted_users - Move method to waitlist_teams model and use the new table&lt;br /&gt;
##find_slots_waitlisted - Move method to waitlist_teams model&lt;br /&gt;
##find_waitlisted_topics - Move method to waitlist_teams model&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification&lt;br /&gt;
##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.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team&lt;br /&gt;
###Removing from waitlist and adding to team to sign up should be as a single transaction&lt;br /&gt;
###There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet&lt;br /&gt;
###All functionality should be moved to waitlist_helper and implemented in a robust and dry manner&lt;br /&gt;
&lt;br /&gt;
===Adding new waitlist_teams Table ===&lt;br /&gt;
We plan to add a new table ''waitlist_teams''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The attributes for the table are team_id(refers to the ''teams'' table), topic_id (refers to the ''sign_up_topics'' table)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This table only stores the waitlisted teams for each topic.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Having separated tables for signups and waitlists will help in managing entries and enforcing constraints and make it easier to implement and extend functionality if required.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
The waitlist_helper class will perform the following operations &lt;br /&gt;
#Delete all waitlists for team&lt;br /&gt;
#Purge all waitlists for topic &lt;br /&gt;
#Add team to waitlist&lt;br /&gt;
#Delete specific team from waitlist&lt;br /&gt;
#Get all waitlisted topics for team&lt;br /&gt;
#Get all waitlisted teams for topic&lt;br /&gt;
#Get first team in waitlist for topic&lt;br /&gt;
#Check waitlist empty for topic&lt;br /&gt;
#Check if team has any waitlists &lt;br /&gt;
#Get the number of waitlisted teams for all topics in an assignment&lt;br /&gt;
&lt;br /&gt;
===Migrating existing waitlists to use new table===&lt;br /&gt;
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.&lt;br /&gt;
&amp;lt;br/&amp;gt; &lt;br /&gt;
We plan on writing a migration script to move the waitlists from signed_up_teams table to waitlist_teams table.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
This will ensure minimal regression breakages and retain existing functionalities.&lt;br /&gt;
=== Specific Tasks Completed ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
=== Video Demonstration ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
=== Testing Goals and Test Objects ===&lt;br /&gt;
&lt;br /&gt;
''Drawing from the project objectives:''&lt;br /&gt;
#Ways to get added to the waitlist for a topic&lt;br /&gt;
##Team requests a topic that has no slot available.&lt;br /&gt;
##When capacity/max choosers for a topic is increased&lt;br /&gt;
##When a student gets added to a team that already has a signed up topic&lt;br /&gt;
#Ways to get off a waitlist&lt;br /&gt;
##team gets the topic they are waiting for ( all other waitlists are dropped for the team)&lt;br /&gt;
##team drops off the waitlist&lt;br /&gt;
##instructor drops team from the waitlist&lt;br /&gt;
##a drop-topic deadline passes&lt;br /&gt;
##team is deleted&lt;br /&gt;
##student gets added to a new team, then the old team's waitlist should be dropped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RSpec Unit Tests ===&lt;br /&gt;
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''&lt;br /&gt;
*Student Waitlist&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting added to the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has no available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be added to the waitlist for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be enrolled for the topic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted topics getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: Student gets enrolled into a course for which he was waitlisted before.&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: All waitlisted teams getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The deadline for a topic passes.&lt;br /&gt;
  Then: All the waitlisted teams for that particular topic must be dropped.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting enrolled in a topic&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The enrolled team for a topic drops&lt;br /&gt;
  Then: The team that was waitlisted earlier for the topics must be enrolled.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Regression Testing ===&lt;br /&gt;
''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 ''&lt;br /&gt;
''old test cases still pass.''&lt;br /&gt;
&lt;br /&gt;
# Make sure all existing waitlist functionality still passes&lt;br /&gt;
&lt;br /&gt;
== Conclusions and Future Work ==&lt;br /&gt;
=== Comprehensive Testing and Scope ===&lt;br /&gt;
* ''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
Pull request&lt;br /&gt;
&lt;br /&gt;
Deployed application with changes&lt;br /&gt;
&lt;br /&gt;
Forked repository&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
=== Students ===&lt;br /&gt;
*Krishna Saurabh Vankadaru (''kvankad'')&lt;br /&gt;
*Samson Reddy Mulkur (''smulkur'')&lt;br /&gt;
*Akhil Kumar Mengani (''amengan'')&lt;br /&gt;
*Sai Naga Vamshi Chidara (''schidar'')&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
*Naman Shrimali (''nshrima'')&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144429</id>
		<title>CSC/ECE 517 Spring 2022 - E2240. Re-write waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2240._Re-write_waitlist_functionality&amp;diff=144429"/>
		<updated>2022-04-06T21:58:35Z</updated>

		<summary type="html">&lt;p&gt;Amengan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
Whenever a team requests for a topic, there are two things that can happen. &lt;br /&gt;
&lt;br /&gt;
'''The topic is available''':&lt;br /&gt;
&lt;br /&gt;
In this case, the team will be assigned this topic ( Assuming that there is no bidding for the assignment ).&lt;br /&gt;
&lt;br /&gt;
'''The topic is unavailable''':&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
=== Feature Overview ===&lt;br /&gt;
&lt;br /&gt;
=== Issues with existing functionality ===&lt;br /&gt;
&lt;br /&gt;
=== Overview of Major Changes ===&lt;br /&gt;
&lt;br /&gt;
== Proposed design and Plan of action ==&lt;br /&gt;
&lt;br /&gt;
=== General Design Goals ===&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_uml_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:Waitlists_class_diagram.png|600px|]]&lt;br /&gt;
&lt;br /&gt;
=== Changes to the signed_up_teams Table ===&lt;br /&gt;
=== Files and methods to be refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##switch_original_topic_to_approved_suggested_topic&lt;br /&gt;
###Change usage of is_waitlisted attribute in the signed_up_teams table to use the new table&lt;br /&gt;
###Add additional checks and transactions to make sure perform operations in an atomic way in case of failures.&lt;br /&gt;
&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification&lt;br /&gt;
##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.&lt;br /&gt;
&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team&lt;br /&gt;
###Removing from waitlist and adding to team to sign up should be as a single transaction&lt;br /&gt;
###There should be additional checks to make sure that there is enough space left before adding team to signed_up_sheet&lt;br /&gt;
###All functionality should be moved to waitlist_helper and implemented in a robust and dry manner&lt;br /&gt;
&lt;br /&gt;
===Adding new waitlist_teams Table ===&lt;br /&gt;
#Add a new table waitlist_teams&lt;br /&gt;
#The attributes for the table are team_id(refers to the teams table), topic_id (refers to the sign_up_topics table)&lt;br /&gt;
#This table only stores the waitlisted teams for each topic.&lt;br /&gt;
#The default timestamp in the table will be used to check the first team waitlisted instead of using queues to implement the functionality.&lt;br /&gt;
#The waitlist_helper class will perform the following operations &lt;br /&gt;
##Delete all waitlists for team&lt;br /&gt;
##Purge all waitlists for topic &lt;br /&gt;
##Add team to waitlist&lt;br /&gt;
##Delete specific team from waitlist&lt;br /&gt;
##Get all waitlisted topics for team&lt;br /&gt;
##Get all waitlisted teams for topic&lt;br /&gt;
##Get first team in waitlist for topic&lt;br /&gt;
##Check waitlist empty for topic&lt;br /&gt;
##Check if team has any waitlists &lt;br /&gt;
&lt;br /&gt;
===Refactoring and Design Patterns===&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* We are only changing what we set out to change when fixing a particular issue.&lt;br /&gt;
* We are not breaking what was working before we deployed our fix.&lt;br /&gt;
&lt;br /&gt;
We believe at the end our changes will increase the quality of Expertiza and improve the experience for users an developers alike.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specific Tasks Completed ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
=== Video Demonstration ===&lt;br /&gt;
''will be added for the final submission''&lt;br /&gt;
=== Testing Goals and Test Objects ===&lt;br /&gt;
&lt;br /&gt;
''Drawing from the project objectives:''&lt;br /&gt;
#Ways to get added to waitlist for a topic&lt;br /&gt;
##Team requests a topic that has no slot available.&lt;br /&gt;
##When capacity/max choosers for a topic is increased&lt;br /&gt;
##When student gets added to a team which has signed up topic&lt;br /&gt;
#Ways to get off a waitlist&lt;br /&gt;
##team gets the topic they are waiting for ( all other waitlists are dropped for the team)&lt;br /&gt;
##team drops off the waitlist&lt;br /&gt;
##instructor drops team from the waitlist&lt;br /&gt;
##a drop-topic deadline passes&lt;br /&gt;
##team is deleted&lt;br /&gt;
##student gets added to a new team, then old team's waitlist should be dropped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RSpec Unit Tests ===&lt;br /&gt;
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''&lt;br /&gt;
*Student Waitlist&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Getting added to the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has no available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be added to the waitlist for the topic.&lt;br /&gt;
&lt;br /&gt;
Scenario: Getting enrolled in a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The topic for an assignment has available slots&lt;br /&gt;
   And: Student tries to signup for a topic&lt;br /&gt;
  Then: The team that the student is a part of should be enrolled for the topic.&lt;br /&gt;
&lt;br /&gt;
Scenario: All waitlisted topics getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: Student gets enrolled into a course for which he was waitlisted before.&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from the remaining waitlisted topics.&lt;br /&gt;
&lt;br /&gt;
Scenario: All waitlisted teams getting dropped&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The deadline for a topic passes.&lt;br /&gt;
  Then: All the waitlisted teams for that particular topic must be dropped.&lt;br /&gt;
&lt;br /&gt;
Scenario: Getting enrolled in a topic&lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The enrolled team for a topic drops&lt;br /&gt;
  Then: The team that was waitlisted earlier for the topics must be enrolled.&lt;br /&gt;
&lt;br /&gt;
=== Manual UI Tests ===&lt;br /&gt;
*Student ID in header&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Student ID in grading history view &lt;br /&gt;
Logged in as an Instructor/Admin&lt;br /&gt;
  On Assignment page, click on Grading History&lt;br /&gt;
   Resulting Grading History Table is shown&lt;br /&gt;
    Student ID appears in the header, not in any table columns&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Regression Testing ===&lt;br /&gt;
''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 ''&lt;br /&gt;
''old test cases still pass.''&lt;br /&gt;
&lt;br /&gt;
# Make sure all existing waitlist functionality still passes&lt;br /&gt;
&lt;br /&gt;
== Conclusions and Future Work ==&lt;br /&gt;
=== Comprehensive Testing and Scope ===&lt;br /&gt;
* ''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
''will be added for final submission''&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
Pull request&lt;br /&gt;
&lt;br /&gt;
Deployed application with changes&lt;br /&gt;
&lt;br /&gt;
Forked repository&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
=== Students ===&lt;br /&gt;
*Krishna Saurabh Vankadaru (''kvankad'')&lt;br /&gt;
*Samson Mulkur (''smulkur'')&lt;br /&gt;
*Akhil Mengani (''amengan'')&lt;br /&gt;
*Sai Naga Vamshi Chidara (''schidar'')&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
*Naman Shrimali (''nshrima'')&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Waitlists_uml_diagram.png&amp;diff=144428</id>
		<title>File:Waitlists uml diagram.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Waitlists_uml_diagram.png&amp;diff=144428"/>
		<updated>2022-04-06T21:53:55Z</updated>

		<summary type="html">&lt;p&gt;Amengan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Waitlists_class_diagram.png&amp;diff=144427</id>
		<title>File:Waitlists class diagram.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Waitlists_class_diagram.png&amp;diff=144427"/>
		<updated>2022-04-06T21:53:12Z</updated>

		<summary type="html">&lt;p&gt;Amengan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143495</id>
		<title>CSC/ECE 517 Spring 2022 - E2218: Refactor response controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143495"/>
		<updated>2022-03-22T02:23:34Z</updated>

		<summary type="html">&lt;p&gt;Amengan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page details project documentation for the CSC/ECE 517 Spring 2022, '''E2218 refactor response_controller.rb''' project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
A response is the object that is created when someone fills out a review rubric, such as when one writes a review, gives feedback to a reviewer, or fills out a survey.  Responses to the individual rubric items are kept in Answer objects; each Answer object has a response_id to say what Response it is part of.  Since response_controller needs to work with many kinds of responses, its code is pretty general.  It is not the worst controller in the system, but it would be much clearer if its method names were more descriptive of what they do.&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Sai Naga Vamshi Chidara (schidar@ncsu.edu)&lt;br /&gt;
* Akhil Kumar Mengani (amengan@ncsu.edu)&lt;br /&gt;
* Samson Reddy Mulkur (smulkur@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Modified Files and Refactorization ==&lt;br /&gt;
A. '''response_controller.rb''' &amp;lt;br&amp;gt;&lt;br /&gt;
1.  '''authorize_show_calibration_results'''&lt;br /&gt;
      This method is used to authorize if the user(reviewer) is allowed to view the calibration results for the corresponding ''calibration_response_map_id'' and ''review_response_map_id'' &lt;br /&gt;
      passed as parameters in the URL.&lt;br /&gt;
      Ex: https://expertiza.ncsu.edu/response/show_calibration_results_for_student?calibration_response_map_id=165688&amp;amp;review_response_map_id=165790&lt;br /&gt;
      When someone tries to change the map_id's, the request should be authorized to check if the user can access the calibration result or not. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      [[File:Authorize_show_calibration_results.png|1200px|]]&lt;br /&gt;
&lt;br /&gt;
B. '''response_helper.rb''' &amp;lt;br&amp;gt;&lt;br /&gt;
1 . Following methods are moved from the ''response_controller.rb'' class to ''response_helper.rb'' class since these methods are called from the controller action methods.&lt;br /&gt;
    i) '''current_user_is_reviewer''' &lt;br /&gt;
    ii) '''sort_questions'''&lt;br /&gt;
    iii) '''store_total_cake_score'''&lt;br /&gt;
    iv) '''set_content''' &amp;lt;br&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    [[File:Response_helper_1.png|1200px|]]&lt;br /&gt;
&lt;br /&gt;
    [[File:Response_helper_2.png|1200px|]]&lt;br /&gt;
&lt;br /&gt;
C. '''assignment_questionnaire.rb''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. ''get_questions_by_assignment_id''&lt;br /&gt;
      Parameters : assignment_id &lt;br /&gt;
      When a user clicks on 'calibration results' from UI, questions in the assignment that has been reviewed are displayed.&lt;br /&gt;
      A new method is added in the ''AssignmentQuestionnaire'' model class that returns the appropriate questions by querying the ''AssignmentQuestionnaire'' using the ''assignment_id''.&lt;br /&gt;
      This method is added to separate the business logic of retrieving the questions from the controller class.&lt;br /&gt;
     &lt;br /&gt;
     [[File: Get_questions_by_assignment_id.png|1200px|]]&lt;br /&gt;
&lt;br /&gt;
D. '''awarded_badge.rb'''  &amp;lt;br&amp;gt;&lt;br /&gt;
1. ''award_badge''&lt;br /&gt;
    Parameters :  participant_id, badge_name&lt;br /&gt;
    This method adds the ''badge_name'' to a specific ''participant_id'' in the AwardedBadges table. &lt;br /&gt;
    A separate method is created in the ''AwardedBadges'' model class to avoid the controller class from knowing the business logic of adding a badge name to a participant.&lt;br /&gt;
&lt;br /&gt;
    [[File:RespControllerAwardBadge.png|1200px|]]&lt;br /&gt;
&lt;br /&gt;
    [[File:AwardBadgeMethod.png|1200px|]]&lt;br /&gt;
    &lt;br /&gt;
E. '''cake.rb'''  &amp;lt;br&amp;gt;&lt;br /&gt;
1. ''store_total_cake_score''&lt;br /&gt;
   This method clearly exposes the logic of retrieving the score for a cake question in the ''response_controller.rb'' class which is an incorrect design.  &lt;br /&gt;
   So, a model class method ''get_total_score_for_questions'' is added and the same logic of iterating over the Cake questions is moved there.&lt;br /&gt;
   Return results for this method remains same here.&lt;br /&gt;
   &lt;br /&gt;
   [[File:Cake.png|1200px|]]&lt;br /&gt;
&lt;br /&gt;
F. '''response.rb'''  &amp;lt;br&amp;gt;&lt;br /&gt;
1. ''calibration_results_info''&lt;br /&gt;
    This method in ''response.rb'' model is completely removed because this method only adds more complexity to the model class.&lt;br /&gt;
    We refactored the method ''show_calibration_results_for_student'' in the ''response_controller.rb'' class. &lt;br /&gt;
    Previously, ''calibration_results_info'' was just doing nothing but getting responses using ''calibration_response_map_id'' and ''review_response_map_id'', and querying ''AssignmentQuestionnaire''.&lt;br /&gt;
    Both of these operations can be done by using ''find'' method of model class and adding model class ''get_questions_by_assignment_id'' method.&lt;br /&gt;
&lt;br /&gt;
2. ''create_or_get_response''&lt;br /&gt;
     Method name ''populate_new_response'' is changed to ''create_or_get_response'' to convey the functionality of the method.&lt;br /&gt;
     &lt;br /&gt;
    [[File:Create_or_get_response.png|1200px|]]&lt;br /&gt;
&lt;br /&gt;
3. ''set_response''&lt;br /&gt;
    @response and @map instance variables are initialized the same way across multiple methods.&lt;br /&gt;
    In order to avoid duplication, we created a before_action action which will be called first before calling the corresponding methods.&lt;br /&gt;
&lt;br /&gt;
    [[File:Set_response_method.png|1200px|]]&lt;br /&gt;
&lt;br /&gt;
G. '''Code Climate issues''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. ''Update'' &amp;lt;br&amp;gt;&lt;br /&gt;
     &amp;lt;p&amp;gt; Made changes to split a line into multiple lines because it is too long. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     [[File:Update_line_long.png|1200px|]]&lt;br /&gt;
2. ''Create'' &amp;lt;br&amp;gt;&lt;br /&gt;
     &amp;lt;p&amp;gt; Made changes to split a line into multiple lines because it is too long. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     [[File:Create_line_long.png|1200px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  rspec spec/models/responses_spec.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  rspec spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
Link to Expertiza repository: [https://github.com/expertiza/expertiza here]&lt;br /&gt;
&lt;br /&gt;
Link to the forked repository: [https://github.com/vamshi-chidara/expertiza here]&lt;br /&gt;
&lt;br /&gt;
Link to Pull Request: [https://github.com/expertiza/expertiza/pull/2327 here]&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Show_calibration_rsults_info.png&amp;diff=143493</id>
		<title>File:Show calibration rsults info.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Show_calibration_rsults_info.png&amp;diff=143493"/>
		<updated>2022-03-22T02:18:17Z</updated>

		<summary type="html">&lt;p&gt;Amengan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Response_helper_2.png&amp;diff=143492</id>
		<title>File:Response helper 2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Response_helper_2.png&amp;diff=143492"/>
		<updated>2022-03-22T02:18:07Z</updated>

		<summary type="html">&lt;p&gt;Amengan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Response_helper_1.png&amp;diff=143491</id>
		<title>File:Response helper 1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Response_helper_1.png&amp;diff=143491"/>
		<updated>2022-03-22T02:17:56Z</updated>

		<summary type="html">&lt;p&gt;Amengan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Get_questions_by_assignment_id.png&amp;diff=143490</id>
		<title>File:Get questions by assignment id.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Get_questions_by_assignment_id.png&amp;diff=143490"/>
		<updated>2022-03-22T02:17:46Z</updated>

		<summary type="html">&lt;p&gt;Amengan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Create_or_get_response.png&amp;diff=143489</id>
		<title>File:Create or get response.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Create_or_get_response.png&amp;diff=143489"/>
		<updated>2022-03-22T02:17:32Z</updated>

		<summary type="html">&lt;p&gt;Amengan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Cake.png&amp;diff=143487</id>
		<title>File:Cake.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Cake.png&amp;diff=143487"/>
		<updated>2022-03-22T02:17:21Z</updated>

		<summary type="html">&lt;p&gt;Amengan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143486</id>
		<title>CSC/ECE 517 Spring 2022 - E2218: Refactor response controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143486"/>
		<updated>2022-03-22T02:17:10Z</updated>

		<summary type="html">&lt;p&gt;Amengan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page details project documentation for the CSC/ECE 517 Spring 2022, &amp;quot;E2218 refactor response_controller.rb&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
A response is the object that is created when someone fills out a review rubric, such as when one writes a review, gives feedback to a reviewer, or fills out a survey.  Responses to the individual rubric items are kept in Answer objects; each Answer object has a response_id to say what Response it is part of.  Since response_controller needs to work with many kinds of responses, its code is pretty general.  It is not the worst controller in the system, but it would be much clearer if its method names were more descriptive of what they do.&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Sai Naga Vamshi Chidara (schidar@ncsu.edu)&lt;br /&gt;
* Akhil Kumar Mengani (amengan@ncsu.edu)&lt;br /&gt;
* Samson Reddy Mulkur (smulkur@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Modified Files and Refactorization ==&lt;br /&gt;
A. '''response_controller.rb''' &amp;lt;br&amp;gt;&lt;br /&gt;
1.  '''authorize_show_calibration_results'''&lt;br /&gt;
      This method is used to authorize if the user(reviewer) is allowed to view the calibration results for the corresponding ''calibration_response_map_id'' and ''review_response_map_id'' &lt;br /&gt;
      passed as parameters in the URL.&lt;br /&gt;
      Ex: https://expertiza.ncsu.edu/response/show_calibration_results_for_student?calibration_response_map_id=165688&amp;amp;review_response_map_id=165790&lt;br /&gt;
      When someone tries to change the map_id's, the request should be authorized to check if the user can access the calibration result or not. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      [[File:Authorize_show_calibration_results.png]]&lt;br /&gt;
&lt;br /&gt;
B. '''response_helper.rb''' &amp;lt;br&amp;gt;&lt;br /&gt;
1 . Following methods are moved from the ''response_controller.rb'' class to ''response_helper.rb'' class since these methods are called from the controller action methods.&lt;br /&gt;
    i) '''current_user_is_reviewer''' &lt;br /&gt;
    ii) '''sort_questions'''&lt;br /&gt;
    iii) '''store_total_cake_score'''&lt;br /&gt;
    iv) '''set_content'''&lt;br /&gt;
&lt;br /&gt;
C. '''assignment_questionnaire.rb''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. ''get_questions_by_assignment_id''&lt;br /&gt;
      Parameters : assignment_id &lt;br /&gt;
      When a user clicks on 'calibration results' from UI, questions in the assignment that has been reviewed are displayed.&lt;br /&gt;
      A new method is added in the ''AssignmentQuestionnaire'' model class that returns the appropriate questions by querying the ''AssignmentQuestionnaire'' using the ''assignment_id''.&lt;br /&gt;
      This method is added to separate the business logic of retrieving the questions from the controller class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
D. '''awarded_badge.rb'''  &amp;lt;br&amp;gt;&lt;br /&gt;
1. ''award_badge''&lt;br /&gt;
    Parameters :  participant_id, badge_name&lt;br /&gt;
    This method adds the ''badge_name'' to a specific ''participant_id'' in the AwardedBadges table. &lt;br /&gt;
    A separate method is created in the ''AwardedBadges'' model class to avoid the controller class from knowing the business logic of adding a badge name to a participant.&lt;br /&gt;
&lt;br /&gt;
    [[File:RespControllerAwardBadge.png|1200px|]]&lt;br /&gt;
&lt;br /&gt;
    [[File:AwardBadgeMethod.png|1200px|]]&lt;br /&gt;
    &lt;br /&gt;
E. '''cake.rb'''  &amp;lt;br&amp;gt;&lt;br /&gt;
1. ''store_total_cake_score''&lt;br /&gt;
   This method clearly exposes the logic of retrieving the score for a cake question in the ''response_controller.rb'' class which is an incorrect design.  &lt;br /&gt;
   So, a model class method ''get_total_score_for_questions'' is added and the same logic of iterating over the Cake questions is moved there.&lt;br /&gt;
   Return results for this method remains same here.&lt;br /&gt;
&lt;br /&gt;
F. '''response.rb'''  &amp;lt;br&amp;gt;&lt;br /&gt;
1. ''calibration_results_info''&lt;br /&gt;
    This method in ''response.rb'' model is completely removed because this method only adds more complexity to the model class.&lt;br /&gt;
    We refactored the method ''show_calibration_results_for_student'' in the ''response_controller.rb'' class. &lt;br /&gt;
    Previously, ''calibration_results_info'' was just doing nothing but getting responses using ''calibration_response_map_id'' and ''review_response_map_id'', and querying ''AssignmentQuestionnaire''.&lt;br /&gt;
    Both of these operations can be done by using ''find'' method of model class and adding model class ''get_questions_by_assignment_id'' method.&lt;br /&gt;
&lt;br /&gt;
2. ''set_response''&lt;br /&gt;
    @response and @map instance variables are initialized the same way across multiple methods.&lt;br /&gt;
    In order to avoid duplication, we created a before_action action which will be called first before calling the corresponding methods.&lt;br /&gt;
&lt;br /&gt;
    [[File:Set_response_method.png|1200px|]]&lt;br /&gt;
&lt;br /&gt;
3. ''create_or_get_response''&lt;br /&gt;
     Method name ''populate_new_response'' is changed to ''create_or_get_response'' to convey the functionality of the method. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
G. '''Code Climate issues''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. ''Update'' &amp;lt;br&amp;gt;&lt;br /&gt;
     &amp;lt;p&amp;gt; Made changes to split a line into multiple lines because it is too long. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     [[File:Update_line_long.png|1200px|]]&lt;br /&gt;
2. ''Create'' &amp;lt;br&amp;gt;&lt;br /&gt;
     &amp;lt;p&amp;gt; Made changes to split a line into multiple lines because it is too long. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     [[File:Create_line_long.png|1200px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  rspec spec/models/responses_spec.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  rspec spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
Link to Expertiza repository: [https://github.com/expertiza/expertiza here]&lt;br /&gt;
&lt;br /&gt;
Link to the forked repository: [https://github.com/vamshi-chidara/expertiza here]&lt;br /&gt;
&lt;br /&gt;
Link to Pull Request: [https://github.com/expertiza/expertiza/pull/2327 here]&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Awrded_badge_method.png&amp;diff=143484</id>
		<title>File:Awrded badge method.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Awrded_badge_method.png&amp;diff=143484"/>
		<updated>2022-03-22T02:15:41Z</updated>

		<summary type="html">&lt;p&gt;Amengan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Authorize_show_calibration_results.png&amp;diff=143483</id>
		<title>File:Authorize show calibration results.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Authorize_show_calibration_results.png&amp;diff=143483"/>
		<updated>2022-03-22T02:15:16Z</updated>

		<summary type="html">&lt;p&gt;Amengan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143480</id>
		<title>CSC/ECE 517 Spring 2022 - E2218: Refactor response controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143480"/>
		<updated>2022-03-22T02:13:19Z</updated>

		<summary type="html">&lt;p&gt;Amengan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page details project documentation for the CSC/ECE 517 Spring 2022, &amp;quot;E2218 refactor response_controller.rb&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
A response is the object that is created when someone fills out a review rubric, such as when one writes a review, gives feedback to a reviewer, or fills out a survey.  Responses to the individual rubric items are kept in Answer objects; each Answer object has a response_id to say what Response it is part of.  Since response_controller needs to work with many kinds of responses, its code is pretty general.  It is not the worst controller in the system, but it would be much clearer if its method names were more descriptive of what they do.&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Sai Naga Vamshi Chidara (schidar@ncsu.edu)&lt;br /&gt;
* Akhil Kumar Mengani (amengan@ncsu.edu)&lt;br /&gt;
* Samson Reddy Mulkur (smulkur@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Modified Files and Refactorization ==&lt;br /&gt;
A. '''response_controller.rb''' &amp;lt;br&amp;gt;&lt;br /&gt;
1.  '''authorize_show_calibration_results'''&lt;br /&gt;
      This method is used to authorize if the user(reviewer) is allowed to view the calibration results for the corresponding ''calibration_response_map_id'' and ''review_response_map_id'' &lt;br /&gt;
      passed as parameters in the URL.&lt;br /&gt;
      Ex: https://expertiza.ncsu.edu/response/show_calibration_results_for_student?calibration_response_map_id=165688&amp;amp;review_response_map_id=165790&lt;br /&gt;
      When someone tries to change the map_id's, the request should be authorized to check if the user can access the calibration result or not. &lt;br /&gt;
&lt;br /&gt;
B. '''response_helper.rb''' &amp;lt;br&amp;gt;&lt;br /&gt;
1 . Following methods are moved from the ''response_controller.rb'' class to ''response_helper.rb'' class since these methods are called from the controller action methods.&lt;br /&gt;
    i) '''current_user_is_reviewer''' &lt;br /&gt;
    ii) '''sort_questions'''&lt;br /&gt;
    iii) '''store_total_cake_score'''&lt;br /&gt;
    iv) '''set_content'''&lt;br /&gt;
&lt;br /&gt;
C. '''assignment_questionnaire.rb''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. ''get_questions_by_assignment_id''&lt;br /&gt;
      Parameters : assignment_id &lt;br /&gt;
      When a user clicks on 'calibration results' from UI, questions in the assignment that has been reviewed are displayed.&lt;br /&gt;
      A new method is added in the ''AssignmentQuestionnaire'' model class that returns the appropriate questions by querying the ''AssignmentQuestionnaire'' using the ''assignment_id''.&lt;br /&gt;
      This method is added to separate the business logic of retrieving the questions from the controller class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
D. '''awarded_badge.rb'''  &amp;lt;br&amp;gt;&lt;br /&gt;
1. ''award_badge''&lt;br /&gt;
    Parameters :  participant_id, badge_name&lt;br /&gt;
    This method adds the ''badge_name'' to a specific ''participant_id'' in the AwardedBadges table. &lt;br /&gt;
    A separate method is created in the ''AwardedBadges'' model class to avoid the controller class from knowing the business logic of adding a badge name to a participant.&lt;br /&gt;
&lt;br /&gt;
    [[File:RespControllerAwardBadge.png|1200px|]]&lt;br /&gt;
&lt;br /&gt;
    [[File:AwardBadgeMethod.png|1200px|]]&lt;br /&gt;
    &lt;br /&gt;
E. '''cake.rb'''  &amp;lt;br&amp;gt;&lt;br /&gt;
1. ''store_total_cake_score''&lt;br /&gt;
   This method clearly exposes the logic of retrieving the score for a cake question in the ''response_controller.rb'' class which is an incorrect design.  &lt;br /&gt;
   So, a model class method ''get_total_score_for_questions'' is added and the same logic of iterating over the Cake questions is moved there.&lt;br /&gt;
   Return results for this method remains same here.&lt;br /&gt;
&lt;br /&gt;
F. '''response.rb'''  &amp;lt;br&amp;gt;&lt;br /&gt;
1. ''calibration_results_info''&lt;br /&gt;
    This method in ''response.rb'' model is completely removed because this method only adds more complexity to the model class.&lt;br /&gt;
    We refactored the method ''show_calibration_results_for_student'' in the ''response_controller.rb'' class. &lt;br /&gt;
    Previously, ''calibration_results_info'' was just doing nothing but getting responses using ''calibration_response_map_id'' and ''review_response_map_id'', and querying ''AssignmentQuestionnaire''.&lt;br /&gt;
    Both of these operations can be done by using ''find'' method of model class and adding model class ''get_questions_by_assignment_id'' method.&lt;br /&gt;
&lt;br /&gt;
2. ''set_response''&lt;br /&gt;
    @response and @map instance variables are initialized the same way across multiple methods.&lt;br /&gt;
    In order to avoid duplication, we created a before_action action which will be called first before calling the corresponding methods.&lt;br /&gt;
&lt;br /&gt;
    [[File:Set_response_method.png|1200px|]]&lt;br /&gt;
&lt;br /&gt;
3. ''create_or_get_response''&lt;br /&gt;
     Method name ''populate_new_response'' is changed to ''create_or_get_response'' to convey the functionality of the method. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
G. '''Code Climate issues''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. ''Update'' &amp;lt;br&amp;gt;&lt;br /&gt;
     &amp;lt;p&amp;gt; Made changes to split a line into multiple lines because it is too long. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     [[File:Update_line_long.png|1200px|]]&lt;br /&gt;
2. ''Create'' &amp;lt;br&amp;gt;&lt;br /&gt;
     &amp;lt;p&amp;gt; Made changes to split a line into multiple lines because it is too long. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     [[File:Create_line_long.png|1200px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  rspec spec/models/responses_spec.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  rspec spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
Link to Expertiza repository: [https://github.com/expertiza/expertiza here]&lt;br /&gt;
&lt;br /&gt;
Link to the forked repository: [https://github.com/vamshi-chidara/expertiza here]&lt;br /&gt;
&lt;br /&gt;
Link to Pull Request: [https://github.com/expertiza/expertiza/pull/2327 here]&lt;/div&gt;</summary>
		<author><name>Amengan</name></author>
	</entry>
</feed>