From 71d323030890802e1f82b07fd16462b9e3984749 Mon Sep 17 00:00:00 2001
From: Damian Rene <37555910+DCRepublic@users.noreply.github.com>
Date: Mon, 18 Nov 2024 11:54:13 -0500
Subject: [PATCH 1/6] Update main.yml
---
.github/workflows/main.yml | 2 --
1 file changed, 2 deletions(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index d939c47..53515c3 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -5,8 +5,6 @@ name: Mirror
on:
push:
branches: [ "main" ]
- pull_request:
- branches: [ "main" ]
jobs:
build:
From 0815e74f99430a14d108f022452c2e6e22653676 Mon Sep 17 00:00:00 2001
From: Damian <37555910+DCRepublic@users.noreply.github.com>
Date: Mon, 18 Nov 2024 12:02:03 -0500
Subject: [PATCH 2/6] Fix swat scraper
---
swatscraper | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/swatscraper b/swatscraper
index c6e481f..b82ba90 160000
--- a/swatscraper
+++ b/swatscraper
@@ -1 +1 @@
-Subproject commit c6e481fd4c8d163e6878c1b428be9726f685653a
+Subproject commit b82ba903ed4eba8f7d50f50f2237acafae72b12c
From 49ab93bbff51a0dba056645a44ca847fd70dd18f Mon Sep 17 00:00:00 2001
From: Damian <37555910+DCRepublic@users.noreply.github.com>
Date: Mon, 18 Nov 2024 12:04:13 -0500
Subject: [PATCH 3/6] update scraper
---
swatscraper | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/swatscraper b/swatscraper
index b82ba90..b3a2157 160000
--- a/swatscraper
+++ b/swatscraper
@@ -1 +1 @@
-Subproject commit b82ba903ed4eba8f7d50f50f2237acafae72b12c
+Subproject commit b3a2157105945977bd67c3ad3e81bc4992b85a8b
From c86dc931df33b99f5dc6ce5dba2dfbd6037c0c0c Mon Sep 17 00:00:00 2001
From: Damian Rene <37555910+DCRepublic@users.noreply.github.com>
Date: Thu, 21 Nov 2024 13:29:24 -0500
Subject: [PATCH 4/6] Update README.md
---
README.md | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index a265aed..11bb9b5 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
-
+
-
+
SCCS Course Planner
@@ -28,7 +28,7 @@
-### Clone the Repo(recursivly!)
+### Clone the Repo
```bash
git clone --recursive https://github.com/swat-sccs/scheduler-v2.git
@@ -40,9 +40,17 @@
Paste the following into a .env in the root of the project.
-```env
-DATABASE_URL="postgresql://postgres:example@localhost:5432/scheduler_db"
+```bash
+echo 'DATABASE_URL="postgresql://postgres:example@localhost:5432/scheduler_db"' > .env
+```
+Pase the following into a .env in the /swatscraper dir
+```bash
+ echo 'HOST=localhost
+ SQL_USER=postgres
+ PASS=example
+ DBNAME=scheduler_db
+ OPMODE="DEV"' > ./swatscraper/.env
```
### Run the development server
@@ -60,7 +68,7 @@ go mod tidy
go run main.go -semester=spring -year=2025 # Change to semester of choice
```
-### View the dev site
+## View the dev site
Head on over to http://localhost:3000
@@ -72,7 +80,7 @@ npx prisma studio
Head on over to http://localhost:5555. Use this to confirm your database is populated.
-### 📡 Technologies in Use
+## 📡 Technologies in Use
- [Next.js 14](https://nextjs.org/docs/getting-started)
- [NextUI v2](https://nextui.org/)
From 3c1ed12b0e42f3824fa9a3f205bcd18dc38f0d54 Mon Sep 17 00:00:00 2001
From: Damian Rene <37555910+DCRepublic@users.noreply.github.com>
Date: Thu, 21 Nov 2024 15:53:19 -0500
Subject: [PATCH 5/6] Create CONTRIBUTING.md
---
CONTRIBUTING.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100644 CONTRIBUTING.md
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..d22ebbd
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,49 @@
+# Contributing
+
+Thanks for considering contributing to Scheduler-V2!
+
+## Opening issues
+
+If you find a bug, please feel free to [open an issue](https://github.com/swat-sccs/scheduler-v2/issues).
+
+If you taking the time to mention a problem, even a seemingly minor one, it is greatly appreciated, and a totally valid contribution to this project. Thank you!
+
+## Fixing bugs
+
+We love pull requests. Here’s a quick guide:
+
+1. [Fork this repository](https://github.com/swat-sccs/scheduler-v2/fork) and then clone it locally:
+
+ ```bash
+ git clone --recursive https://github.com/swat-sccs/scheduler-v2.git
+ ```
+
+2. Create a topic branch for your changes:
+
+ ```bash
+ git checkout -b fix-for-that-thing
+ ```
+3. Commit a failing test for the bug:
+
+ ```bash
+ git commit -am "Adds a failing test to demonstrate that thing"
+ ```
+
+4. Commit a fix that makes the test pass:
+
+ ```bash
+ git commit -am "Adds a fix for that thing!"
+ ```
+
+6. If everything looks good, push to your fork:
+
+ ```bash
+ git push origin fix-for-that-thing
+ ```
+
+7. [Submit a pull request.](https://github.com/swat-sccs/scheduler-v2/pulls)
+
+
+## Adding new features
+
+Thinking of adding a new feature? Awesome! [open an issue](https://github.com/swat-sccs/scheduler-v2/issues). and let’s work on it together!
From 79328b4ccc7811c4e0ebc1e1556b4f678e1efdff Mon Sep 17 00:00:00 2001
From: Damian <37555910+DCRepublic@users.noreply.github.com>
Date: Sun, 24 Nov 2024 18:29:35 -0500
Subject: [PATCH 6/6] Change branding to Planner/Plan
---
.github/workflows/main.yml | 24 ++--
.gitlab-ci.yml | 4 +-
README.md | 23 ++--
app/actions/getCourses.ts | 206 +++++++++++++++++-------------
app/page.tsx | 74 ++---------
components/FullCourseList.tsx | 2 +-
components/OLD.FullCourseList.tsx | 149 ---------------------
components/PlanContext.tsx | 24 ++++
components/Search.tsx | 3 +-
components/primitives.ts | 4 +-
docker-compose.debug.yml | 11 +-
docker-compose.yml | 40 +++---
package-lock.json | 4 +-
package.json | 2 +-
14 files changed, 215 insertions(+), 355 deletions(-)
delete mode 100644 components/OLD.FullCourseList.tsx
create mode 100644 components/PlanContext.tsx
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 53515c3..ba402c2 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -4,21 +4,21 @@ name: Mirror
on:
push:
- branches: [ "main" ]
+ branches: ["main"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
- with:
- fetch-depth: 0
- - uses: action-pack/gitlab-sync@v3
- with:
- # GitLab repo URL
- url: https://gitlab.sccs.swarthmore.edu/sccs/scheduler.git
- # GitLab username
- username: mirrorbot
- # GitLab token
- token: ${{ secrets.GITLAB_TOKEN }}
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ - uses: action-pack/gitlab-sync@v3
+ with:
+ # GitLab repo URL
+ url: https://gitlab.sccs.swarthmore.edu/sccs/planner.git
+ # GitLab username
+ username: mirrorbot
+ # GitLab token
+ token: ${{ secrets.GITLAB_TOKEN }}
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cc6cd89..1c314ca 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -21,11 +21,11 @@ build:
stage: build
script:
- docker compose -f docker-compose.yml build
- - docker push $SCCS_REGISTRY/sccs/scheduler/scheduler:latest
+ - docker push $SCCS_REGISTRY/sccs/planner/planner:latest
deploy_docker_stage:
stage: deploy
variables:
DOCKER_HOST: "tcp://130.58.218.21:2376"
script:
- - docker stack deploy --with-registry-auth -c ./docker-compose.yml scheduler
+ - docker stack deploy --with-registry-auth -c ./docker-compose.yml planner
diff --git a/README.md b/README.md
index 11bb9b5..c7c538d 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@
![repo_size]
![build_status]
-
Looking to plan your classes? Visit the live site!
+
Looking to plan your classes? Visit the live site!
## 🏁 Getting Started
@@ -31,9 +31,9 @@
### Clone the Repo
```bash
- git clone --recursive https://github.com/swat-sccs/scheduler-v2.git
+ git clone --recursive https://github.com/swat-sccs/planner.git
git checkout dev
- cd scheduler-v2
+ cd planner
```
### Configure your .env file
@@ -41,15 +41,16 @@
Paste the following into a .env in the root of the project.
```bash
-echo 'DATABASE_URL="postgresql://postgres:example@localhost:5432/scheduler_db"' > .env
+echo 'DATABASE_URL="postgresql://postgres:example@localhost:5432/planner_db"' > .env
```
Pase the following into a .env in the /swatscraper dir
+
```bash
- echo 'HOST=localhost
+ echo 'HOST=localhost
SQL_USER=postgres
PASS=example
- DBNAME=scheduler_db
+ DBNAME=planner_db
OPMODE="DEV"' > ./swatscraper/.env
```
@@ -93,12 +94,12 @@ Head on over to http://localhost:5555. Use this to confirm your database is popu
## License
-Licensed under the [MIT license](https://github.com/swat-sccs/scheduler-v2/blob/main/LICENSE).
+Licensed under the [MIT license](https://github.com/swat-sccs/planner/blob/main/LICENSE).
[repo_license_img]: https://img.shields.io/badge/license-Mit-red?style=for-the-badge&logo=none
-[repo_license_url]: https://github.com/swat-sccs/scheduler-v2?tab=MIT-1-ov-file#readme
-[repo_last_commit]: https://img.shields.io/github/last-commit/swat-sccs/scheduler-v2?style=for-the-badge&link=https%3A%2F%2Fgithub.com%2Fswat-sccs%2Fscheduler-v2&color=%2343AA8B
-[build_status]: https://img.shields.io/github/check-runs/swat-sccs/scheduler-v2/main?style=for-the-badge&label=Build&color=%2343AA8B
-[repo_size]: https://img.shields.io/github/repo-size/swat-sccs/scheduler-v2?style=for-the-badge
+[repo_license_url]: https://github.com/swat-sccs/planner?tab=MIT-1-ov-file#readme
+[repo_last_commit]: https://img.shields.io/github/last-commit/swat-sccs/planner?style=for-the-badge&link=https%3A%2F%2Fgithub.com%2Fswat-sccs%2Fplanner&color=%2343AA8B
+[build_status]: https://img.shields.io/github/check-runs/swat-sccs/planner/main?style=for-the-badge&label=Build&color=%2343AA8B
+[repo_size]: https://img.shields.io/github/repo-size/swat-sccs/planner?style=for-the-badge
diff --git a/app/actions/getCourses.ts b/app/actions/getCourses.ts
index 2bf561e..929d838 100644
--- a/app/actions/getCourses.ts
+++ b/app/actions/getCourses.ts
@@ -3,11 +3,114 @@
import { cookies } from "next/headers";
import prisma from "../../lib/prisma";
import { Prisma } from "@prisma/client";
+import { auth } from "@/lib/auth";
+import { getPlanCookie } from "./actions";
+
+export async function getUniqueCodes() {
+ const codes = await prisma.sectionAttribute.findMany();
+ const daCodes: any = [];
+
+ for (let i = 0; i < codes.length; i++) {
+ if (!daCodes.includes(codes[i].code)) {
+ daCodes.push(codes[i].code);
+ }
+ }
+
+ return daCodes;
+}
+
+export async function getUniqueStartEndTimes() {
+ const meetingTimes = await prisma.meetingTime.findMany({
+ where: {
+ beginTime: { not: "" },
+ },
+ orderBy: {
+ beginTime: "asc",
+ },
+ });
+ const startTimes: any = [];
+ const endTimes: any = [];
+
+ for (let i = 0; i < meetingTimes.length; i++) {
+ if (!startTimes.includes(meetingTimes[i].beginTime)) {
+ startTimes.push(meetingTimes[i].beginTime);
+ }
+ if (!endTimes.includes(meetingTimes[i].endTime)) {
+ endTimes.push(meetingTimes[i].endTime);
+ }
+ }
+
+ const times = { startTimes: startTimes, endTimes: endTimes };
+
+ return times;
+}
+
+export async function getTerms() {
+ const courses = await prisma.course.findMany();
+ const output: any = [];
+
+ for (let i = 0; i < courses.length; i++) {
+ if (!output.includes(courses[i].year)) {
+ output.push(courses[i].year);
+ }
+ }
+
+ return output;
+}
+
export async function setPlanCookie(plan: string) {
//@ts-ignore
(await cookies()).set("plan", plan);
}
+export async function getPlanCourses1() {
+ const planCookie: any = await getPlanCookie();
+ const session = await auth();
+
+ return await prisma.coursePlan.findMany({
+ where: {
+ AND: {
+ User: {
+ uuid: session?.user.id,
+ },
+ //id: parseInt(planCookie),
+ },
+ },
+ include: {
+ courses: true,
+ },
+ });
+}
+
+export async function getPlanCourses(planID: any) {
+ //let DOTW: Array
= dotw.split(",");
+
+ return await prisma.course.findMany({
+ relationLoadStrategy: "join", // or 'query'
+ where: {
+ CoursePlan: {
+ some: {
+ id: parseInt(planID),
+ },
+ },
+ },
+ include: {
+ CoursePlan: true,
+ },
+ });
+}
+
+export async function getInitialCoursePlans() {
+ //let DOTW: Array = dotw.split(",");
+
+ return await prisma.coursePlan.findMany({
+ relationLoadStrategy: "join", // or 'query'
+ include: {
+ courses: true,
+ },
+ });
+}
+
export async function getInitialCourses(
query: any,
term: any,
@@ -15,91 +118,15 @@ export async function getInitialCourses(
stime: any
) {
const startTime = stime.toString().split(",").filter(Number);
-
return await prisma.course.findMany({
relationLoadStrategy: "join", // or 'query'
take: 20,
-
where: {
...(term
? {
year: term,
}
: {}),
- //year: term,
-
- ...(query
- ? {
- OR: [
- {
- courseTitle: {
- search: query.trim().split(" ").join(" | "),
- mode: "insensitive",
- },
- },
- {
- sectionAttributes: {
- some: {
- code: {
- search: query.trim().split(" ").join(" | "),
- mode: "insensitive",
- },
- },
- },
- },
- {
- subject: {
- search: query.trim().split(" ").join(" | "),
- mode: "insensitive",
- },
- },
- {
- courseNumber: {
- search: query.trim().split(" ").join(" | "),
- mode: "insensitive",
- },
- },
- {
- instructor: {
- displayName: {
- search: query.trim().split(" ").join(" | "),
- mode: "insensitive",
- },
- },
- },
- ],
- }
- : {}),
-
- ...(startTime.length > 0
- ? {
- facultyMeet: {
- meetingTimes: {
- beginTime: {
- in: startTime,
- },
- },
- },
- }
- : {}),
-
- ...(dotw.length > 0
- ? {
- facultyMeet: {
- meetingTimes: {
- is: {
- monday: dotw.includes("monday") ? true : Prisma.skip,
- tuesday: dotw.includes("tuesday") ? true : Prisma.skip,
- wednesday: dotw.includes("wednesday") ? true : Prisma.skip,
- thursday: dotw.includes("thursday") ? true : Prisma.skip,
- friday: dotw.includes("friday") ? true : Prisma.skip,
- saturday: dotw.includes("saturday") ? true : Prisma.skip,
- sunday: dotw.includes("sunday") ? true : Prisma.skip,
- },
- },
- },
- }
- : {}),
},
include: {
@@ -116,19 +143,16 @@ export async function getInitialCourses(
export async function getCourses(
take: any,
- cursor: any,
query: any,
term: any,
dotw: any,
stime: any
) {
const startTime = stime.toString().split(",").filter(Number);
+
return await prisma.course.findMany({
relationLoadStrategy: "join", // or 'query'
take: take,
- cursor: {
- id: 1,
- },
include: {
sectionAttributes: true,
@@ -140,15 +164,19 @@ export async function getCourses(
instructor: true,
},
- orderBy: [
- {
- _relevance: {
- fields: ["courseTitle", "subject", "courseNumber"],
- search: query.trim().split(" ").join(" & "),
- sort: "desc",
- },
- },
- ],
+ ...(query
+ ? {
+ orderBy: [
+ {
+ _relevance: {
+ fields: ["courseTitle", "subject", "courseNumber"],
+ search: query.trim().split(" ").join(" & "),
+ sort: "desc",
+ },
+ },
+ ],
+ }
+ : ""),
where: {
...(term
? {
diff --git a/app/page.tsx b/app/page.tsx
index f120379..0bccd38 100644
--- a/app/page.tsx
+++ b/app/page.tsx
@@ -6,61 +6,15 @@ import { cookies } from "next/headers";
import Search from "../components/Search";
import { FullCourseList } from "../components/FullCourseList";
import CreatePlan from "../components/CreatePlan";
-import prisma from "../lib/prisma";
-import { getInitialCourses } from "../app/actions/getCourses";
+import {
+ getInitialCourses,
+ getPlanCourses1,
+ getTerms,
+ getUniqueStartEndTimes,
+ getUniqueCodes,
+} from "../app/actions/getCourses";
import { redirect } from "next/navigation";
-
-async function getCourses() {
- const courses = await prisma.course.findMany();
- const output: any = [];
-
- for (let i = 0; i < courses.length; i++) {
- if (!output.includes(courses[i].year)) {
- output.push(courses[i].year);
- }
- }
-
- return output;
-}
-
-async function getUniqueStartEndTimes() {
- const meetingTimes = await prisma.meetingTime.findMany({
- where: {
- beginTime: { not: "" },
- },
- orderBy: {
- beginTime: "asc",
- },
- });
- const startTimes: any = [];
- const endTimes: any = [];
-
- for (let i = 0; i < meetingTimes.length; i++) {
- if (!startTimes.includes(meetingTimes[i].beginTime)) {
- startTimes.push(meetingTimes[i].beginTime);
- }
- if (!endTimes.includes(meetingTimes[i].endTime)) {
- endTimes.push(meetingTimes[i].endTime);
- }
- }
-
- const times = { startTimes: startTimes, endTimes: endTimes };
-
- return times;
-}
-
-async function getUniquCodes() {
- const codes = await prisma.sectionAttribute.findMany();
- const daCodes: any = [];
-
- for (let i = 0; i < codes.length; i++) {
- if (!daCodes.includes(codes[i].code)) {
- daCodes.push(codes[i].code);
- }
- }
-
- return daCodes;
-}
+import { CoursePlan } from "@prisma/client";
export default async function Page(props: {
searchParams?: Promise<{
@@ -72,10 +26,9 @@ export default async function Page(props: {
}>;
}) {
const cookieStore = await cookies();
+ const planID = await cookieStore.get("plan");
const pagePref = cookieStore.get("pagePref");
if (pagePref && pagePref.value != "plan") {
- console.log("wtf");
- console.log(pagePref.value);
redirect("/" + pagePref.value);
}
@@ -86,6 +39,7 @@ export default async function Page(props: {
const stime = searchParams?.stime || [];
const homePageProps: any = {};
const initalCourses = await getInitialCourses(query, term, dotw, stime);
+ const planCourses: CoursePlan[] = await getPlanCourses1();
homePageProps["fullCourseList"] = (
}
>
-
+
);
return ; // return with no events
}
async function Home(props: any) {
- const terms = await getCourses();
+ const terms = await getTerms();
const uniqueTimes = await getUniqueStartEndTimes();
- const codes = await getUniquCodes();
+ const codes = await getUniqueCodes();
return (
<>
@@ -136,7 +90,7 @@ async function Home(props: any) {