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";
import { CalendarMonthModel } from "./calendarMonthUtils";
import { CalendarMonthModel, getWeekNumber } from "./calendarMonthUtils";
import { DayOfWeek } from "@/models/local/localCourseSettings";
import { Expandable } from "@/components/Expandable";
import { CalendarWeek } from "./CalendarWeek";
import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHooks";
import { getDateFromStringOrThrow } from "@/models/local/utils/timeUtils";
export const CalendarMonth = ({ month }: { month: CalendarMonthModel }) => {
// const weekInMilliseconds = 604_800_000;
const four_days_in_milliseconds = 345_600_000;
const isInPast =
new Date(month.year, month.month, 1) <
new Date(Date.now() - four_days_in_milliseconds);
const [settings] = useLocalCourseSettingsQuery();
const startDate = getDateFromStringOrThrow(
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(
"default",

View File

@@ -19,6 +19,7 @@ export default function TrpcProvider({
httpBatchLink({
url,
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 } }) => {
return await fileStorageService.assignments.getAssignment(
const assignment = await fileStorageService.assignments.getAssignment(
courseName,
moduleName,
assignmentName
);
// console.log(assignment);
return assignment;
}),
getAllAssignments: publicProcedure
.input(
@@ -28,10 +30,11 @@ export const assignmentRouter = router({
})
)
.query(async ({ input: { courseName, moduleName } }) => {
return await fileStorageService.assignments.getAssignments(
const assignments = await fileStorageService.assignments.getAssignments(
courseName,
moduleName
);
return assignments;
}),
createAssignment: publicProcedure
.input(