Skip to content
Snippets Groups Projects
Commit d9d572d4 authored by Stephanie Freitag's avatar Stephanie Freitag
Browse files

NOISSUE: adjust range for selection random pages

parent e6e5cf2d
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,7 @@ const PICTURE_TYPE_REGEX = /(.*)_(\d+)x(\d+)/;
export const SUPPORTED_LANGUAGES = ["en", "de"];
export const DEFAULT_LANGUAGE: BetterPlaceLanguage = "en";
const DEFAULT_PAGE_SIZE = 10;
const MAX_PAGE_FOR_RANDOMIZATION = 1250;
const MAX_PAGE_FOR_RANDOMIZATION = 10;
const cleanUpHtml = (html: string): string => {
let result = "";
......@@ -251,10 +251,9 @@ const fetchPageOfProjects = (
});
};
// Do not select projects from too far back and not the first two pages
// Do not select projects from too far back
const randomPageForToday = () =>
(new Date().setUTCHours(0, 0, 0, 0) / 100000) % MAX_PAGE_FOR_RANDOMIZATION +
2;
(new Date().setUTCHours(0, 0, 0, 0) / 100000) % MAX_PAGE_FOR_RANDOMIZATION;
export const fetchProjects = (
{ offset = 0, limit = DEFAULT_PAGE_SIZE, location }: ProjectsParameters,
......
......@@ -185,7 +185,7 @@ describe("betterplace", () => {
let time: FakeTime;
beforeEach(() => {
time = new FakeTime(new Date(2023, 8, 13, 12));
time = new FakeTime(new Date(2023, 8, 12, 12));
});
afterEach(() => {
......@@ -248,7 +248,7 @@ describe("betterplace", () => {
await fetchProjects({}, "de");
assertSpyCall(fetchStub, 0, { args: [urlForPage(635)] });
assertSpyCall(fetchStub, 0, { args: [urlForPage(9)] });
});
it("queries a different random page the next day", async () => {
......@@ -257,7 +257,7 @@ describe("betterplace", () => {
await fetchProjects({}, "de");
assertSpyCall(fetchStub, 0, { args: [urlForPage(249)] });
assertSpyCall(fetchStub, 0, { args: [urlForPage(3)] });
});
it("resumes normal pagination after the first page", async () => {
......@@ -275,7 +275,7 @@ describe("betterplace", () => {
await fetchProjects({ offset: 10 }, "de");
await fetchProjects({ offset: 20 }, "de");
assertSpyCall(fetchStub, 0, { args: [urlForPage(635)] });
assertSpyCall(fetchStub, 0, { args: [urlForPage(9)] });
assertSpyCall(fetchStub, 1, { args: [urlForPage(1)] });
assertSpyCall(fetchStub, 2, { args: [urlForPage(2)] });
});
......@@ -292,12 +292,12 @@ describe("betterplace", () => {
);
await fetchProjects({}, "de");
await fetchProjects({ offset: 6340 }, "de");
await fetchProjects({ offset: 6350 }, "de");
await fetchProjects({ offset: 80 }, "de");
await fetchProjects({ offset: 90 }, "de");
assertSpyCall(fetchStub, 0, { args: [urlForPage(635)] });
assertSpyCall(fetchStub, 1, { args: [urlForPage(634)] });
assertSpyCall(fetchStub, 2, { args: [urlForPage(636)] });
assertSpyCall(fetchStub, 0, { args: [urlForPage(9)] });
assertSpyCall(fetchStub, 1, { args: [urlForPage(8)] });
assertSpyCall(fetchStub, 2, { args: [urlForPage(10)] });
});
it("does not query random projects for the first page when filtering for location", async () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment