mirror of
https://github.com/dylanbenzi/yellowbird.git
synced 2026-11-27 09:17:00 +00:00
Iterating through events (bathtub commit)
This commit is contained in:
+17
-2
@@ -61,7 +61,9 @@ export interface Event {
|
|||||||
symbol?: string | null;
|
symbol?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getEvents = async (startDate: Date, endDate: Date) => {
|
export const getEvents = async (startDate: Date, endDate: Date): EventArray[] => {
|
||||||
|
const eventArray: EventArray = []
|
||||||
|
|
||||||
const events: Event[] = await db
|
const events: Event[] = await db
|
||||||
.select()
|
.select()
|
||||||
.from(EventsTable)
|
.from(EventsTable)
|
||||||
@@ -74,5 +76,18 @@ export const getEvents = async (startDate: Date, endDate: Date) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// return eventArray;
|
for(let d = startDate, d <= endDate, d.setDate(d.getDate() + 1)) {
|
||||||
|
const eventsByDay: Event[] = []
|
||||||
|
|
||||||
|
events.forEach((e) => {
|
||||||
|
if(isSameDay(e.datetime, d){
|
||||||
|
eventsByDay.push(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
eventArray.push({"date": d, events: eventsByDay})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return eventArray;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user