finally had to deal with too many http requests

This commit is contained in:
2024-11-15 13:10:04 -07:00
parent b889ed6e22
commit 283650d70a
3 changed files with 26 additions and 6 deletions

View File

@@ -1,15 +1,31 @@
"use client"; "use client";
import { CalendarMonthModel } from "./calendarMonthUtils"; import { CalendarMonthModel, getWeekNumber } from "./calendarMonthUtils";
import { DayOfWeek } from "@/models/local/localCourseSettings"; import { DayOfWeek } from "@/models/local/localCourseSettings";
import { Expandable } from "@/components/Expandable"; import { Expandable } from "@/components/Expandable";
import { CalendarWeek } from "./CalendarWeek"; import { CalendarWeek } from "./CalendarWeek";
import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHooks";
import { getDateFromStringOrThrow } from "@/models/local/utils/timeUtils";
export const CalendarMonth = ({ month }: { month: CalendarMonthModel }) => { export const CalendarMonth = ({ month }: { month: CalendarMonthModel }) => {
// const weekInMilliseconds = 604_800_000; // const weekInMilliseconds = 604_800_000;
const four_days_in_milliseconds = 345_600_000; const four_days_in_milliseconds = 345_600_000;
const isInPast = const [settings] = useLocalCourseSettingsQuery();
new Date(month.year, month.month, 1) < const startDate = getDateFromStringOrThrow(
new Date(Date.now() - four_days_in_milliseconds); settings.startDate,
"week calculation start date"
);
const pastWeekNumber = getWeekNumber(
startDate,
new Date(Date.now() - four_days_in_milliseconds)
);
const startOfMonthWeekNumber = getWeekNumber(
startDate,
new Date(month.year, month.month, 1)
);
const isInPast = pastWeekNumber >= startOfMonthWeekNumber;
const monthName = new Date(month.year, month.month - 1, 1).toLocaleString( const monthName = new Date(month.year, month.month - 1, 1).toLocaleString(
"default", "default",

View File

@@ -19,6 +19,7 @@ export default function TrpcProvider({
httpBatchLink({ httpBatchLink({
url, url,
transformer: superjson, transformer: superjson,
maxURLLength: 10_000, // limit number of batched requests
}), }),
], ],
}) })

View File

@@ -14,11 +14,13 @@ export const assignmentRouter = router({
}) })
) )
.query(async ({ input: { courseName, moduleName, assignmentName } }) => { .query(async ({ input: { courseName, moduleName, assignmentName } }) => {
return await fileStorageService.assignments.getAssignment( const assignment = await fileStorageService.assignments.getAssignment(
courseName, courseName,
moduleName, moduleName,
assignmentName assignmentName
); );
// console.log(assignment);
return assignment;
}), }),
getAllAssignments: publicProcedure getAllAssignments: publicProcedure
.input( .input(
@@ -28,10 +30,11 @@ export const assignmentRouter = router({
}) })
) )
.query(async ({ input: { courseName, moduleName } }) => { .query(async ({ input: { courseName, moduleName } }) => {
return await fileStorageService.assignments.getAssignments( const assignments = await fileStorageService.assignments.getAssignments(
courseName, courseName,
moduleName moduleName
); );
return assignments;
}), }),
createAssignment: publicProcedure createAssignment: publicProcedure
.input( .input(