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

feat: professor link table to efficiently store links #110

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
7 changes: 5 additions & 2 deletions django/university/controllers/ClassController.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from university.models import Class, Professor, Slot, SlotProfessor
from university.models import Class, Professor, Slot, SlotProfessor, ProfessorLink


class ClassController:
Expand All @@ -9,11 +9,14 @@ def get_professors(slot):
professors = []

for slot_professor in slot_professors:
professor_link = ProfessorLink.objects.get(pk=slot_professor.link_id)

professor = Professor.objects.get(id=slot_professor['professor_id'])
professors.append({
'id': professor.id,
'acronym': professor.professor_acronym,
'name': professor.professor_name
'name': professor.professor_name,
'link': professor_link.link
})

return {
Expand Down
9 changes: 7 additions & 2 deletions postgres/sql/00_schema_postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ CREATE TABLE "public"."slot_class" (
"class_id" bigint NOT NULL
);

CREATE TABLE "public"."professor_link" (
id SERIAL PRIMARY KEY,
"link" varchar(256) NOT NULL
);

--
-- TOC entry 225 (class 1259 OID 16806)
Expand All @@ -173,7 +177,8 @@ CREATE TABLE "public"."slot_class" (

CREATE TABLE "public"."slot_professor" (
"slot_id" integer NOT NULL,
"professor_id" integer NOT NULL
"professor_id" integer NOT NULL,
"link_id" integer NOT NULL
);


Expand Down Expand Up @@ -317,7 +322,7 @@ ALTER TABLE ONLY "public"."slot"
--

ALTER TABLE ONLY "public"."slot_professor"
ADD CONSTRAINT "slot_professor_pkey" PRIMARY KEY ("slot_id", "professor_id");
ADD CONSTRAINT "slot_professor_pkey" PRIMARY KEY ("slot_id", "professor_id", "link_id");
Process-ing marked this conversation as resolved.
Show resolved Hide resolved


--
Expand Down