Skip to content

Commit 559799d

Browse files
committed
classrooms: misc changes for updating wi22/sp22 room data
1 parent e5e7849 commit 559799d

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

scripts/deploy.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ if [ -z "$2" ]; then
3737
done
3838

3939
URL="https://sheeptester.github.io/uxdy/"
40+
TAG="uxdy"
4041
else
4142
# Check out existing files in gh-pages
4243
git checkout origin/gh-pages
@@ -47,12 +48,13 @@ else
4748
cp -ar ../../$1/. $2
4849

4950
URL="https://sheeptester.github.io/uxdy/$2/"
51+
TAG="$2"
5052
fi
5153

5254
# Commit everything and push
5355
git checkout -b gh-pages
5456
git add .
55-
git commit -m "Building for $LAST_COMMIT
57+
git commit -m "$TAG: Deploy $LAST_COMMIT
5658
5759
$URL"
5860
git push origin gh-pages

webreg-scraping/scrape.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def get(path, query = {})
2626
end
2727

2828
begin
29-
return JSON.parse(File.read("./webreg-data/#{file_name}.json"), symbolize_names: true)
29+
return JSON.parse(File.read("./cache-wi22/#{file_name}.json"), symbolize_names: true)
3030
rescue Errno::ENOENT
3131
end
3232

@@ -35,8 +35,11 @@ def get(path, query = {})
3535
# I don't think UqZBpD3n needs to be a secret but whatever
3636
"Cookie" => "jlinksessionidx=#{@session_index}; UqZBpD3n=#{@uqz}",
3737
}).read, symbolize_names: true)
38+
if json.length > 0 && json[0][:VERIFY] == "FAIL"
39+
raise "[0].VERIFY: FAIL #{file_name}"
40+
end
3841
# File.write: https://stackoverflow.com/a/19337403
39-
File.write("./webreg-data/#{file_name}.json", JSON.pretty_generate(json))
42+
File.write("./cache-wi22/#{file_name}.json", JSON.pretty_generate(json))
4043
puts "Fetched #{file_name}"
4144
json
4245
end

webreg-scraping/scrape.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ export class Scraper {
132132
? response.json()
133133
: Promise.reject(`HTTP ${response.status} error from ${response.url}`)
134134
)
135+
if (json?.[0]?.VERIFY === 'FAIL') {
136+
throw new Error(
137+
'WebReg returned VERIFY: FAIL. Was the quarter selected on WebReg?'
138+
)
139+
}
135140
if (this.#cachePath !== null) {
136141
await Deno.writeTextFile(
137142
joinPath(this.#cachePath, `${fileName}.json`),
@@ -678,10 +683,10 @@ export class ScheduleSection extends BaseGroup<RawGetClassResult> {
678683
}
679684

680685
if (import.meta.main) {
681-
const getter = new Scraper('WI22', {
686+
const getter = new Scraper('SP22', {
682687
jlinksessionidx: Deno.args[1],
683688
UqZBpD3n: Deno.args[0],
684-
cachePath: 'cache-wi22'
689+
cachePath: 'cache-sp22'
685690
})
686691
const courses = []
687692
const freq: Record<number, number> = {}

0 commit comments

Comments
 (0)