Skip to content

Commit

Permalink
chore: move delay to env
Browse files Browse the repository at this point in the history
  • Loading branch information
D0dii committed Jan 17, 2025
1 parent 1e07303 commit 22d0631
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions backend/app/scrap-lecturers/scrap_lecturers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,16 @@ const scrapLecturersPage = async (url: string, authCookie: string) => {

if (body.includes("Zapomniałem hasła")) {
logger.error("You need to login to polwro.com. Wrong cookies my friends");
// TODO: set this in env
await delay(1000);
await delay(Number(env.get("POLWRO_DELAY")));
return;
}

const $ = cheerio.load(body);
logger.info("Planer to bambiki");
const lecturers = $("tbody")
.find("td")
.children("div.hrw")
.children("div.img.folder, div.img.folder_hot, div.img.folder_locked")
.map((_, element) => {
logger.info("Planer to bambiki 1");
const smallBlock = $(element);
const text = smallBlock.text().trim().replace(/\s+/g, " ");
const splitedData = removeTitles(text.split(" "));
Expand Down Expand Up @@ -134,8 +131,7 @@ const scrapLecturersPage = async (url: string, authCookie: string) => {
}
});

// TODO: set this in env
await delay(1000);
await delay(Number(env.get("POLWRO_DELAY")));
return { lecturers, nextPageUrl };
};

Expand Down Expand Up @@ -171,4 +167,3 @@ export const scrapLecturers = async () => {
}
return lecturers;
};
// elo żelo

0 comments on commit 22d0631

Please sign in to comment.