Skip to content

Commit

Permalink
Change branding to Planner/Plan
Browse files Browse the repository at this point in the history
  • Loading branch information
DCRepublic committed Nov 24, 2024
1 parent 3c1ed12 commit 79328b4
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 355 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
![repo_size]
![build_status]

<p>Looking to plan your classes? <a href="https://schedulerv2.sccs.swarthmore.edu/">Visit the live site!</a></p>
<p>Looking to plan your classes? <a href="https://planner.sccs.swarthmore.edu/">Visit the live site!</a></p>
</div>

## 🏁 Getting Started
Expand All @@ -31,25 +31,26 @@
### 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

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
```

Expand Down Expand Up @@ -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).

<!---vars-->

[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
206 changes: 117 additions & 89 deletions app/actions/getCourses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,103 +3,130 @@
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<String> = 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<String> = dotw.split(",");

return await prisma.coursePlan.findMany({
relationLoadStrategy: "join", // or 'query'
include: {
courses: true,
},
});
}

export async function getInitialCourses(
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: 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: {
Expand All @@ -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,
Expand All @@ -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
? {
Expand Down
Loading

0 comments on commit 79328b4

Please sign in to comment.