<?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=Schidar</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=Schidar"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Schidar"/>
	<updated>2026-05-17T02:14:29Z</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=145663</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=145663"/>
		<updated>2022-05-03T15:04:59Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Regression Testing */&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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added the business logic to ''waitlist_teams.rb'' file&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 1.Changes done 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556 commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2 commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b diff] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files PR] to view the changes.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team - Removed this method as we dont need it in this file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331 diff] to view the changes.&lt;br /&gt;
&lt;br /&gt;
===3. Added new waitlist_teams Table ===&lt;br /&gt;
We added 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 is 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 helps us in managing entries and enforcing constraints and makes 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_teams.rb model class performs 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.&amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0b3fc155270b76c5cdbf311acb356fbcd90873d2704bf87c44ee1d5ce111b9ca file] to view the waitlist_teams model.&lt;br /&gt;
&lt;br /&gt;
=== 4. Migrated 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 moved 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 have written 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 ensures minimal regression breakages and that all existing functionalities are retained. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-327e3874b03ef13dc2d75451388a63d2d28dd775df41e2d48389eb701667f5cb file] to view the migration script.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
'''1. 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;
Please watch this [https://www.youtube.com/watch?v=L6NntAvnzUo Video Demonstration] where we explain the bugs we rectified in this project.&lt;br /&gt;
&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;
*Student Waitlist&lt;br /&gt;
**Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0e90ff1a02697a3552966c713b541746d6b1226088147dcfe333f9605ebeb576 diff] to view the RSpec unit tests for waitlist_teams.rb model file. Few of them are&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: 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: Drop team from the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The student is waitlisted for a topic&lt;br /&gt;
   And: Student drops from the waitlist of this topic&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from 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 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;
&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;
&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 is done to ensure that old test cases still pass. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-41ff53070546cf68377a8592d16001af4558d9aa280bb65a21cf74cc2af33ceb PR] to view the changes to old test cases.&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;
== Conclusions and Future Work ==&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://go.ncsu.edu/fab_four_deployed_application Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145662</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=145662"/>
		<updated>2022-05-03T15:04:03Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Useful Links */&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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added the business logic to ''waitlist_teams.rb'' file&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 1.Changes done 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556 commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2 commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b diff] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files PR] to view the changes.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team - Removed this method as we dont need it in this file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331 diff] to view the changes.&lt;br /&gt;
&lt;br /&gt;
===3. Added new waitlist_teams Table ===&lt;br /&gt;
We added 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 is 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 helps us in managing entries and enforcing constraints and makes 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_teams.rb model class performs 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.&amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0b3fc155270b76c5cdbf311acb356fbcd90873d2704bf87c44ee1d5ce111b9ca file] to view the waitlist_teams model.&lt;br /&gt;
&lt;br /&gt;
=== 4. Migrated 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 moved 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 have written 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 ensures minimal regression breakages and that all existing functionalities are retained. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-327e3874b03ef13dc2d75451388a63d2d28dd775df41e2d48389eb701667f5cb file] to view the migration script.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
'''1. 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;
Please watch this [https://www.youtube.com/watch?v=L6NntAvnzUo Video Demonstration] where we explain the bugs we rectified in this project.&lt;br /&gt;
&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;
*Student Waitlist&lt;br /&gt;
**Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0e90ff1a02697a3552966c713b541746d6b1226088147dcfe333f9605ebeb576 diff] to view the RSpec unit tests for waitlist_teams.rb model file. Few of them are&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: 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: Drop team from the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The student is waitlisted for a topic&lt;br /&gt;
   And: Student drops from the waitlist of this topic&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from 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 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;
&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;
&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 is done to ensure that ''&lt;br /&gt;
''old test cases still pass.'' &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-41ff53070546cf68377a8592d16001af4558d9aa280bb65a21cf74cc2af33ceb PR] to view the changes to old test cases.&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;
== Conclusions and Future Work ==&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://go.ncsu.edu/fab_four_deployed_application Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145661</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=145661"/>
		<updated>2022-05-03T15:03:02Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Video Demonstration */&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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added the business logic to ''waitlist_teams.rb'' file&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 1.Changes done 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556 commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2 commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b diff] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files PR] to view the changes.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team - Removed this method as we dont need it in this file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331 diff] to view the changes.&lt;br /&gt;
&lt;br /&gt;
===3. Added new waitlist_teams Table ===&lt;br /&gt;
We added 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 is 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 helps us in managing entries and enforcing constraints and makes 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_teams.rb model class performs 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.&amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0b3fc155270b76c5cdbf311acb356fbcd90873d2704bf87c44ee1d5ce111b9ca file] to view the waitlist_teams model.&lt;br /&gt;
&lt;br /&gt;
=== 4. Migrated 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 moved 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 have written 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 ensures minimal regression breakages and that all existing functionalities are retained. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-327e3874b03ef13dc2d75451388a63d2d28dd775df41e2d48389eb701667f5cb file] to view the migration script.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
'''1. 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;
Please watch this [https://www.youtube.com/watch?v=L6NntAvnzUo Video Demonstration] where we explain the bugs we rectified in this project.&lt;br /&gt;
&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;
*Student Waitlist&lt;br /&gt;
**Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0e90ff1a02697a3552966c713b541746d6b1226088147dcfe333f9605ebeb576 diff] to view the RSpec unit tests for waitlist_teams.rb model file. Few of them are&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: 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: Drop team from the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The student is waitlisted for a topic&lt;br /&gt;
   And: Student drops from the waitlist of this topic&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from 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 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;
&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;
&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 is done to ensure that ''&lt;br /&gt;
''old test cases still pass.'' &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-41ff53070546cf68377a8592d16001af4558d9aa280bb65a21cf74cc2af33ceb PR] to view the changes to old test cases.&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;
== Conclusions and Future Work ==&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145660</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=145660"/>
		<updated>2022-05-03T05:13:13Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Testing */&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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added the business logic to ''waitlist_teams.rb'' file&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 1.Changes done 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556 commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2 commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b diff] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files PR] to view the changes.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team - Removed this method as we dont need it in this file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331 diff] to view the changes.&lt;br /&gt;
&lt;br /&gt;
===3. Added new waitlist_teams Table ===&lt;br /&gt;
We added 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 is 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 helps us in managing entries and enforcing constraints and makes 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_teams.rb model class performs 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.&amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0b3fc155270b76c5cdbf311acb356fbcd90873d2704bf87c44ee1d5ce111b9ca file] to view the waitlist_teams model.&lt;br /&gt;
&lt;br /&gt;
=== 4. Migrated 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 moved 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 have written 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 ensures minimal regression breakages and that all existing functionalities are retained. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-327e3874b03ef13dc2d75451388a63d2d28dd775df41e2d48389eb701667f5cb file] to view the migration script.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
'''1. 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;
*Student Waitlist&lt;br /&gt;
**Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0e90ff1a02697a3552966c713b541746d6b1226088147dcfe333f9605ebeb576 diff] to view the RSpec unit tests for waitlist_teams.rb model file. Few of them are&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: 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: Drop team from the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The student is waitlisted for a topic&lt;br /&gt;
   And: Student drops from the waitlist of this topic&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from 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 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;
&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;
&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 is done to ensure that ''&lt;br /&gt;
''old test cases still pass.'' &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-41ff53070546cf68377a8592d16001af4558d9aa280bb65a21cf74cc2af33ceb PR] to view the changes to old test cases.&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;
== Conclusions and Future Work ==&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145659</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=145659"/>
		<updated>2022-05-03T05:10:03Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* 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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added the business logic to ''waitlist_teams.rb'' file&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 1.Changes done 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556 commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2 commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b diff] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files PR] to view the changes.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team - Removed this method as we dont need it in this file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331 diff] to view the changes.&lt;br /&gt;
&lt;br /&gt;
===3. Added new waitlist_teams Table ===&lt;br /&gt;
We added 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 is 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 helps us in managing entries and enforcing constraints and makes 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_teams.rb model class performs 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.&amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0b3fc155270b76c5cdbf311acb356fbcd90873d2704bf87c44ee1d5ce111b9ca file] to view the waitlist_teams model.&lt;br /&gt;
&lt;br /&gt;
=== 4. Migrated 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 moved 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 have written 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 ensures minimal regression breakages and that all existing functionalities are retained. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-327e3874b03ef13dc2d75451388a63d2d28dd775df41e2d48389eb701667f5cb file] to view the migration script.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
'''1. 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;
*Student Waitlist&lt;br /&gt;
**Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0e90ff1a02697a3552966c713b541746d6b1226088147dcfe333f9605ebeb576 diff] to view the RSpec unit tests for waitlist_teams.rb model file. Few of them are&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: 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: Drop team from the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The student is waitlisted for a topic&lt;br /&gt;
   And: Student drops from the waitlist of this topic&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from 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 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;
&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;
&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;
'''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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145658</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=145658"/>
		<updated>2022-05-03T05:09:27Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* RSpec Unit Tests */&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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added the business logic to ''waitlist_teams.rb'' file&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 1.Changes done 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556 commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2 commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b diff] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files PR] to view the changes.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team - Removed this method as we dont need it in this file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331 diff] to view the changes.&lt;br /&gt;
&lt;br /&gt;
===3. Added new waitlist_teams Table ===&lt;br /&gt;
We added 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 is 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 helps us in managing entries and enforcing constraints and makes 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_teams.rb model class performs 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.&amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0b3fc155270b76c5cdbf311acb356fbcd90873d2704bf87c44ee1d5ce111b9ca file] to view the waitlist_teams model.&lt;br /&gt;
&lt;br /&gt;
=== 4. Migrated 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 moved 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 have written 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 ensures minimal regression breakages and that all existing functionalities are retained. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-327e3874b03ef13dc2d75451388a63d2d28dd775df41e2d48389eb701667f5cb file] to view the migration script.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
'''1. 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;
*Student Waitlist&lt;br /&gt;
**Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0e90ff1a02697a3552966c713b541746d6b1226088147dcfe333f9605ebeb576 diff] to view the RSpec unit tests for waitlist_teams.rb model file. Few of them are&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: 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: Drop team from the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The student is waitlisted for a topic&lt;br /&gt;
   And: Student drops from the waitlist of this topic&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from 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 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;
&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;
&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145657</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=145657"/>
		<updated>2022-05-03T05:08:54Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* RSpec Unit Tests */&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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added the business logic to ''waitlist_teams.rb'' file&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 1.Changes done 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556 commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2 commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b diff] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files PR] to view the changes.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team - Removed this method as we dont need it in this file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331 diff] to view the changes.&lt;br /&gt;
&lt;br /&gt;
===3. Added new waitlist_teams Table ===&lt;br /&gt;
We added 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 is 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 helps us in managing entries and enforcing constraints and makes 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_teams.rb model class performs 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.&amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0b3fc155270b76c5cdbf311acb356fbcd90873d2704bf87c44ee1d5ce111b9ca file] to view the waitlist_teams model.&lt;br /&gt;
&lt;br /&gt;
=== 4. Migrated 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 moved 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 have written 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 ensures minimal regression breakages and that all existing functionalities are retained. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-327e3874b03ef13dc2d75451388a63d2d28dd775df41e2d48389eb701667f5cb file] to view the migration script.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
'''1. 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;
*Student Waitlist&lt;br /&gt;
Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0e90ff1a02697a3552966c713b541746d6b1226088147dcfe333f9605ebeb576 diff] to view the RSpec unit tests for waitlist_teams.rb model file. Few of them are&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: 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: Drop team from the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The student is waitlisted for a topic&lt;br /&gt;
   And: Student drops from the waitlist of this topic&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from 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 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;
&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;
&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145656</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=145656"/>
		<updated>2022-05-03T05:05:06Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* RSpec Unit Tests */&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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added the business logic to ''waitlist_teams.rb'' file&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 1.Changes done 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556 commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2 commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b diff] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files PR] to view the changes.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team - Removed this method as we dont need it in this file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331 diff] to view the changes.&lt;br /&gt;
&lt;br /&gt;
===3. Added new waitlist_teams Table ===&lt;br /&gt;
We added 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 is 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 helps us in managing entries and enforcing constraints and makes 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_teams.rb model class performs 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.&amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0b3fc155270b76c5cdbf311acb356fbcd90873d2704bf87c44ee1d5ce111b9ca file] to view the waitlist_teams model.&lt;br /&gt;
&lt;br /&gt;
=== 4. Migrated 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 moved 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 have written 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 ensures minimal regression breakages and that all existing functionalities are retained. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-327e3874b03ef13dc2d75451388a63d2d28dd775df41e2d48389eb701667f5cb file] to view the migration script.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
'''1. 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;
Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0e90ff1a02697a3552966c713b541746d6b1226088147dcfe333f9605ebeb576 diff] to view the RSpec unit tests for waitlist_teams.rb model file.&lt;br /&gt;
*Student Waitlist&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: 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: Dropping from the waitlist for a topic &lt;br /&gt;
 Given: Logged in as a Student&lt;br /&gt;
  When: The student is waitlisted for a topic&lt;br /&gt;
   And: Student drops from the waitlist of this topic&lt;br /&gt;
  Then: The team that the student is a part of should be dropped from 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: 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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145655</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=145655"/>
		<updated>2022-05-03T04:49:41Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* 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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added the business logic to ''waitlist_teams.rb'' file&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 1.Changes done 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556 commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2 commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b diff] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files PR] to view the changes.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team - Removed this method as we dont need it in this file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331 diff] to view the changes.&lt;br /&gt;
&lt;br /&gt;
===3. Added new waitlist_teams Table ===&lt;br /&gt;
We added 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 is 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 helps us in managing entries and enforcing constraints and makes 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_teams.rb model class performs 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.&amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0b3fc155270b76c5cdbf311acb356fbcd90873d2704bf87c44ee1d5ce111b9ca file] to view the waitlist_teams model.&lt;br /&gt;
&lt;br /&gt;
=== 4. Migrated 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 moved 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 have written 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 ensures minimal regression breakages and that all existing functionalities are retained. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-327e3874b03ef13dc2d75451388a63d2d28dd775df41e2d48389eb701667f5cb file] to view the migration script.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
'''1. 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;
*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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145654</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=145654"/>
		<updated>2022-05-03T04:49:18Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* RSpec Unit Tests */&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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added the business logic to ''waitlist_teams.rb'' file&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 1.Changes done 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556 commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2 commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b diff] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files PR] to view the changes.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team - Removed this method as we dont need it in this file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331 diff] to view the changes.&lt;br /&gt;
&lt;br /&gt;
===3. Added new waitlist_teams Table ===&lt;br /&gt;
We added 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 is 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 helps us in managing entries and enforcing constraints and makes 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_teams.rb model class performs 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.&amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0b3fc155270b76c5cdbf311acb356fbcd90873d2704bf87c44ee1d5ce111b9ca file] to view the waitlist_teams model.&lt;br /&gt;
&lt;br /&gt;
=== 4. Migrated 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 moved 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 have written 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 ensures minimal regression breakages and that all existing functionalities are retained. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-327e3874b03ef13dc2d75451388a63d2d28dd775df41e2d48389eb701667f5cb file] to view the migration script.&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;
*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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145653</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=145653"/>
		<updated>2022-05-03T04:15:56Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Actions performed */&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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added the business logic to ''waitlist_teams.rb'' file&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 1.Changes done 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556 commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2 commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b diff] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files PR] to view the changes.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team - Removed this method as we dont need it in this file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331 diff] to view the changes.&lt;br /&gt;
&lt;br /&gt;
===3. Added new waitlist_teams Table ===&lt;br /&gt;
We added 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 is 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 helps us in managing entries and enforcing constraints and makes 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_teams.rb model class performs 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.&amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-0b3fc155270b76c5cdbf311acb356fbcd90873d2704bf87c44ee1d5ce111b9ca file] to view the waitlist_teams model.&lt;br /&gt;
&lt;br /&gt;
=== 4. Migrated 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 moved 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 have written 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 ensures minimal regression breakages and that all existing functionalities are retained. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-327e3874b03ef13dc2d75451388a63d2d28dd775df41e2d48389eb701667f5cb file] to view the migration script.&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145652</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=145652"/>
		<updated>2022-05-03T04:14:35Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Actions performed */&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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added the business logic to ''waitlist_teams.rb'' file&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 1.Changes done 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556 commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2 commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b diff] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files PR] to view the changes.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team - Removed this method as we dont need it in this file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331 diff] to view the changes.&lt;br /&gt;
&lt;br /&gt;
===3. Added new waitlist_teams Table ===&lt;br /&gt;
We added 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 is 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 helps us in managing entries and enforcing constraints and makes 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_teams.rb model class performs 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. Migrated 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 moved 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 have written 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 ensures minimal regression breakages and that all existing functionalities are retained. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-327e3874b03ef13dc2d75451388a63d2d28dd775df41e2d48389eb701667f5cb file] to view the migration script.&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145651</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=145651"/>
		<updated>2022-05-03T04:13:15Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Actions performed */&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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added the business logic to ''waitlist_teams.rb'' file&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 1.Changes done 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556 commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2 commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b diff] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files PR] to view the changes.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team - Removed this method as we dont need it in this file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331 diff] to view the changes.&lt;br /&gt;
&lt;br /&gt;
===3. Added new waitlist_teams Table ===&lt;br /&gt;
We added 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 is 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 helps us in managing entries and enforcing constraints and makes 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_teams.rb model class performs 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. Migrated 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 moved 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 have written 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 ensures minimal regression breakages and that all existing functionalities are retained.&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145650</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=145650"/>
		<updated>2022-05-03T04:11:36Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* 4. Migrating existing waitlists to use new table */&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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added the business logic to ''waitlist_teams.rb'' file&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 1.Changes done 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556 commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2 commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b diff] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files PR] to view the changes.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team - Removed this method as we dont need it in this file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331 diff] to view the changes.&lt;br /&gt;
&lt;br /&gt;
===3. Added new waitlist_teams Table ===&lt;br /&gt;
We added 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 is 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 helps us in managing entries and enforcing constraints and makes 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_teams.rb model class performs 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. Migrated 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 moved 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 have written 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 ensures minimal regression breakages and that all existing functionalities are retained.&lt;br /&gt;
&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145649</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=145649"/>
		<updated>2022-05-03T04:08:50Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Actions performed */&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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added the business logic to ''waitlist_teams.rb'' file&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 1.Changes done 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556 commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2 commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b diff] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files PR] to view the changes.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team - Removed this method as we dont need it in this file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331 diff] to view the changes.&lt;br /&gt;
&lt;br /&gt;
===3. Added new waitlist_teams Table ===&lt;br /&gt;
We added 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 is 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 helps us in managing entries and enforcing constraints and makes 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_teams.rb model class performs 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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145648</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=145648"/>
		<updated>2022-05-03T04:06:14Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* 2. Files and methods refactored */&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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556 commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2 commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b diff] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files PR] to view the changes.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team - Removed this method as we dont need it in this file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331 diff] to view the changes.&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145647</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=145647"/>
		<updated>2022-05-03T04:05:21Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* 2. Files and methods refactored */&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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a/view commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d/view commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556/view commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2/view commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b diff] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files PR] to view the changes.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team - Removed this method as we dont need it in this file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331 diff] to view the changes.&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145646</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=145646"/>
		<updated>2022-05-03T04:04:22Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* 2. Files and methods refactored */&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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a/view commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d/view commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556/view commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2/view commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b/view PR] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files PR] to view the changes.&lt;br /&gt;
#invitation.rb&lt;br /&gt;
##remove_waitlists_for_team - Removed this method as we dont need it in this file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331 diff] to view the changes.&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145645</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=145645"/>
		<updated>2022-05-03T03:59:27Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* 2. Files and methods refactored */&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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a/view commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d/view commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556/view commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2/view commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b/view PR] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files/view PR] to view the changes.&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. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/files/view PR] to view the changes.&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145644</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=145644"/>
		<updated>2022-05-03T03:55:55Z</updated>

		<summary type="html">&lt;p&gt;Schidar: &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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a/view commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d/view commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556/view commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2/view commit] to view the changes.&lt;br /&gt;
#sign_up_topic.rb&lt;br /&gt;
##users_on_waiting_list - Moved this method to fetch all users on waitlist for a topic to waitlist_teams model file.&lt;br /&gt;
##assign_to_first_waiting_team - The same functionality is being called in multiple places. This is modified to comply with DRY and is moved to the waitlist_teams model&lt;br /&gt;
##reassign_topic - Modified this method to use waitlist_teams.rb model file for actions on waitlisted teams.&lt;br /&gt;
##update_waitlisted_users - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_slots_waitlisted - Moved this method to waitlist_teams model file.&lt;br /&gt;
##find_waitlisted_topics - Moved this method to waitlist_teams model file. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-e0df714a791bc6d36e6b27b82af71be36e8eac2cd21af5ea28a8bc5303953f5b/view PR] to view the changes.&lt;br /&gt;
#suggestion_controller.rb&lt;br /&gt;
##notification - Clean waitlist functionality is moved to a method in waitlist_teams model. team id is passed as a parameter to delete the waitlist for that team. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/14/commits/e2c6614a726c1dbfd157b42ba0a1bd51db03433c/view PR] to view the changes.&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145643</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=145643"/>
		<updated>2022-05-03T03:31:37Z</updated>

		<summary type="html">&lt;p&gt;Schidar: &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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a/view commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d/view commit] to view the changes.&lt;br /&gt;
#sign_up_sheet.rb&lt;br /&gt;
##cancel_all_wailists&lt;br /&gt;
###This method previously has done 2 things, it cancelled waitlist and also updated the signed_up_team topic which needs to be split to comply with single responsibility principle. We ensured that is happening in the current implementation. &amp;lt;br&amp;gt; Refer to this [https://github.com/expertiza/expertiza/pull/2384/files#diff-f7b8fbeb82e3d7d5481ba3ed065d55838a21a82ebd055ac076ea36f222f88556/view commit] to view the changes.&lt;br /&gt;
##create_SignUpTeam&lt;br /&gt;
### This method in the previous implementation checked if topic has slots. If yes, it added to signed up team, else created a signup as waitlist. &amp;lt;br&amp;gt; We modified this in order to use the new table and call the functions of waitlist_teams.rb to perform actions on waitlists. [https://github.com/akhilkumarmengani/expertiza/pull/12/commits/7194a53ec01e78ea0d95920624436da6fe9933e2/view commit] to view the changes.&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145642</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=145642"/>
		<updated>2022-05-03T03:04:12Z</updated>

		<summary type="html">&lt;p&gt;Schidar: &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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist_teams.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. &amp;lt;br&amp;gt; We have eliminated the waitlist.rb file and moved all the references to this class to the new waitlist_teams.rb model file. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a/view commit] to view the changes.&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
##set_values_for_new_topic&lt;br /&gt;
###Added code to get waitlisted entries from new table instead of having all the entries from signed_up_teams table. &amp;lt;br&amp;gt; Refer to this https://github.com/akhilkumarmengani/expertiza/pull/15/commits/44a0f06761dfc681d6ed8e6d9ecd3017a816848d/view commit] to view the changes.&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145641</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=145641"/>
		<updated>2022-05-03T02:52:27Z</updated>

		<summary type="html">&lt;p&gt;Schidar: &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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous implementation had 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 have rewritten the methods in multiple controllers and model files that manipulate waitlists of a topic. All these classes now just invoke methods of waitlist.rb. The following files contains the waitlist functionality which we have modified to refer to the new model file.&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;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
Since our goal is to fix existing functionalities we did not update 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. We tested the existing features and ensured that we are not breaking what was working before we deployed our fix.&lt;br /&gt;
We can say that we achieved our goal of making 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;
== Actions performed ==&lt;br /&gt;
&lt;br /&gt;
Following are the sections of changes that we have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a/view commit] to view the changes.&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145640</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=145640"/>
		<updated>2022-05-03T01:56:28Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* 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;
We simplified the way we are handling the second case. For each topic, we have a waitlist object associated with it. If a team has requested for a topic that is not available, the team is queued on to the waitlist for this topic. In the waitlist table, we maintain the team id and the topic id for which this team is waitlisted. In the previous implementation, the waitlisting functionality is scattered across multiple files. All this is consolidated and placed in one model file ( waitlists.rb )&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
The previous 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 have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a/view commit] to view the changes.&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145639</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=145639"/>
		<updated>2022-05-03T01:48:59Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* 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 have done in this project : &amp;lt;br&amp;gt;&lt;br /&gt;
1. Updated the SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Refactored files that contains waitlist functionality &amp;lt;br&amp;gt;&lt;br /&gt;
3. Added new WAITLIST_TEAMS table using scaffold. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Migrated the data to WAITLIST_TEAMS table from SIGNED_UP_TEAMS table. &amp;lt;br&amp;gt;&lt;br /&gt;
5. Added 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 have eliminated the use of is_waitlisted column of this table. Instead, we have used a separate table &amp;lt;b&amp;gt;waitlist_teams&amp;lt;/b&amp;gt; for waitlisting entries. With this, the signed_up_teams table consists of only signed up teams and waitlist_teams consists of only waitlisted up teams.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
All existing references to the is_waitlisted flag has been rewritten to make use of the new table.&lt;br /&gt;
&lt;br /&gt;
=== 2. Files and methods refactored ===&lt;br /&gt;
&lt;br /&gt;
#signed_up_team.rb&lt;br /&gt;
##All references to the is_waitlisted boolean flag are removed and waitlists are determined by using the new waitlist_team table. &lt;br /&gt;
#waitlist.rb&lt;br /&gt;
##We have completely eliminated this class. We have used &amp;lt;b&amp;gt;WaitlistTeam&amp;lt;/b&amp;gt; in place of this class and this contains all business logic for managing waitlisted teams for topics. &amp;lt;br&amp;gt; Refer to this [https://github.com/akhilkumarmengani/expertiza/pull/1/commits/f1520041e759518e87109be1fa6adf539d7deb0a/view commit] to view the changes.&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=145638</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=145638"/>
		<updated>2022-05-03T01:25:47Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Useful Links */&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;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2384/view Pull request] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://152.7.98.216:8080/view Deployed application with changes] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://github.com/akhilkumarmengani/expertiza/view Forked repository] &amp;lt;br/&amp;gt;&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>Schidar</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=144876</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=144876"/>
		<updated>2022-04-12T02:19:42Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Class Diagram */&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;
=== 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>Schidar</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=144853</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=144853"/>
		<updated>2022-04-12T01:55:52Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* 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 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>Schidar</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=144520</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=144520"/>
		<updated>2022-04-07T01:45:55Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Problem Statement */&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;
[[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>Schidar</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=144514</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=144514"/>
		<updated>2022-04-07T01:37:39Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Overview of Major Changes */&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 ). This is pretty straightforward.&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, 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;
[[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>Schidar</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=144508</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=144508"/>
		<updated>2022-04-07T00:57:33Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Problem Statement */&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 ). This is pretty straightforward.&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, 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;
&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;
[[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>Schidar</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=144502</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=144502"/>
		<updated>2022-04-07T00:31:27Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Problem Statement */&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 ). This is pretty straightforward.&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, 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;
=== 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;
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;
[[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>Schidar</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=144467</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=144467"/>
		<updated>2022-04-06T23:41:51Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Problem Statement */&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 ). This is pretty straightforward.&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, 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. The current implementation has most of the code for manipulating waitlists in sign_up_topic.rb, with other portions in waitlist.rb, invitation.rb, lottery_controller.rb, suggestion_controller.rb and signed_up_team.rb. There are other files too which invoke waitlist functionality by calling methods of the above class.&lt;br /&gt;
&lt;br /&gt;
&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;
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;
[[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>Schidar</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=144396</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=144396"/>
		<updated>2022-04-06T20:38:47Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Problem Statement */&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;
=== 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;
#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;
#suggestion_controller.rb&lt;br /&gt;
#invitation.rb&lt;br /&gt;
&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>Schidar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143609</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=143609"/>
		<updated>2022-03-27T21:35:21Z</updated>

		<summary type="html">&lt;p&gt;Schidar: &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;
   &lt;br /&gt;
   '''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 &lt;br /&gt;
   ''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;
   [[File:Authorize_show_calibration_results.png|1180px|]]&lt;br /&gt;
&lt;br /&gt;
   '''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;
   [[File:Set_response_method.png|1170px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
B. '''response_helper.rb''' &amp;lt;br&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
   Following methods are moved from the ''response_controller.rb'' class to ''response_helper.rb'' class since these methods are called from the &lt;br /&gt;
   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|1170px|]]&lt;br /&gt;
&lt;br /&gt;
    [[File:Response_helper_2.png|1170px|]]&lt;br /&gt;
&lt;br /&gt;
C. '''assignment_questionnaire.rb''' &amp;lt;br&amp;gt;&lt;br /&gt;
   '''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 &lt;br /&gt;
   ''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|1170px|]]&lt;br /&gt;
&lt;br /&gt;
D. '''awarded_badge.rb'''  &amp;lt;br&amp;gt;&lt;br /&gt;
   '''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 &lt;br /&gt;
   name to a participant.&lt;br /&gt;
   &lt;br /&gt;
   [[File:RespControllerAwardBadge.png|1170px|]]&lt;br /&gt;
&lt;br /&gt;
   [[File:AwardBadgeMethod.png|1170px|]]&lt;br /&gt;
    &lt;br /&gt;
E. '''cake.rb'''  &amp;lt;br&amp;gt;&lt;br /&gt;
   '''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 &lt;br /&gt;
   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;
   [[File:Cake.png|1170px|]]&lt;br /&gt;
&lt;br /&gt;
F. '''response.rb'''  &amp;lt;br&amp;gt;&lt;br /&gt;
   '''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 &lt;br /&gt;
   ''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;
   '''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|1170px|]]&lt;br /&gt;
&lt;br /&gt;
G. '''Code Climate issues''' &amp;lt;br&amp;gt;&lt;br /&gt;
   '''Update'''&lt;br /&gt;
   Made changes to split a line into multiple lines because it is too long.&lt;br /&gt;
   [[File:Update_line_long.png|1170px|]]&lt;br /&gt;
   &lt;br /&gt;
   '''Create'''&lt;br /&gt;
   Made changes to split a line into multiple lines because it is too long.&lt;br /&gt;
   [[File:Create_line_long.png|1170px|]]&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
This is a refactoring project, so we have refactored response controller while ensuring that existing tests don't break.&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  rspec spec/controllers/response_controller_spec.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&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;
=== UI Testing ===&lt;br /&gt;
1) Login using the following details. User Name: student432 Password: password&lt;br /&gt;
&lt;br /&gt;
[[File:resp_p1.png|800px|]]&lt;br /&gt;
&lt;br /&gt;
2) Click on the assignment Design Exercise pertaining to course CSC/ECE 517, Spring 2017 &lt;br /&gt;
&lt;br /&gt;
[[File:resp_p2.png|800px|]]&lt;br /&gt;
&lt;br /&gt;
3) Click on other's work&lt;br /&gt;
&lt;br /&gt;
[[File:resp_p3.png|800px|]]&lt;br /&gt;
&lt;br /&gt;
4) Click on show calibration results, verify if the calibration results are displayed on the UI.&lt;br /&gt;
&lt;br /&gt;
[[File:resp_p4.png|800px|]]&lt;br /&gt;
&lt;br /&gt;
[[File:resp_p5.png|800px|]]&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>Schidar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143511</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=143511"/>
		<updated>2022-03-22T02:59:11Z</updated>

		<summary type="html">&lt;p&gt;Schidar: &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;
   &lt;br /&gt;
   '''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 &lt;br /&gt;
   ''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;
   [[File:Authorize_show_calibration_results.png|1180px|]]&lt;br /&gt;
&lt;br /&gt;
   '''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;
   [[File:Set_response_method.png|1170px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
B. '''response_helper.rb''' &amp;lt;br&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
   Following methods are moved from the ''response_controller.rb'' class to ''response_helper.rb'' class since these methods are called from the &lt;br /&gt;
   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|1170px|]]&lt;br /&gt;
&lt;br /&gt;
    [[File:Response_helper_2.png|1170px|]]&lt;br /&gt;
&lt;br /&gt;
C. '''assignment_questionnaire.rb''' &amp;lt;br&amp;gt;&lt;br /&gt;
   '''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 &lt;br /&gt;
   ''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|1170px|]]&lt;br /&gt;
&lt;br /&gt;
D. '''awarded_badge.rb'''  &amp;lt;br&amp;gt;&lt;br /&gt;
   '''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 &lt;br /&gt;
   name to a participant.&lt;br /&gt;
   &lt;br /&gt;
   [[File:RespControllerAwardBadge.png|1170px|]]&lt;br /&gt;
&lt;br /&gt;
   [[File:AwardBadgeMethod.png|1170px|]]&lt;br /&gt;
    &lt;br /&gt;
E. '''cake.rb'''  &amp;lt;br&amp;gt;&lt;br /&gt;
   '''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 &lt;br /&gt;
   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;
   [[File:Cake.png|1170px|]]&lt;br /&gt;
&lt;br /&gt;
F. '''response.rb'''  &amp;lt;br&amp;gt;&lt;br /&gt;
   '''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 &lt;br /&gt;
   ''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;
   '''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|1170px|]]&lt;br /&gt;
&lt;br /&gt;
G. '''Code Climate issues''' &amp;lt;br&amp;gt;&lt;br /&gt;
   '''Update'''&lt;br /&gt;
   Made changes to split a line into multiple lines because it is too long.&lt;br /&gt;
   [[File:Update_line_long.png|1170px|]]&lt;br /&gt;
   &lt;br /&gt;
   '''Create'''&lt;br /&gt;
   Made changes to split a line into multiple lines because it is too long.&lt;br /&gt;
   [[File:Create_line_long.png|1170px|]]&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>Schidar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143155</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=143155"/>
		<updated>2022-03-21T16:14:14Z</updated>

		<summary type="html">&lt;p&gt;Schidar: &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 (amengan@ncsu.edu)&lt;br /&gt;
* Samson Mulkur (smulkur@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Code Modifications and Refactorization ==&lt;br /&gt;
Described below are the code refactoring tasks and issues addressed by this team. We have also included any pertinent details, reasonings, comments, warnings, etc., corresponding to each task.&lt;br /&gt;
&lt;br /&gt;
=== METHOD: def set_response ===&lt;br /&gt;
@response and @map instance variables are initialized the same way across multiple methods. In order to avoid duplication, we created a &lt;br /&gt;
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;
== Modified Files ==&lt;br /&gt;
&amp;lt;code&amp;gt;response_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response_helper.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;assignment_questionnaire.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awarded_badge.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cake.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response.rb&amp;lt;/code&amp;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/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>Schidar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143154</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=143154"/>
		<updated>2022-03-21T16:11:54Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Code Modifications and Refactorization */&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 (amengan@ncsu.edu)&lt;br /&gt;
* Samson Mulkur (smulkur@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Code Modifications and Refactorization ==&lt;br /&gt;
Described below are the code refactoring tasks and issues addressed by this team. We have also included any pertinent details, reasonings, comments, warnings, etc., corresponding to each task.&lt;br /&gt;
&lt;br /&gt;
=== METHOD: def set_response ===&lt;br /&gt;
@response and @map instance variables are initialized the same way across multiple methods. In order to avoid duplication, we created a &lt;br /&gt;
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|thumb|left]]&lt;br /&gt;
&lt;br /&gt;
== Modified Files ==&lt;br /&gt;
&amp;lt;code&amp;gt;response_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response_helper.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;assignment_questionnaire.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awarded_badge.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cake.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response.rb&amp;lt;/code&amp;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/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>Schidar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143153</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=143153"/>
		<updated>2022-03-21T16:10:52Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Code Modifications and Refactorization */&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 (amengan@ncsu.edu)&lt;br /&gt;
* Samson Mulkur (smulkur@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Code Modifications and Refactorization ==&lt;br /&gt;
Described below are the code refactoring tasks and issues addressed by this team. We have also included any pertinent details, reasonings, comments, warnings, etc., corresponding to each task.&lt;br /&gt;
&lt;br /&gt;
* '''Initializing response and map variables'''&lt;br /&gt;
  @response and @map instance variables are initialized the same way across multiple methods. In order to avoid duplication, we created a &lt;br /&gt;
  before_action action which will be called first before calling the corresponding methods.&lt;br /&gt;
&lt;br /&gt;
  [[File:Set_response_method.png|1205px|thumb|left]]&lt;br /&gt;
&lt;br /&gt;
== Modified Files ==&lt;br /&gt;
&amp;lt;code&amp;gt;response_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response_helper.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;assignment_questionnaire.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awarded_badge.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cake.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response.rb&amp;lt;/code&amp;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/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>Schidar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Set_response_method.png&amp;diff=143152</id>
		<title>File:Set response method.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Set_response_method.png&amp;diff=143152"/>
		<updated>2022-03-21T16:07:54Z</updated>

		<summary type="html">&lt;p&gt;Schidar: Before action method to initialize response and map instance variables&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Before action method to initialize response and map instance variables&lt;/div&gt;</summary>
		<author><name>Schidar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143151</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=143151"/>
		<updated>2022-03-21T16:02:24Z</updated>

		<summary type="html">&lt;p&gt;Schidar: &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 (amengan@ncsu.edu)&lt;br /&gt;
* Samson Mulkur (smulkur@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Code Modifications and Refactorization ==&lt;br /&gt;
Described below are the code refactoring tasks and issues addressed by this team. We have also included any pertinent details, reasonings, comments, warnings, etc., corresponding to each task.&lt;br /&gt;
&lt;br /&gt;
* '''Initializing response and map variables'''&lt;br /&gt;
  @response and @map instance variables are initialized the same way across multiple methods. In order to avoid duplication, we created a &lt;br /&gt;
  before_action action which will be called first before calling the corresponding methods.&lt;br /&gt;
&lt;br /&gt;
     def set_response&lt;br /&gt;
        @response = Response.find(params[:id])&lt;br /&gt;
        @map = @response.map&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
== Modified Files ==&lt;br /&gt;
&amp;lt;code&amp;gt;response_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response_helper.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;assignment_questionnaire.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awarded_badge.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cake.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response.rb&amp;lt;/code&amp;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/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>Schidar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143150</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=143150"/>
		<updated>2022-03-21T16:02:09Z</updated>

		<summary type="html">&lt;p&gt;Schidar: &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 (amengan@ncsu.edu)&lt;br /&gt;
* Samson Mulkur (smulkur@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Code Modifications and Refactorization ==&lt;br /&gt;
Described below are the code refactoring tasks and issues addressed by this team. We have also included any pertinent details, reasonings, comments, warnings, etc., corresponding to each task.&lt;br /&gt;
&lt;br /&gt;
* '''Initializing response and map variables'''&lt;br /&gt;
  @response and @map instance variables are initialized the same way across multiple methods. In order to avoid duplication, we created a &lt;br /&gt;
  before_action action which will be called first before calling the corresponding methods.&lt;br /&gt;
&lt;br /&gt;
     def set_response&lt;br /&gt;
        @response = Response.find(params[:id])&lt;br /&gt;
        @map = @response.map&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
== Modified Files ==&lt;br /&gt;
&amp;lt;code&amp;gt;response_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response_helper.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;assignment_questionnaire.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awarded_badge.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cake.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response.rb&amp;lt;/code&amp;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/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&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>Schidar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143149</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=143149"/>
		<updated>2022-03-21T16:00:06Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Code Modifications and Refactorization */&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 (amengan@ncsu.edu)&lt;br /&gt;
* Samson Mulkur (smulkur@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Code Modifications and Refactorization ==&lt;br /&gt;
Described below are the code refactoring tasks and issues addressed by this team. We have also included any pertinent details, reasonings, comments, warnings, etc., corresponding to each task.&lt;br /&gt;
&lt;br /&gt;
* '''Initializing response and map variables'''&lt;br /&gt;
  @response and @map instance variables are initialized the same way across multiple methods. In order to avoid duplication, we created a &lt;br /&gt;
  before_action action which will be called first before calling the corresponding methods.&lt;br /&gt;
&lt;br /&gt;
     def set_response&lt;br /&gt;
        @response = Response.find(params[:id])&lt;br /&gt;
        @map = @response.map&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
== Modified Files ==&lt;br /&gt;
&amp;lt;code&amp;gt;response_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response_helper.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;assignment_questionnaire.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awarded_badge.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cake.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&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>Schidar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143148</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=143148"/>
		<updated>2022-03-21T15:58:03Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Code Modifications and Refactorization */&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 (amengan@ncsu.edu)&lt;br /&gt;
* Samson Mulkur (smulkur@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Code Modifications and Refactorization ==&lt;br /&gt;
Described below are the code refactoring tasks and issues addressed by this team. We have also included any pertinent details, reasonings, comments, warnings, etc., corresponding to each task.&lt;br /&gt;
&lt;br /&gt;
* '''Initializing response and map variables'''&lt;br /&gt;
     @response and @map instance variables are initialized the same way across multiple methods. In order to avoid duplication, we created a &lt;br /&gt;
     before_action action which will be called first before calling the corresponding methods.&lt;br /&gt;
&lt;br /&gt;
== Modified Files ==&lt;br /&gt;
&amp;lt;code&amp;gt;response_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response_helper.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;assignment_questionnaire.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awarded_badge.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cake.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&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>Schidar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143145</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=143145"/>
		<updated>2022-03-21T15:24:09Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Code Modifications and Refactorization */&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 (amengan@ncsu.edu)&lt;br /&gt;
* Samson Mulkur (smulkur@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Code Modifications and Refactorization ==&lt;br /&gt;
Described below are the code refactoring tasks and issues addressed by this team. We have also included any pertinent details, reasonings, comments, warnings, etc., corresponding to each task.&lt;br /&gt;
&lt;br /&gt;
* '''Initializing response and map variables'''&lt;br /&gt;
@response and @map instance variables are initialized the same way across multiple methods. 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;
== Modified Files ==&lt;br /&gt;
&amp;lt;code&amp;gt;response_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response_helper.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;assignment_questionnaire.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awarded_badge.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cake.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&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>Schidar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143124</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=143124"/>
		<updated>2022-03-21T03:08:30Z</updated>

		<summary type="html">&lt;p&gt;Schidar: &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 (amengan@ncsu.edu)&lt;br /&gt;
* Samson Mulkur (smulkur@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Code Modifications and Refactorization ==&lt;br /&gt;
Described below are the code refactoring tasks and issues addressed by this team. We have also included any pertinent details, reasonings, comments, warnings, etc., corresponding to each task.&lt;br /&gt;
&lt;br /&gt;
== Modified Files ==&lt;br /&gt;
&amp;lt;code&amp;gt;response_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response_helper.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;assignment_questionnaire.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awarded_badge.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cake.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&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>Schidar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143123</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=143123"/>
		<updated>2022-03-21T03:08:16Z</updated>

		<summary type="html">&lt;p&gt;Schidar: /* Refactorization and Code Modifications */&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 (amengan@ncsu.edu)&lt;br /&gt;
* Samson Mulkur (smulkur@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Issues ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Modifications and Refactorization ==&lt;br /&gt;
Described below are the code refactoring tasks and issues addressed by this team. We have also included any pertinent details, reasonings, comments, warnings, etc., corresponding to each task.&lt;br /&gt;
&lt;br /&gt;
== Modified Files ==&lt;br /&gt;
&amp;lt;code&amp;gt;response_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response_helper.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;assignment_questionnaire.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awarded_badge.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cake.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&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>Schidar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143102</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=143102"/>
		<updated>2022-03-21T01:33:03Z</updated>

		<summary type="html">&lt;p&gt;Schidar: &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 (amengan@ncsu.edu)&lt;br /&gt;
* Samson Mulkur (smulkur@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Issues ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refactorization and Code Modifications ==&lt;br /&gt;
Below is a list of code refactor tasks and issues addressed by this team in this project. We have also included any pertinent details, reasonings, comments, warnings, etc., corresponding to each task.&lt;br /&gt;
&lt;br /&gt;
== Modified Files ==&lt;br /&gt;
&amp;lt;code&amp;gt;response_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response_helper.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;assignment_questionnaire.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awarded_badge.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cake.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;response.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&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>Schidar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143099</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=143099"/>
		<updated>2022-03-21T01:09:34Z</updated>

		<summary type="html">&lt;p&gt;Schidar: &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 (amengan@ncsu.edu)&lt;br /&gt;
* Samson Mulkur (smulkur@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Issues ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refactorization and Code Modifications ==&lt;br /&gt;
Below is a list of code refactor tasks and issues addressed by this team in this project. We have also included any pertinent details, reasonings, comments, warnings, etc., corresponding to each task.&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>Schidar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2218:_Refactor_response_controller&amp;diff=143098</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=143098"/>
		<updated>2022-03-21T00:43:41Z</updated>

		<summary type="html">&lt;p&gt;Schidar: Created page with &amp;quot;This page details project documentation for the CSC/ECE 517 Spring 2022, &amp;quot;E2218 refactor response_controller.rb&amp;quot; project.   == Background ==  A response is the object that is...&amp;quot;&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 (amengan@ncsu.edu)&lt;br /&gt;
* Samson Mulkur (smulkur@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Issues ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refactorization and Code Modifications ==&lt;br /&gt;
Below is a list of code refactor tasks and issues addressed by this team in this project. We have also included any pertinent details, reasonings, comments, warnings, etc., corresponding to each task.&lt;/div&gt;</summary>
		<author><name>Schidar</name></author>
	</entry>
</feed>