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

#520 automate course updates across semesters #534

Closed
wants to merge 64 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
bf42deb
First draft
jaw12346 Feb 11, 2022
537c695
Fixed minor syntax and style issues
jaw12346 Feb 11, 2022
528eca5
Fixed typo
jaw12346 Feb 15, 2022
c03a5bd
Fix if statements
jaw12346 Feb 15, 2022
68540b8
Fix if statements
jaw12346 Feb 15, 2022
915c056
Fixed error #1
pyalla26 Feb 15, 2022
8ae857c
Revert "Fixed error #1"
jaw12346 Feb 15, 2022
d776a3a
Revert "Revert "Fixed error #1""
jaw12346 Feb 15, 2022
00efd69
Repaired automate-semesters.sh by creating a 404-catching Python script
jaw12346 Feb 18, 2022
588619c
Removed print output
jaw12346 Feb 18, 2022
063153f
Try to fix codefactor error
jaw12346 Feb 18, 2022
e971fd5
Replaced $? variable with exitCode
jaw12346 Feb 18, 2022
c19da6f
Create cronjob
pyalla26 Feb 18, 2022
2b785d8
Update ci.yaml
pyalla26 Feb 18, 2022
0857609
Merge branch '#520-Automate-course-updates-across-semesters' of https…
pyalla26 Feb 18, 2022
adaca28
Changed logic to prevent double fetching on boundary-months
jaw12346 Feb 24, 2022
98b08e1
I made the DockerFile and Image
pyalla26 Feb 25, 2022
e6e7fb6
Merge branch '#520-Automate-course-updates-across-semesters' of https…
pyalla26 Feb 25, 2022
d3db2a4
Created instructions to run cronjob
pyalla26 Feb 25, 2022
fe9aca6
Fixed Dockerfile with correct syntax.
pyalla26 Feb 25, 2022
c9cb714
Updated Dockerfile
pyalla26 Feb 25, 2022
074c32b
Update cronjob
pyalla26 Mar 1, 2022
69ba064
major cleanup! Also,`regex.compile` throws error
RichtXO Mar 5, 2022
7098d19
now works!
RichtXO Mar 5, 2022
eb1545b
Curl updated csv to endpoint, API doesn't work?
RichtXO Mar 5, 2022
2b9bc9e
fixed API container
RichtXO Mar 5, 2022
2ff78f0
curl now works, but "No file received"???
RichtXO Mar 21, 2022
9cfa0a8
First draft
jaw12346 Feb 11, 2022
61ce206
Fixed minor syntax and style issues
jaw12346 Feb 11, 2022
e316dec
Fixed typo
jaw12346 Feb 15, 2022
f9ffef2
Fix if statements
jaw12346 Feb 15, 2022
71b1fce
Fix if statements
jaw12346 Feb 15, 2022
bb54287
Fixed error #1
pyalla26 Feb 15, 2022
ab25663
Revert "Fixed error #1"
jaw12346 Feb 15, 2022
11ef6c9
Revert "Revert "Fixed error #1""
jaw12346 Feb 15, 2022
3a06bc1
Repaired automate-semesters.sh by creating a 404-catching Python script
jaw12346 Feb 18, 2022
a226004
Removed print output
jaw12346 Feb 18, 2022
75d7375
Try to fix codefactor error
jaw12346 Feb 18, 2022
9e783b6
Create cronjob
pyalla26 Feb 18, 2022
c733cde
Update ci.yaml
pyalla26 Feb 18, 2022
b2baa46
Replaced $? variable with exitCode
jaw12346 Feb 18, 2022
1c102f1
I made the DockerFile and Image
pyalla26 Feb 25, 2022
2d09afe
Changed logic to prevent double fetching on boundary-months
jaw12346 Feb 24, 2022
970f92c
Created instructions to run cronjob
pyalla26 Feb 25, 2022
5e28f28
Fixed Dockerfile with correct syntax.
pyalla26 Feb 25, 2022
43bdab0
Updated Dockerfile
pyalla26 Feb 25, 2022
192fdbb
Update cronjob
pyalla26 Mar 1, 2022
4f37cf3
major cleanup! Also,`regex.compile` throws error
RichtXO Mar 5, 2022
0ab839e
now works!
RichtXO Mar 5, 2022
6b5520b
Curl updated csv to endpoint, API doesn't work?
RichtXO Mar 5, 2022
a859e84
fixed API container
RichtXO Mar 5, 2022
c6afdf0
curl now works, but "No file received"???
RichtXO Mar 21, 2022
e6df87b
Merge branch '#520-Automate-course-updates-across-semesters' of https…
RichtXO May 12, 2022
1a92916
Revert "beep boop Github Action Master Branch CI Prettier hard at work"
RichtXO May 12, 2022
5bf633b
Merge remote-tracking branch 'origin/master' into #520-Automate-cours…
RichtXO May 12, 2022
0f15fe5
missing python mods... hate git
RichtXO May 12, 2022
80ce822
changed curl flags
RichtXO May 12, 2022
a118067
updated for testing
RichtXO May 12, 2022
5f2f655
syntax error
RichtXO May 12, 2022
af9e18d
script now works and cronjob :)
RichtXO May 12, 2022
e9cdf4d
changing perms on script
RichtXO May 12, 2022
a839756
syntax error :/
RichtXO May 12, 2022
da56b55
removing uncessary line
RichtXO May 12, 2022
42ef2b4
done :)
RichtXO May 12, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:

- name: run Lighthouse CI
run: |
npm install -g @lhci/cli@0.7.x &&
npm install -g @lhci/cli &&
lhci autorun
env:
LHCI_GITHUB_APP_TOKEN: ${{secrets.LHCI_GITHUB_APP_TOKEN}}
46 changes: 0 additions & 46 deletions .github/workflows/prod-update.yaml

This file was deleted.

15 changes: 14 additions & 1 deletion docker-compose.production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version: "3.4"
# web -> api -> db [dependency chain]

services:

yacs_web:
ports:
- 80:8080
Expand Down Expand Up @@ -37,7 +38,7 @@ services:
- PROXY_CACHE_VALID=200=1s
# ===== HTTPS config =====
- AUTO_LETS_ENCRYPT=${AUTO_LE:-no}
- GENERATE_SELF_SIGNED_SSL=${SELF_CERT:-no}
- GENERATE_SELF_SIGNED_SSL=${SELF_CERT:-yes}
- REDIRECT_HTTP_TO_HTTPS=yes
# ===== ModSecurity =====
- USE_MODSECURITY=no
Expand Down Expand Up @@ -75,3 +76,15 @@ services:
- POSTGRES_DB=yacs
- POSTGRES_USER=yacs
- POSTGRES_PASSWORD=${DB_PASS:-easy_dev_pass}


yacs_updater:
restart: unless-stopped
container_name: yacs_updater
stdin_open: true
tty: true
build:
context: ./rpi_data
dockerfile: Dockerfile
depends_on:
- yacs_web
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions rpi_data/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.8.12-slim-bullseye

RUN mkdir -p /usr/src
WORKDIR /usr/src
COPY modules ./modules/
COPY requirements.txt ./
COPY school-department-mapping.yaml ./
COPY automate-semesters.sh ./
COPY website_checker.py ./

RUN apt update && apt install cron curl -y && \
pip install --no-cache-dir -r requirements.txt && \
chmod 0744 automate-semesters.sh && \
crontab -l | { cat; echo "0 * * * * /usr/src/automate-semesters.sh"; } | crontab -

CMD ["cron", "-f"]
96 changes: 96 additions & 0 deletions rpi_data/automate-semesters.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/usr/bin/env bash

post() {
test=${TESTING:-0}

if [ ${test} == 0 ]
then
curl -X POST -H "Content-Type: multipart/form-data" -F "isPubliclyVisible=on" -F "file=@${1}" \
-A "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0" -k $API_ENDPOINT
else
curl --insecure -X POST -H "Content-Type: multipart/form-data" -F "isPubliclyVisible=on" -F "file=@${1}" \
-A "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0" -k $API_ENDPOINT
fi
}

spring() {
local year=${1}
source_url=https://sis.rpi.edu/reg/zfs${year}01.htm

python3 ./website_checker.py ${source_url}
exitCode=$?
if [ ${exitCode} == 0 ]
then
export SEMESTER="SPRING ${year}"
SOURCE_URL=${source_url} DEST=p0.csv HEADERS=True python3 ./modules/rpi-parse.py
cat p* > spring-${year}.csv
rm -rf p*.csv
post spring-${year}.csv
else
echo "The requested Spring SIS page returned error 404." >&2
fi
}

summer() {
local year=${1}
source_url_a=https://sis.rpi.edu/reg/zfs${year}05.htm
source_url_b=https://sis.rpi.edu/reg/zfs${year}0502.htm
source_url_c=https://sis.rpi.edu/reg/zfs${year}0503.htm

python3 ./website_checker.py ${source_url_a} ${source_url_b} ${source_url}
exitCode=$?
if [ ${exitCode} == 0 ]
then
export SEMESTER="SUMMER ${year}"
SOURCE_URL=${source_url_a} HEADERS=True DEST=p0.csv python3 ./modules/rpi-parse.py
SOURCE_URL=${source_url_b} HEADERS=False DEST=p1.csv python3 ./modules/rpi-parse.py
SOURCE_URL=${source_url_c} HEADERS=False DEST=p2.csv python3 ./modules/rpi-parse.py
cat p* > summer-${year}.csv
rm -rf p*.csv
post summer-${year}.csv
else
echo "A requested Summer SIS page returned error 404." >&2
fi
}

fall() {
local year=${1}
source_url=https://sis.rpi.edu/reg/zfs${year}09.htm

python3 ./website_checker.py ${source_url}
exitCode=$?
if [ ${exitCode} == 0 ]
then
export SEMESTER="FALL ${year}"
SOURCE_URL=${source_url} DEST=p0.csv HEADERS=True python3 ./modules/rpi-parse.py
cat p* > fall-${year}.csv
rm -rf p*.csv
post fall-${year}.csv
else
echo "A requested Fall SIS page returned error 404." >&2
fi
}


MONTH=$(date +%m)
YEAR=$(date +%Y)
API_ENDPOINT=https://yacs_web:8443/api/bulkCourseUpload
if [[ ${MONTH} -ge 1 && ${MONTH} -lt 5 ]]
then
spring ${YEAR}
summer ${YEAR}
fi

if [[ ${MONTH} -ge 5 && ${MONTH} -lt 9 ]]
then
summer ${YEAR}
fall ${YEAR}
fi

if [[ ${MONTH} -ge 9 && ${MONTH} -le 12 ]]
then
fall ${YEAR}
spring ${YEAR}
fi

rm *.csv
5 changes: 0 additions & 5 deletions rpi_data/get-fall-2020.sh

This file was deleted.

5 changes: 0 additions & 5 deletions rpi_data/get-fall-2021.sh

This file was deleted.

5 changes: 0 additions & 5 deletions rpi_data/get-fall-2022.sh

This file was deleted.

5 changes: 0 additions & 5 deletions rpi_data/get-spring-2020.sh

This file was deleted.

5 changes: 0 additions & 5 deletions rpi_data/get-spring-2021.sh

This file was deleted.

5 changes: 0 additions & 5 deletions rpi_data/get-spring-2022.sh

This file was deleted.

7 changes: 0 additions & 7 deletions rpi_data/get-summer-2020.sh

This file was deleted.

7 changes: 0 additions & 7 deletions rpi_data/get-summer-2021.sh

This file was deleted.

7 changes: 0 additions & 7 deletions rpi_data/get-summer-2022.sh

This file was deleted.

1 change: 0 additions & 1 deletion rpi_data/modules/rpi-parse.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python
# coding: utf-8
# %%
import json
import pandas as pd
import os
from fetch_catalog_course_info import acalog_client as AcalogClient
Expand Down
File renamed without changes.
20 changes: 20 additions & 0 deletions rpi_data/website_checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import requests
import sys

"""Script to determine if a website returns a 404 error."""


def main():

for url in range(1, len(sys.argv)):
URL = sys.argv[url]
response = requests.get(URL)
if response.status_code == 404:
print(URL)
exit(1)
exit(0)


if __name__ == "__main__":
main()

2 changes: 1 addition & 1 deletion src/api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ pytest==6.2.5
uvicorn==0.14.0
python-multipart==0.0.5
fastapi-cache2==0.1.8
itsdangerous==2.0.1
itsdangerous==2.0.1
36 changes: 14 additions & 22 deletions src/web/src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@
YACS
</b-navbar-brand>
<div>
<b-dropdown
variant="outline-primary"
size="sm"
:text="selectedSemester"
class="m-md-2"
>
<b-dropdown-item
v-for="option in semesterOptions"
:key="option.value"
:value="option.value"
@click="selectSemester(option.value)"
>
{{ option.value }}
<b-dropdown variant="outline-primary"
size = "sm"
:text= selectedSemester
class= "m-md-2">
<b-dropdown-item v-for="option in semesterOptions"
:key="option.value"
:value="option.value"
@click="selectSemester(option.value)">

{{option.value}}
</b-dropdown-item>
</b-dropdown>
</div>
Expand Down Expand Up @@ -95,13 +92,8 @@
</template>

<script>
import {
SELECT_SEMESTER,
COOKIE_DARK_MODE,
TOGGLE_DARK_MODE,
SAVE_DARK_MODE,
RESET_DARK_MODE,
} from "@/store";
import { SELECT_SEMESTER, COOKIE_DARK_MODE, TOGGLE_DARK_MODE, SAVE_DARK_MODE,
RESET_DARK_MODE } from "@/store";
import { mapState, mapActions, mapGetters } from "vuex";
import LoginComponent from "@/components/Login";
import { userTypes } from "../store/modules/user";
Expand Down Expand Up @@ -177,14 +169,14 @@ export default {
}),
...mapState({ sessionId: userTypes.state.SESSION_ID }),
...mapState(["semesters", "selectedSemester"]),

semesterOptions() {
return this.semesters.map(({ semester }) => ({
text: semester,
value: semester,
}));
},
},
}
};
</script>

Expand Down