Skip to content

Commit

Permalink
Merge main and update ReadMe
Browse files Browse the repository at this point in the history
  • Loading branch information
DCRepublic committed Nov 21, 2024
2 parents 49ab93b + 1938e8c commit 345d589
Show file tree
Hide file tree
Showing 24 changed files with 502 additions and 339 deletions.
12 changes: 7 additions & 5 deletions Dockerfile.cron
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@ FROM golang:1.23-bookworm

RUN useradd cronuser
RUN mkdir -p /app
RUN touch /var/log/cron.log
RUN chown -R cronuser /app

WORKDIR /app

RUN apt update
RUN apt install -y cron rsyslog

COPY --chown=cronuser:cronuser ./crontab_file /etc/cron.d/cron-scraper
RUN crontab -u cronuser /etc/cron.d/cron-scraper
RUN chmod u+s /usr/sbin/cron
COPY --chown=cronuser:cronuser ./cron-startup.sh ./cron-startup.sh
COPY ./crontab_file /etc/cron.d/cron-scraper
RUN chmod 0644 /etc/cron.d/cron-scraper
COPY ./cron-startup.sh ./cron-startup.sh

USER cronuser

COPY ./swatscraper/go.mod ./swatscraper/go.sum ./
RUN go mod download

COPY --chown=cronuser:cronuser ./scraper.env ./env
COPY --chown=cronuser:cronuser ./scraper.env ./.env
COPY --chown=cronuser:cronuser ./swatscraper/*.go ./

RUN GOCACHE=/app/.cache CGO_ENABLED=0 GOOS=linux go build -o /app/swatscraper

USER root
ENTRYPOINT ["./cron-startup.sh"]
69 changes: 47 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
# Scheduler v2
<div style="align:center; text-align:center;">

## Technologies Used
<img style="display:block; margin-left:auto; margin-right:auto;" src="./public/logo/logo.png" width="300" height="300"/>

- [Next.js 14](https://nextjs.org/docs/getting-started)
- [NextUI v2](https://nextui.org/)
- [Tailwind CSS](https://tailwindcss.com/)
- [Tailwind Variants](https://tailwind-variants.org)
- [TypeScript](https://www.typescriptlang.org/)
- [Framer Motion](https://www.framer.com/motion/)
- [next-themes](https://github.com/pacocoursey/next-themes)
- [Golang](https://go.dev/)
<h1 style="text-align:center"> SCCS Course Planner</h1>

<p style="text-align:center"> The SCCS Course Planner is an all in one solution for planning your classes at Swarthmore College!</p>

![repo_last_commit]
[![License][repo_license_img]][repo_license_url]
![repo_size]
![build_status]

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

Install [Golang](https://go.dev/dl/)
## 🏁 Getting Started

Install [NodeJS](https://nodejs.org/en) v18.18 or higher
### Install

<ul>

[Golang](https://go.dev/dl/)

[NodeJS](https://nodejs.org/en) v18.18 or higher

[Docker](https://docs.docker.com/engine/install/)

</ul>

### Clone the Repo(recursivly!)

```bash
git clone --recursive https://github.com/swat-sccs/scheduler-v2.git
git checkout dev
cd scheduler-v2
```

### Configure your .env file

Paste the following into a .env in the root of the project.

```env
DATABASE_URL="postgresql://postgres:example@localhost:5432/scheduler_db"
Expand All @@ -42,30 +57,40 @@ first run only:
```bash
go mod init github.com/swatscraper
go mod tidy
```

```bash
go run main.go -semester=spring -year=2025 # Change to semester of choice

```



### View the dev site

Head on over to http://localhost:3000



### (Optional) View the database visually and in the browser!

```bash
npx prisma studio
```
Head on over to http://localhost:5555. Use this to confirm your database is populated.

Head on over to http://localhost:5555. Use this to confirm your database is populated.

### 📡 Technologies in Use

- [Next.js 14](https://nextjs.org/docs/getting-started)
- [NextUI v2](https://nextui.org/)
- [Tailwind CSS](https://tailwindcss.com/)
- [Tailwind Variants](https://tailwind-variants.org)
- [TypeScript](https://www.typescriptlang.org/)
- [Framer Motion](https://www.framer.com/motion/)
- [next-themes](https://github.com/pacocoursey/next-themes)
- [Golang](https://go.dev/)

## License

Licensed under the [MIT license](https://github.com/swat-sccs/scheduler-v2/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
96 changes: 94 additions & 2 deletions app/actions/getCourses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,99 @@ export async function setPlanCookie(plan: string) {
(await cookies()).set("plan", plan);
}

export async function getInitialCourses() {
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: 10,
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: {
sectionAttributes: true,
Expand All @@ -37,6 +126,9 @@ export async function getCourses(
return await prisma.course.findMany({
relationLoadStrategy: "join", // or 'query'
take: take,
cursor: {
id: 1,
},

include: {
sectionAttributes: true,
Expand Down
Loading

0 comments on commit 345d589

Please sign in to comment.