Skip to content

Commit

Permalink
Merge branch 'main' into chore/data-update
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm authored May 7, 2024
2 parents ddabe7f + 61d9aa6 commit 0e306f0
Show file tree
Hide file tree
Showing 19 changed files with 262 additions and 200 deletions.
3 changes: 2 additions & 1 deletion data/processors/sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ def extract_tumonline_props(data: dict[str, dict[str, Any]]) -> None:
"""Extract some of the TUMonline data and provides it as `prop`."""
for entry in data.values():
if entry.get("tumonline_data", {}).get("calendar", None):
calendar_url = f"https://campus.tum.de/tumonline/{entry['tumonline_data']['calendar']}"
calendar_resource_id = entry["tumonline_data"]["calendar"]
calendar_url = f"https://campus.tum.de/tumonline/tvKalender.wSicht?cOrg=0&cRes={calendar_resource_id}"
entry["props"]["calendar_url"] = calendar_url
if entry.get("tumonline_data", {}).get("operator", None):
entry["props"]["operator"] = {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
-- Add down migration script here
-- was never used
create table rooms
(
key text primary key not null,
tumonline_org_id integer not null,
tumonline_calendar_id integer not null,
tumonline_room_id integer not null,
last_scrape timestamp without time zone not null
);

-- migrating to
DROP TABLE en;
create table en
(
key text not null
primary key
references de,
name text not null,
tumonline_room_nr integer,
type text not null,
type_common_name text not null,
lat double precision not null,
lon double precision not null,
data text not null,
last_calendar_scrape_at timestamp with time zone
);
comment on column en.last_calendar_scrape_at is 'the last time the calendar was scraped for this room';

DROP TABLE de;
create table de
(
key text not null primary key,
name text not null,
tumonline_room_nr integer,
type text not null,
type_common_name text not null,
lat double precision not null,
lon double precision not null,
data text not null,
last_calendar_scrape_at timestamp with time zone
);
comment on column de.last_calendar_scrape_at is 'the last time the calendar was scraped for this room';
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
-- Add up migration script here
-- was never used
DROP TABLE rooms;

-- migrating to using the json type instead of having elaborate insertion logic
alter table de alter column data type jsonb using data::jsonb;
alter table de drop column lat;
alter table de add column lat FLOAT NOT NULL GENERATED ALWAYS AS (CAST (data->'coords'->>'lat' AS FLOAT)) STORED;
alter table de drop column lon;
alter table de add column lon FLOAT NOT NULL GENERATED ALWAYS AS (CAST (data->'coords'->>'lon' AS FLOAT)) STORED;
alter table de drop column name;
alter table de add column name TEXT NOT NULL GENERATED ALWAYS AS (CAST (data->>'name' AS TEXT)) STORED;
alter table de drop column type_common_name;
alter table de add column type_common_name TEXT NOT NULL GENERATED ALWAYS AS (CAST (data->>'type_common_name' AS TEXT)) STORED;
alter table de drop column type;
alter table de add column type TEXT NOT NULL GENERATED ALWAYS AS (CAST (data->>'type' AS TEXT)) STORED;
alter table de add column calendar_url TEXT GENERATED ALWAYS AS (CAST (data->'props'->>'calendar_url' AS TEXT)) STORED;
alter table de drop column tumonline_room_nr;
alter table de add column tumonline_room_nr INTEGER GENERATED ALWAYS AS (CAST (data->'props'->>'tumonline_room_nr' AS INTEGER)) STORED;

alter table en alter column data type jsonb using data::jsonb;
alter table en drop column lat;
alter table en add column lat FLOAT NOT NULL GENERATED ALWAYS AS (CAST (data->'coords'->>'lat' AS FLOAT)) STORED;
alter table en drop column lon;
alter table en add column lon FLOAT NOT NULL GENERATED ALWAYS AS (CAST (data->'coords'->>'lon' AS FLOAT)) STORED;
alter table en drop column name;
alter table en add column name TEXT NOT NULL GENERATED ALWAYS AS (CAST (data->>'name' AS TEXT)) STORED;
alter table en drop column type_common_name;
alter table en add column type_common_name TEXT NOT NULL GENERATED ALWAYS AS (CAST (data->>'type_common_name' AS TEXT)) STORED;
alter table en drop column type;
alter table en add column type TEXT NOT NULL GENERATED ALWAYS AS (CAST (data->>'type' AS TEXT)) STORED;
alter table en add column calendar_url TEXT GENERATED ALWAYS AS (CAST (data->'props'->>'calendar_url' AS TEXT)) STORED;
alter table en drop column tumonline_room_nr;
alter table en add column tumonline_room_nr INTEGER GENERATED ALWAYS AS (CAST (data->'props'->>'tumonline_room_nr' AS INTEGER)) STORED;
Loading

0 comments on commit 0e306f0

Please sign in to comment.