Add helper functions for fetching events #115

Merged
j285he merged 13 commits from feat/events-lib into main 2021-08-17 14:58:07 -04:00
Member

helper functions for [year] and [year]/[term] only

closes #110

helper functions for [year] and [year]/[term] only closes #110
j285he added 1 commit 2021-07-27 16:47:48 -04:00
continuous-integration/drone/push Build is passing Details
b733acd156
Add lib file
a3thakra changed title from Add lib file to Add helper functions for fetching events 2021-07-27 16:54:00 -04:00
j285he added 1 commit 2021-07-27 20:34:00 -04:00
continuous-integration/drone/push Build is passing Details
bfcbf5c687
Fix type error
a3thakra reviewed 2021-08-01 17:21:25 -04:00
lib/events.ts Outdated
@ -0,0 +7,4 @@
const EVENTS_PATH = path.join("content", "events");
export async function getYears(): Promise<string[]> {
return await fs.readdir(EVENTS_PATH);
Owner

You should use options.withFileTypes here and only return the items that are directories

You should use `options.withFileTypes` here and only return the items that are directories
Owner
More info here: https://nodejs.org/api/fs.html#fs_fspromises_readdir_path_options
j285he marked this conversation as resolved
a3thakra reviewed 2021-08-01 17:22:21 -04:00
lib/events.ts Outdated
@ -0,0 +11,4 @@
}
export async function getTermsByYear(year: string): Promise<string[]> {
return await fs.readdir(path.join(EVENTS_PATH, year));
Owner

same here

same here
j285he marked this conversation as resolved
a3thakra reviewed 2021-08-01 17:23:47 -04:00
lib/events.ts Outdated
@ -0,0 +50,4 @@
): Promise<Event[]> {
const files = (await fs.readdir(path.join(EVENTS_PATH, year, term)))
.filter((name) => name.endsWith(".event.md"))
.map((name) => name.slice(0, -".event.md".length));
Owner

Can we switch to foo.md instead of foo.event.md?

Can we switch to `foo.md` instead of `foo.event.md`?
Owner

We were using .event.mdx because that enabled us to easily cast the type of the file to what we wanted. But we can't really do that here.

We were using `.event.mdx` because that enabled us to easily cast the type of the file to what we wanted. But we can't really do that here.
j285he marked this conversation as resolved
a3thakra reviewed 2021-08-01 17:27:14 -04:00
@ -0,0 +44,4 @@
};
}
export async function getEventsByTerm(
Owner

imo this function should just return event slugs, and not the complete events.

imo this function should just return event slugs, and not the complete events.
j285he marked this conversation as resolved
j285he added 1 commit 2021-08-02 20:33:43 -04:00
continuous-integration/drone/push Build is passing Details
9f7d40b426
Merge branch 'main' into feat/events-lib
j285he added 3 commits 2021-08-02 22:45:45 -04:00
a3thakra reviewed 2021-08-03 00:19:21 -04:00
lib/events.ts Outdated
@ -0,0 +9,4 @@
export async function getYears(): Promise<string[]> {
return (await fs.readdir(EVENTS_PATH, { withFileTypes: true })).map(
(dirent) => dirent.name
);
Owner

We are missing something here ... read the documentation for withFileTypes a bit more carefully. What does it return? What do we want to return?

We are missing something here ... read the documentation for `withFileTypes` a bit more carefully. What does it return? What do we want to return?
j285he marked this conversation as resolved
a3thakra reviewed 2021-08-03 00:20:16 -04:00
lib/events.ts Outdated
@ -0,0 +56,4 @@
): Promise<string[]> {
return (
await fs.readdir(path.join(EVENTS_PATH, year, term), {
withFileTypes: true,
Owner

there is no need for doing this here

there is no need for doing this here
j285he marked this conversation as resolved
j285he added 1 commit 2021-08-16 17:02:54 -04:00
continuous-integration/drone/push Build is failing Details
590b2554c0
Fixes for dirents
j285he added 1 commit 2021-08-16 19:40:24 -04:00
continuous-integration/drone/push Build is passing Details
d237621d14
ESLint fixes
Owner

Terms and years should be sorted. Take a look at #145

Terms and years should be sorted. Take a look at #145
j285he added 1 commit 2021-08-16 23:45:20 -04:00
continuous-integration/drone/push Build is passing Details
3a697c09c0
Add sorting
Author
Member

Terms and years should be sorted. Take a look at #145

Why do we have the order as winter, spring, then fall?

> Terms and years should be sorted. Take a look at #145 Why do we have the order as winter, spring, then fall?
j285he added 2 commits 2021-08-16 23:53:08 -04:00
j285he added 1 commit 2021-08-17 00:03:11 -04:00
continuous-integration/drone/push Build is passing Details
b32fd53d95
Remove unneeded dirent conversion
Owner

Why do we have the order as winter, spring, then fall?

because that's the chronological order. Jan - April, May -> August, Sept -> Dec

> Why do we have the order as winter, spring, then fall? because that's the chronological order. Jan - April, May -> August, Sept -> Dec
j285he added 1 commit 2021-08-17 14:52:39 -04:00
continuous-integration/drone/push Build is passing Details
fecd3bf3e0
Rename functions
a3thakra approved these changes 2021-08-17 14:53:02 -04:00
j285he merged commit 64fbabf204 into main 2021-08-17 14:58:07 -04:00
j285he deleted branch feat/events-lib 2021-08-17 14:58:21 -04:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: www/www-new#115
No description provided.