Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprint 2: Deployed frontend #23

Merged
merged 54 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
84391e9
feat: add course information spreadsheet input page
dh-giang-vu Sep 1, 2024
129a83e
Merge pull request #5 from hotungkhanh/kan-25-26-27/spreadsheet-input…
dh-giang-vu Sep 1, 2024
cef0c58
feat(database): connect Quarkus with Azure PostgreSQL database, creat…
FlyingPufferFish Sep 6, 2024
7dc4bee
feat: add Student class
Sep 13, 2024
2f7bf6e
feat: add Room class
Sep 13, 2024
0ed9e82
feat: add Unit class
Sep 13, 2024
f75f06f
feat: add ConflictingUnit class
Sep 13, 2024
1a346ce
feat: add Timetable class
Sep 13, 2024
4b46ebe
feat: add TimetableResource to provide the problem and get the soluti…
Sep 13, 2024
a0b1208
feat: add student constraint: no students have overlapping units
Sep 13, 2024
5957dba
feat: add room constraint, no overlapping units are in the same room
Sep 13, 2024
6454978
feat: add room capacity constraint, ensure room capacity is not less …
Sep 13, 2024
b2fe2f5
refactor: move classes to domain package
Sep 13, 2024
44ff683
refactor: move constraints to solver package
Sep 13, 2024
fe949ae
refactor: remove redundant methods from Unit class
Sep 13, 2024
fdc8f61
Merge pull request #6 from hotungkhanh/kan-32-34-45/backend-constraints
JackTong24 Sep 13, 2024
1b14fb4
feat: add the day-of-week to Unit
Sep 14, 2024
39756dc
feat: add the day-of-week to Timetable
Sep 14, 2024
2e1d2e5
feat: add day-of-week to constraints, add comments to explain the con…
Sep 14, 2024
bab1a2e
feat: add day-of-week to problem in TimetableResource
Sep 14, 2024
d960b1a
feat: add isLab attribute to Room, whether it is a laboratory
Sep 14, 2024
b82d52f
feat: add wantsLab attribute to Unit, whether it prefers a laboratory…
Sep 14, 2024
a23e2a7
feat: add lab preference constraint, lab units prefer lab rooms
Sep 14, 2024
3d0a34d
Merge pull request #7 from hotungkhanh/kan-32-34-45/backend-constraints
NguyenDonLam Sep 14, 2024
0e4a78f
feat: store user input data in indexedDB; remove sessionStorage
dh-giang-vu Sep 15, 2024
60b407a
Merge pull request #9 from hotungkhanh/kan-56/frontend-persistence
NguyenDonLam Sep 15, 2024
3af65a4
Merge pull request #8 from hotungkhanh/kan-41/database
NguyenDonLam Sep 15, 2024
5fa57e0
Revert "Merge pull request #8 from hotungkhanh/kan-41/database"
dh-giang-vu Sep 15, 2024
d9e8638
feat: parse and send user input
dh-giang-vu Sep 15, 2024
42f0458
Revert "Revert "Merge pull request #8 from hotungkhanh/kan-41/database""
FlyingPufferFish Sep 15, 2024
4eb7c18
feat: send + test display response
dh-giang-vu Sep 15, 2024
28da8d8
Merge pull request #10 from hotungkhanh/kan-48/send-user-input
hotungkhanh Sep 18, 2024
c16b96a
fix: handle empty user input edge cases + list of units readonly
dh-giang-vu Sep 22, 2024
2f6e591
fix: delete corresponding rows from indexedDB when user delete rows f…
dh-giang-vu Sep 22, 2024
3d71aac
Merge pull request #12 from hotungkhanh/kan-56/frontend-persistence
NguyenDonLam Sep 22, 2024
db9bda9
Merge pull request #13 from hotungkhanh/kan-48/send-user-input
NguyenDonLam Sep 22, 2024
a8d6c59
build: add files for frontend deployment
dh-giang-vu Sep 22, 2024
2f8bb4c
Merge pull request #14 from hotungkhanh/deploy-frontend
hotungkhanh Sep 22, 2024
6cc4dd0
Merge pull request #15 from hotungkhanh/main
hotungkhanh Sep 22, 2024
de74e95
docs: update comments / JSDoc
dh-giang-vu Sep 22, 2024
38db9a1
Merge pull request #17 from hotungkhanh/kan-54/frontend-comment
NguyenDonLam Sep 22, 2024
7eba07c
feat: add room conflict unit test
JackTong24 Sep 23, 2024
be0ac08
fix: room conflict test
JackTong24 Sep 23, 2024
71c3c9e
feat: add student conflict test
JackTong24 Sep 23, 2024
a194594
feat: add room capacity conflict test
JackTong24 Sep 23, 2024
69c3594
feat: add lab concflict test
JackTong24 Sep 23, 2024
f00e59d
feat: add test for fetchTimetableSolution API method
dh-giang-vu Sep 24, 2024
403c887
feat: modify enrolment page to test CI/CD
dh-giang-vu Sep 24, 2024
8e7b351
Merge pull request #18 from hotungkhanh/kan-65/frontend-tests
JackTong24 Sep 24, 2024
ee772ca
fix: student conflict test
JackTong24 Sep 24, 2024
7288250
fix: reformat code
JackTong24 Sep 24, 2024
83fba30
Merge pull request #20 from hotungkhanh/kan-62/backend-tests
hotungkhanh Sep 24, 2024
55d0da8
feat: add test for sending multiple solve requests to server
dh-giang-vu Sep 25, 2024
032b94c
Merge pull request #21 from hotungkhanh/kan-65/frontend-tests
JackTong24 Sep 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 39 additions & 9 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,45 @@
<groupId>ai.timefold.solver</groupId>
<artifactId>timefold-solver-quarkus-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ai.timefold.solver</groupId>
<artifactId>timefold-solver-test</artifactId>
<version>1.13.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.26.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-panache</artifactId>
</dependency>
</dependencies>

Expand Down Expand Up @@ -91,10 +121,10 @@
</build>
<profiles>
<profile>
<id>native</id>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
<id>native</id>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
</profiles>
</project>
16 changes: 0 additions & 16 deletions backend/src/main/java/org/acme/GreetingResource.java

This file was deleted.

95 changes: 95 additions & 0 deletions backend/src/main/java/org/acme/TimetableResource.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package org.acme;

import ai.timefold.solver.core.api.solver.SolverManager;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.acme.domain.Room;
import org.acme.domain.Student;
import org.acme.domain.Timetable;
import org.acme.domain.Unit;

import java.time.DayOfWeek;
import java.time.Duration;
import java.time.LocalTime;
import java.util.List;
import java.util.concurrent.ExecutionException;

/**
* Entry to the timetabling program.
* Receives a timetabling problem and outputs the solution
* with the best optimised scores according to the provided constraints.
*
* @author Jet Edge
*/
@Path("/timetabling")
public class TimetableResource {

@Inject
SolverManager<Timetable, String> solverManager;

private int jobId = 0;

@POST
public Timetable handleRequest(Timetable problem) throws ExecutionException, InterruptedException {
jobId += 1;
String name = "Job" + Integer.toString(jobId);

Timetable solution = solverManager.solve(name, problem).getFinalBestSolution();
return solution;
}

@GET
@Produces(MediaType.APPLICATION_JSON)
public Timetable solveExample() throws ExecutionException, InterruptedException {

Student a = new Student("a");
Student b = new Student("b");
Student c = new Student("c");
Student d = new Student("d");
Student e = new Student("e");
Student f = new Student("f");
Student g = new Student("g");
Student h = new Student("h");
Student i = new Student("i");

Room r1 = new Room("Room1", 2, true);
Room r2 = new Room("Room2", 4, false);
Room r3 = new Room("Room3", 4, false);

var problem = new Timetable(
List.of(
new Unit(1, "1", Duration.ofHours(2), List.of(a, b), true),
new Unit(2, "2", Duration.ofHours(2), List.of(a, c, d, e), true),
new Unit(3, "3", Duration.ofHours(2), List.of(f, g, h, i), false),
new Unit(4, "4", Duration.ofHours(2), List.of(a, b), false)
// new Unit(5, "5", Duration.ofHours(2), List.of(c, d, e)),
// new Unit(6, "6", Duration.ofHours(2), List.of(f, g, h, i))
),

List.of(
DayOfWeek.MONDAY,
DayOfWeek.TUESDAY,
DayOfWeek.WEDNESDAY
// DayOfWeek.THURSDAY,
// DayOfWeek.FRIDAY
),

List.of(
LocalTime.of(15, 0)
// LocalTime.of(17, 0)
// LocalTime.of(16,0),
// LocalTime.of(23,0)
),
List.of(r1, r2, r3)
);

Timetable solution = solverManager.solve("job 1", problem).getFinalBestSolution();

return solution;
}

}
62 changes: 62 additions & 0 deletions backend/src/main/java/org/acme/domain/ConflictingUnit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package org.acme.domain;

/**
* Represents a pair of conflicting units, which are units with common students.
*
* @author Jet Edge
*/
public class ConflictingUnit {
private Unit unit1;

private Unit unit2;

private int numStudent;

/**
* Creates a pair of conflicting units.
*
* @param first The first unit.
* @param second The second unit.
*/
public ConflictingUnit(Unit first, Unit second) {
this.unit1 = first;
this.unit2 = second;
}

/**
* Creates a pair of conflicting units.
*
* @param first The first unit.
* @param second The second unit.
* @param numStudent The number of common students.
*/
public ConflictingUnit(Unit first, Unit second, int numStudent) {
this.unit1 = first;
this.unit2 = second;
this.numStudent = numStudent;
}

public Unit getUnit1() {
return unit1;
}

public void setUnit1(Unit unit1) {
this.unit1 = unit1;
}

public Unit getUnit2() {
return unit2;
}

public void setUnit2(Unit unit2) {
this.unit2 = unit2;
}

public int getNumStudent() {
return numStudent;
}

public void setNumStudent(int numStudent) {
this.numStudent = numStudent;
}
}
56 changes: 56 additions & 0 deletions backend/src/main/java/org/acme/domain/Room.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.acme.domain;

import ai.timefold.solver.core.api.domain.lookup.PlanningId;

/**
* Represents a room.
*
* @author Jet Edge
*/
public class Room {
@PlanningId
private String id;

private int capacity;
private boolean isLab;

public Room() {
}

/**
* Creates a room with its ID and capacity.
*
* @param id The room’s id.
* @param capacity The room's capacity.
* @param isLab Whether the room is a laboratory.
*/
public Room(String id, int capacity, boolean isLab) {
this.id = id;
this.capacity = capacity;
this.isLab = isLab;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public int getCapacity() {
return capacity;
}

public void setCapacity(int capacity) {
this.capacity = capacity;
}

public boolean isLab() {
return isLab;
}

public void setLab(boolean lab) {
isLab = lab;
}
}
48 changes: 48 additions & 0 deletions backend/src/main/java/org/acme/domain/Student.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.acme.domain;

import java.util.Objects;

/**
* Represents a student.
*
* @author Jet Edge
*/
public class Student {

// String studentID;

String name;

public Student() {
}

/**
* Creates a student with the specified name.
*
* @param name The student’s name.
*/
public Student(String name) {
this.name = name;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Student student = (Student) o;
return Objects.equals(name, student.name);
}

@Override
public int hashCode() {
return Objects.hash(name);
}
}
Loading
Loading