refactor: ♻️emoves Env parameter
Removes the `Env` parameter from several functions to simplify their signatures and rely on the global `env` for configuration. This change reduces the number of arguments passed around, making the code cleaner and easier to maintain.
This commit is contained in:
@@ -6,7 +6,6 @@ import { DateTime } from "luxon";
|
||||
import { maybeScheduleNextAiringEpisode } from "~/libs/maybeScheduleNextAiringEpisode";
|
||||
import { getValue, setValue } from "~/models/kv";
|
||||
import { filterUnreleasedTitles } from "~/models/unreleasedTitles";
|
||||
import type { Env } from "~/types/env";
|
||||
import type { Title } from "~/types/title";
|
||||
import { MediaFragment } from "~/types/title/mediaFragment";
|
||||
|
||||
@@ -49,12 +48,11 @@ type AiringSchedule = {
|
||||
id: number;
|
||||
};
|
||||
|
||||
export async function getUpcomingTitlesFromAnilist(env: Env, req: HonoRequest) {
|
||||
export async function getUpcomingTitlesFromAnilist(req: HonoRequest) {
|
||||
const client = new GraphQLClient("https://graphql.anilist.co/");
|
||||
const lastCheckedScheduleAt = await getValue(
|
||||
env,
|
||||
"schedule_last_checked_at",
|
||||
).then((value) => (value ? Number(value) : DateTime.now().toUnixInteger()));
|
||||
const lastCheckedScheduleAt = await getValue("schedule_last_checked_at").then(
|
||||
(value) => (value ? Number(value) : DateTime.now().toUnixInteger()),
|
||||
);
|
||||
const twoDaysFromNow = DateTime.now().plus({ days: 2 }).toUnixInteger();
|
||||
|
||||
let currentPage = 1;
|
||||
@@ -72,7 +70,6 @@ export async function getUpcomingTitlesFromAnilist(env: Env, req: HonoRequest) {
|
||||
const { airingSchedules, pageInfo } = Page!;
|
||||
plannedToWatchTitles = plannedToWatchTitles.union(
|
||||
await filterUnreleasedTitles(
|
||||
env,
|
||||
airingSchedules!.map((schedule) => schedule!.media?.id!),
|
||||
),
|
||||
);
|
||||
@@ -90,7 +87,7 @@ export async function getUpcomingTitlesFromAnilist(env: Env, req: HonoRequest) {
|
||||
|
||||
await Promise.all(
|
||||
Array.from(plannedToWatchTitles).map((titleId) =>
|
||||
maybeScheduleNextAiringEpisode(env, req, titleId),
|
||||
maybeScheduleNextAiringEpisode(req, titleId),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -99,7 +96,6 @@ export async function getUpcomingTitlesFromAnilist(env: Env, req: HonoRequest) {
|
||||
}
|
||||
|
||||
await setValue(
|
||||
env,
|
||||
"schedule_last_checked_at",
|
||||
scheduleList[scheduleList.length - 1].airingAt.toString(),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user