Skip to content

Commit 004a322

Browse files
hkamran80essential-randomness
authored andcommitted
Apply suggestions from code review
Rename `begunAt` to `startedAt` and `creators` to `authors`
1 parent 28d840d commit 004a322

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

src/series/getters.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,28 @@ export const getSeriesTitle = ($seriesPage: SeriesPage): string => {
3131
return $seriesPage("h2.heading").text().trim();
3232
};
3333

34-
export const getSeriesCreators = (
34+
export const getSeriesAuthors = (
3535
$seriesPage: SeriesPage
36-
): Series["creators"] => {
37-
const creatorLinks = $seriesPage("dl.meta a[rel=author]");
38-
const creators: Author[] = [];
36+
): Series["authors"] => {
37+
const authorLinks = $seriesPage("dl.meta a[rel=author]");
38+
const authors: Author[] = [];
3939

4040
if (
4141
$seriesPage("dl.meta > dd:nth-of-type(1)").text().trim() === "Anonymous"
4242
) {
4343
return "Anonymous";
4444
}
4545

46-
if (creatorLinks.length !== 0) {
47-
creatorLinks.each((i, element) => {
46+
if (authorLinks.length !== 0) {
47+
authorLinks.each((i, element) => {
4848
const url = element.attribs.href;
4949
const [, username, pseud] = url.match(/users\/(.+)\/pseuds\/(.+)/)!;
5050

51-
creators.push({ username: username, pseud: decodeURI(pseud) });
51+
authors.push({ username: username, pseud: decodeURI(pseud) });
5252
});
5353
}
5454

55-
return creators;
55+
return authors;
5656
};
5757

5858
export const getSeriesDescription = (

src/series/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { loadSeriesPage } from "src/page-loaders";
22
import { Series } from "types/entities";
33
import {
4-
getSeriesCreators,
4+
getSeriesAuthors,
55
getSeriesBookmarkCount,
66
getSeriesCompletionStatus,
77
getSeriesDescription,
@@ -27,9 +27,9 @@ export const getSeries = async ({
2727
return {
2828
id: seriesId,
2929
name: getSeriesTitle(seriesPage),
30-
begunAt: getSeriesPublishDate(seriesPage),
30+
startedAt: getSeriesPublishDate(seriesPage),
3131
updatedAt: getSeriesUpdateDate(seriesPage),
32-
creators: getSeriesCreators(seriesPage),
32+
authors: getSeriesAuthors(seriesPage),
3333
description: getSeriesDescription(seriesPage),
3434
notes: getSeriesNotes(seriesPage),
3535
words: getSeriesWordCount(seriesPage),

tests/series.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ describe("Fetches series information", () => {
375375

376376
test("Fetches author with username Anonymous", async () => {
377377
const series = await getSeries({ seriesId: "2946579" });
378-
expect(series.creators).toBe("Anonymous");
378+
expect(series.authors).toBe("Anonymous");
379379
});
380380

381381
describe("Fetches series title", () => {

types/entities.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ export interface SeriesWorkSummary
5050
export interface Series {
5151
id: string;
5252
name: string;
53-
begunAt: string;
53+
startedAt: string;
5454
updatedAt: string;
55-
creators: WorkSummary["authors"];
55+
authors: WorkSummary["authors"];
5656
description: string | null;
5757
notes: string | null;
5858
words: number;

0 commit comments

Comments
 (0)