mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
day of linting judgement
This commit is contained in:
@@ -15,6 +15,7 @@ export const canvasPageService = {
|
||||
url,
|
||||
});
|
||||
return pages.flatMap((pageList) => pageList);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (error: any) {
|
||||
if (error?.response?.status === 403) {
|
||||
console.log(
|
||||
|
||||
@@ -72,6 +72,7 @@ const createQuestionOnly = async (
|
||||
const hackFixQuestionOrdering = async (
|
||||
canvasCourseId: number,
|
||||
canvasQuizId: number,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
questionAndPositions: Array<{ question: any; position: number }>
|
||||
) => {
|
||||
console.log("Fixing question order");
|
||||
@@ -149,6 +150,7 @@ export const canvasQuizService = {
|
||||
? new Date(quiz.lock_at).toLocaleString()
|
||||
: undefined,
|
||||
}));
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (error: any) {
|
||||
if (error?.response?.status === 403) {
|
||||
console.log(
|
||||
|
||||
@@ -33,10 +33,10 @@ const getNextUrl = (
|
||||
return nextUrl;
|
||||
};
|
||||
|
||||
export async function paginatedRequest<T extends any[]>(request: {
|
||||
export async function paginatedRequest<T extends unknown[]>(request: {
|
||||
url: string;
|
||||
}): Promise<T> {
|
||||
var requestCount = 1;
|
||||
let requestCount = 1;
|
||||
const url = new URL(request.url);
|
||||
url.searchParams.set("per_page", "100");
|
||||
|
||||
@@ -44,8 +44,8 @@ export async function paginatedRequest<T extends any[]>(request: {
|
||||
url.toString()
|
||||
);
|
||||
|
||||
var returnData = Array.isArray(firstData) ? [...firstData] : [firstData]; // terms come across as nested objects {enrolmentTerms: terms[]}
|
||||
var nextUrl = getNextUrl(firstHeaders);
|
||||
let returnData = Array.isArray(firstData) ? [...firstData] : [firstData]; // terms come across as nested objects {enrolmentTerms: terms[]}
|
||||
let nextUrl = getNextUrl(firstHeaders);
|
||||
|
||||
while (nextUrl) {
|
||||
requestCount += 1;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { AxiosResponse } from "axios";
|
||||
import { axiosClient } from "../axiosUtils";
|
||||
|
||||
type FetchOptions = Omit<RequestInit, "method">;
|
||||
|
||||
const rateLimitRetryCount = 6;
|
||||
const rateLimitSleepInterval = 1000;
|
||||
|
||||
@@ -18,21 +16,21 @@ export const isRateLimited = async (
|
||||
);
|
||||
};
|
||||
|
||||
const rateLimitAwarePost = async (url: string, body: any, retryCount = 0) => {
|
||||
const response = await axiosClient.post(url, body);
|
||||
// const rateLimitAwarePost = async (url: string, body: unknown, retryCount = 0) => {
|
||||
// const response = await axiosClient.post(url, body);
|
||||
|
||||
if (await isRateLimited(response)) {
|
||||
if (retryCount < rateLimitRetryCount) {
|
||||
console.info(
|
||||
`Hit rate limit on post, retry count is ${retryCount} / ${rateLimitRetryCount}, retrying`
|
||||
);
|
||||
await sleep(rateLimitSleepInterval);
|
||||
return await rateLimitAwarePost(url, body, retryCount + 1);
|
||||
}
|
||||
}
|
||||
// if (await isRateLimited(response)) {
|
||||
// if (retryCount < rateLimitRetryCount) {
|
||||
// console.info(
|
||||
// `Hit rate limit on post, retry count is ${retryCount} / ${rateLimitRetryCount}, retrying`
|
||||
// );
|
||||
// await sleep(rateLimitSleepInterval);
|
||||
// return await rateLimitAwarePost(url, body, retryCount + 1);
|
||||
// }
|
||||
// }
|
||||
|
||||
return response;
|
||||
};
|
||||
// return response;
|
||||
// };
|
||||
|
||||
export const rateLimitAwareDelete = async (
|
||||
url: string,
|
||||
|
||||
Reference in New Issue
Block a user