Add status column for events
All checks were successful
Jenkins Production Deployment

This commit is contained in:
Patrick Müller 2023-05-14 21:26:55 +02:00
parent 95983021ed
commit b8a68c2480
Signed by: Paddy
GPG Key ID: 37ABC11275CAABCE

View File

@ -14,7 +14,7 @@ export const getAllEvents = async (calendarId: number): Promise<Event[]> => {
let conn = await NachklangCalendarDB.getConnection();
let eventRows: Event[] = [];
try {
const eventsQuery = 'SELECT e.*, u.full_name FROM events e LEFT OUTER JOIN users u ON e.created_by_id = u.user_id WHERE calendar_id = ?';
const eventsQuery = 'SELECT e.*, u.full_name FROM events e LEFT OUTER JOIN users u ON e.created_by_id = u.user_id WHERE calendar_id = ? AND status=\'PUBLIC\'';
const eventsRes = await conn.query(eventsQuery, calendarId);
for (let row of eventsRes) {
@ -52,7 +52,7 @@ export const createEvent = async (event: Event): Promise<number> => {
let conn = await NachklangCalendarDB.getConnection();
try {
let eventUUID = Guid.create().toString();
const eventsQuery = 'INSERT INTO events (calendar_id, uuid, name, description, start_datetime, end_datetime, location, created_by_id, url, whole_day) VALUES (?,?,?,?,?,?,?,?,?,?) RETURNING event_id';
const eventsQuery = 'INSERT INTO events (calendar_id, uuid, name, description, start_datetime, end_datetime, location, created_by_id, url, whole_day, status) VALUES (?,?,?,?,?,?,?,?,?,?, \'PUBLIC\') RETURNING event_id';
const eventsRes = await conn.execute(eventsQuery, [event.calendarId, eventUUID, event.name, event.description, event.startDateTime, event.endDateTime, event.location, event.createdById, event.url, event.wholeDay]);
return eventsRes[0].event_id;
@ -94,7 +94,7 @@ export const updateEvent = async (event: Event): Promise<number> => {
export const deleteEvent = async (event: Event): Promise<boolean> => {
let conn = await NachklangCalendarDB.getConnection();
try {
const eventsQuery = 'DELETE FROM events WHERE event_id = ?';
const eventsQuery = 'UPDATE events SET status=\'DELETED\' WHERE event_id = ?';
const eventsRes = await conn.execute(eventsQuery, [event.eventId]);
return eventsRes.affectedRows === 1;