Skip to content

Commit

Permalink
Adding website for Events #59
Browse files Browse the repository at this point in the history
  • Loading branch information
alliyya committed Nov 12, 2018
1 parent a3557c4 commit 92ec351
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 23 deletions.
6 changes: 3 additions & 3 deletions api/src/migrations/001_create_initial_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS Doom_User(
picture_path TEXT,
password_hash TEXT NOT NULL,
confirmed BOOL DEFAULT FALSE,

website TEXT,
PRIMARY KEY (ID)
);

Expand All @@ -32,7 +32,7 @@ CREATE TABLE IF NOT EXISTS Event(
current_capacity INT,
location TEXT,
picture_path TEXT,

website TEXT,
PRIMARY KEY (ID),
FOREIGN KEY (creator_id) REFERENCES Doom_User (ID)
);
Expand All @@ -49,7 +49,7 @@ CREATE TABLE IF NOT EXISTS Seminar(
current_capacity INT,
location TEXT,
picture_path TEXT,

website TEXT,
PRIMARY KEY (ID),
FOREIGN KEY (event_id) REFERENCES Event (ID)
);
Expand Down
3 changes: 2 additions & 1 deletion api/src/migrations/002_create_sample_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ insert into doom_user (first_name, last_name, email, privacy_settings, password_


-- 3 events
insert into Event (creator_id, name, start_time, end_time, capacity_type, max_capacity, current_capacity) values (3,'CUSEC',TIMESTAMP '2019-10-23 8:30:00+02', TIMESTAMP '2019-11-27 10:30:00+02', 'FCFS_E',6,0);
insert into Event (creator_id, name, start_time, end_time, capacity_type, max_capacity, current_capacity, website) values (3,'CUSEC',TIMESTAMP '2019-10-23 8:30:00+02', TIMESTAMP '2019-11-27 10:30:00+02', 'FCFS_E',6,0,'http://2018.cusec.net/');
insert into Event (creator_id, name, start_time, end_time, capacity_type, max_capacity, current_capacity) values (2,'Animefest',TIMESTAMP '2019-10-21 12:30:00+02', TIMESTAMP '2019-11-29 10:30:00+02', 'FCFS_P',3,2);
insert into Event (creator_id, name, start_time, end_time, capacity_type) values (1,'Doomsday convention',TIMESTAMP '2018-10-30 1:00:00', TIMESTAMP '2018-11-02 10:30:00', 'FFA');
insert into Event (creator_id, name, start_time, end_time, capacity_type,max_capacity, current_capacity) values (6,'Avenger Meetup',TIMESTAMP '2019-05-03 10:30:00', TIMESTAMP '2019-11-24 10:30:00', 'FCFS_E',5,0);
Expand All @@ -37,6 +37,7 @@ insert into Seminar_Organizer (user_id, seminar_id) values (2,2);
insert into Seminar_Organizer (user_id, seminar_id) values (3,1);
insert into Seminar_Organizer (user_id, seminar_id) values (4,3);

insert into Event_Participation (user_id, event_id, attending) values (10,1,True);
insert into Event_Participation (user_id, event_id, attending) values (2,2,True);
insert into Event_Participation (user_id, event_id, attending) values (5,2,True);
insert into Event_Participation (user_id, event_id, attending) values (3,2,True);
Expand Down
14 changes: 9 additions & 5 deletions api/src/mutations/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ async function insertNewEvent(eventInput) {
max_capacity,
location,
picture_path,
organizer_ids
organizer_ids,
website
} = eventInput;

const event_start_time = new Date(start_time);
Expand Down Expand Up @@ -40,15 +41,16 @@ async function insertNewEvent(eventInput) {
description = description || null;

location = location || null;
website = website || null;
picture_path = picture_path || null;

organizer_ids = organizer_ids || [];
organizer_ids.push(creator_id);

const queryString = `INSERT INTO Event
(creator_id, name, description, start_time, end_time, capacity_type,
max_capacity, location, picture_path, current_capacity)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id;`;
max_capacity, location, picture_path, current_capacity, website)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?) RETURNING id;`;

const vals = [
creator_id,
Expand All @@ -60,7 +62,8 @@ async function insertNewEvent(eventInput) {
max_capacity,
location,
picture_path,
current_capacity
current_capacity,
website
];

const res = await db.raw(`${queryString}`, vals);
Expand All @@ -83,7 +86,8 @@ async function insertNewEvent(eventInput) {
location,
current_capacity,
picture_path,
id
id,
website
};
}

Expand Down
23 changes: 13 additions & 10 deletions api/src/resolvers/searchResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function searchEventsAndSeminars(
description AS description, start_time AS start_time,
end_time AS end_time, capacity_type AS capacity_type,
max_capacity AS max_capacity, current_capacity AS current_capacity,
location AS location, picture_path AS picture_path
location AS location, picture_path AS picture_path, website AS website
FROM ??`;
vals.push("event_id", "event");
} else {
Expand Down Expand Up @@ -51,7 +51,7 @@ async function searchEventsAndSeminars(
description AS description, start_time AS start_time,
end_time AS end_time, capacity_type AS capacity_type,
max_capacity AS max_capacity, current_capacity AS current_capacity,
location AS location, picture_path AS picture_path
location AS location, picture_path AS picture_path, website AS website
FROM ??
${whereClause}`;
vals.push("creator_id", "seminar");
Expand Down Expand Up @@ -83,7 +83,8 @@ async function searchEventsAndSeminars(
max_capacity: searchResult.max_capacity,
current_capacity: searchResult.current_capacity,
location: searchResult.location,
picture_path: searchResult.picture_path
picture_path: searchResult.picture_path,
website: searchResult.website
};

if (searchResult.creator_id)
Expand Down Expand Up @@ -151,7 +152,7 @@ async function getMySchedule(
??.description AS description, ??.start_time AS start_time,
??.end_time AS end_time, ??.capacity_type AS capacity_type,
??.max_capacity AS max_capacity, ??.current_capacity AS current_capacity,
??.location AS location, ??.picture_path AS picture_path,`;
??.location AS location, ??.picture_path AS picture_path, ??.website AS website, `;
var whereQueryString = `WHERE ??.user_id = ?`;

if (!participationType) {
Expand All @@ -163,12 +164,12 @@ async function getMySchedule(
}

if (!type || type.toLowerCase() === "event") {
// do both types. Start w/ event and UION ALL w/ seminar
// do both types. Start w/ event and UNION ALL w/ seminar
queryString = `
${selectQueryString} "event".creator_id AS creator_id, NULL AS event_id
FROM ?? JOIN ?? ON (??.?? = ??.id) ${whereQueryString}`;

for (let i = 0; i < 10; i++) {
for (let i = 0; i < 11; i++) {
vals.push("event");
}
vals.push(
Expand Down Expand Up @@ -197,7 +198,7 @@ async function getMySchedule(
${queryString} ${selectQueryString} NULL AS creator_id, "seminar".event_id AS event_id
FROM ?? JOIN ?? ON (??.?? = ??.id) ${whereQueryString}`;

for (let i = 0; i < 10; i++) {
for (let i = 0; i < 11; i++) {
vals.push("seminar");
}
vals.push(
Expand Down Expand Up @@ -240,7 +241,8 @@ async function getMySchedule(
max_capacity: result.max_capacity,
current_capacity: result.current_capacity,
location: result.location,
picture_path: result.picture_path
picture_path: result.picture_path,
website: result.website
};

if (result.creator_id) eventOrSeminar.creator_id = result.creator_id;
Expand Down Expand Up @@ -319,7 +321,7 @@ async function getMyManagingSchedule(
WHERE user_id = ?`;

if (!type || type.toLowerCase() === "event") {
// do both types. Start w/ event and UION ALL w/ seminar
// do both types. Start w/ event and UNION ALL w/ seminar
vals.push(
"event_type",
"event_organizer",
Expand Down Expand Up @@ -372,7 +374,8 @@ async function getMyManagingSchedule(
max_capacity: result.max_capacity,
current_capacity: result.current_capacity,
location: result.location,
picture_path: result.picture_path
picture_path: result.picture_path,
website: result.website
};

if (result.type === "event_type")
Expand Down
9 changes: 5 additions & 4 deletions api/src/types/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ type Event {
capacity_type: capacity_type!
max_capacity: Int
current_capacity: Int
location: String
website: String
# still need to add photo
picture_path: String
#Testing attaching announcements to an event
announcements: [Announcement!]
organizers: [User!]
seminars: [Seminar!]
}
input EventInput {
Expand All @@ -36,13 +36,14 @@ input EventInput {
""" Must be formatted as 2019-10-20 10:30 YYYY-MM-DD HH:MM"""
end_time: String!
""" If the capacity_type is FCFS_P or FCFS_P """
capacity_type: capacity_type!
max_capacity: Int
organizer_ids: [Int!]
location: String
picture_path: String
website: String
}
Expand Down

0 comments on commit 92ec351

Please sign in to comment.