Skip to content

Commit

Permalink
Rename algorithm to lottery (#1033)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archinowsk authored Aug 25, 2024
1 parent 98cee16 commit 49060b1
Show file tree
Hide file tree
Showing 20 changed files with 92 additions and 91 deletions.
10 changes: 5 additions & 5 deletions client/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,11 @@ export const translationEN = {
"Participants are selected in the order of sign-ups. Sign-up opens ",
directSignupOpenNow:
"Participants are selected in the order of sign-ups. Sign-up closes ",
algorithmSignupStartsLater:
lotterySignupStartsLater:
"Participants are selected in a lottery. Lotter sign-up open ",
algorithmSignupOpen:
lotterySignupOpen:
"Participants are selected in a lottery. Lottery sign-up closes ",
algorithmSignupEnded: "Participants were selected in a lottery.",
lotterySignupEnded: "Participants were selected in a lottery.",
directSignupStarts: " Direct sign-up to remaining and cancelled spots: ",
},
},
Expand Down Expand Up @@ -492,8 +492,8 @@ export const translationEN = {
},
strategies: {
direct: "Direct",
algorithm: "Algorithm",
"algorithm+direct": "Algorithm + Direct",
lottery: "Lottery",
"lottery+direct": "Lottery + Direct",
},
loginProvider: {
local: "Local",
Expand Down
10 changes: 5 additions & 5 deletions client/src/locales/fi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,11 @@ export const translationFI = {
"Osallistujat valitaan ilmoittautumisjärjestyksessä. Ilmoittautuminen alkaa: ",
directSignupOpenNow:
"Osallistujat valitaan ilmoittautumisjärjestyksessä. Ilmoittautuminen sulkeutuu: ",
algorithmSignupStartsLater:
lotterySignupStartsLater:
"Osallistujat valitaan arvonnalla. Arvontaan ilmoittautuminen: ",
algorithmSignupOpen:
lotterySignupOpen:
"Osallistujat valitaan arvonnalla. Arvontaan ilmoittautuminen päättyy: ",
algorithmSignupEnded: "Osallistujat valittiin arvonnalla.",
lotterySignupEnded: "Osallistujat valittiin arvonnalla.",
directSignupStarts:
" Suora ilmoittautuminen jäljelle jääneisiin ja peruutuspaikkoihin: ",
},
Expand Down Expand Up @@ -494,8 +494,8 @@ export const translationFI = {
},
strategies: {
direct: "Suora",
algorithm: "Algoritmi",
"algorithm+direct": "Algoritmi + Suora",
lottery: "Arvonta",
"lottery+direct": "Arvonta + Suora",
},
loginProvider: {
local: "Lokaali",
Expand Down
6 changes: 3 additions & 3 deletions client/src/views/admin/components/SignupStrategySelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export const SignupStrategySelector = (): ReactElement => {

const strategies = [
{ value: SignupStrategy.DIRECT, title: t("strategies.direct") },
{ value: SignupStrategy.ALGORITHM, title: t("strategies.algorithm") },
{ value: SignupStrategy.LOTTERY, title: t("strategies.lottery") },
{
value: SignupStrategy.ALGORITHM_AND_DIRECT,
title: t("strategies.algorithm+direct"),
value: SignupStrategy.LOTTERY_AND_DIRECT,
title: t("strategies.lottery+direct"),
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { CancelSignupForm } from "client/views/all-program-items/components/Canc
import { getTimeNow } from "client/utils/getTimeNow";
import { config } from "shared/config";
import { SignupStrategy } from "shared/config/eventConfigTypes";
import { getAlgorithmSignupStartTime } from "shared/utils/signupTimes";
import { getLotterySignupStartTime } from "shared/utils/signupTimes";
import { getIsInGroup } from "client/views/group/groupUtils";
import { InfoText } from "client/components/InfoText";

Expand Down Expand Up @@ -96,12 +96,12 @@ export const LotterySignupProgramItem = ({
lotterySignups,
);

const algorithmSignupStartTime = getAlgorithmSignupStartTime(startTime);
const lotterySignupStartTime = getLotterySignupStartTime(startTime);

const timeNow = getTimeNow();
const lotterySignupOpen =
timeNow.isSameOrAfter(algorithmSignupStartTime) ||
config.event().manualSignupMode === SignupStrategy.ALGORITHM;
timeNow.isSameOrAfter(lotterySignupStartTime) ||
config.event().manualSignupMode === SignupStrategy.LOTTERY;

if (!loggedIn) {
return (
Expand Down
38 changes: 19 additions & 19 deletions client/src/views/all-program-items/components/SignupHelpText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import { ProgramItem, SignupType } from "shared/types/models/programItem";
import { getTimeNow } from "client/utils/getTimeNow";
import { isRevolvingDoorWorkshop } from "client/utils/isRevolvingDoorWorkshop";
import {
getAlgorithmSignupEndTime,
getAlgorithmSignupStartTime,
getLotterySignupEndTime,
getLotterySignupStartTime,
getDirectSignupStartTime,
} from "shared/utils/signupTimes";
import {
getFormattedTime,
getFormattedInterval,
} from "client/views/all-program-items/components/allProgramItemsUtils";
import { config } from "shared/config";
import { tooEearlyForAlgorithmSignup } from "shared/utils/tooEearlyForAlgorithmSignup";
import { tooEarlyForLotterySignup } from "shared/utils/tooEarlyForLotterySignup";

interface Props {
programItem: ProgramItem;
Expand All @@ -34,18 +34,18 @@ export const SignupHelpText = ({
}: Props): ReactElement => {
const { t } = useTranslation();

const isAlgorithmSignup =
const isLotterySignup =
config
.event()
.twoPhaseSignupProgramTypes.includes(programItem.programType) &&
!tooEearlyForAlgorithmSignup(startTime);
!tooEarlyForLotterySignup(startTime);

const timeNow = getTimeNow();
const programStartTime = dayjs(programItem.startTime);
const directSignupStartTime = getDirectSignupStartTime(programItem);
const directSignupStarted = timeNow.isSameOrAfter(directSignupStartTime);
const algorithmSignupStartTime = getAlgorithmSignupStartTime(startTime);
const algorithmSignupEndTime = getAlgorithmSignupEndTime(startTime);
const lotterySignupStartTime = getLotterySignupStartTime(startTime);
const lotterySignupEndTime = getLotterySignupEndTime(startTime);

if (
programItem.signupType === SignupType.NONE ||
Expand Down Expand Up @@ -88,7 +88,7 @@ export const SignupHelpText = ({
);
}

if (!isAlgorithmSignup) {
if (!isLotterySignup) {
if (!directSignupStarted) {
return (
<p>
Expand All @@ -107,17 +107,17 @@ export const SignupHelpText = ({
);
}

// Algorithm sign-up
if (algorithmSignupStartTime.isSameOrAfter(timeNow)) {
// Lottery sign-up
if (lotterySignupStartTime.isSameOrAfter(timeNow)) {
// Waiting for sign up to start
return (
<p>
<FontAwesomeIcon icon={"dice-three"} />{" "}
{t("signup.help.algorithmSignupStartsLater")}
{t("signup.help.lotterySignupStartsLater")}
<b>
{getFormattedInterval(
algorithmSignupStartTime,
algorithmSignupEndTime,
lotterySignupStartTime,
lotterySignupEndTime,
timeNow,
)}
</b>
Expand All @@ -133,15 +133,15 @@ export const SignupHelpText = ({
</p>
);
} else if (
algorithmSignupEndTime.isSameOrAfter(timeNow) &&
lotterySignupEndTime.isSameOrAfter(timeNow) &&
!directSignupStarted
) {
// Algorithm sign-up happening now
// Lottery sign-up happening now
return (
<p>
<FontAwesomeIcon icon={"dice-three"} />{" "}
{t("signup.help.algorithmSignupOpen")}
<b>{getFormattedTime(algorithmSignupEndTime, timeNow)}</b>.
{t("signup.help.lotterySignupOpen")}
<b>{getFormattedTime(lotterySignupEndTime, timeNow)}</b>.
{t("signup.help.directSignupStarts")}
<b>
{getFormattedInterval(
Expand All @@ -155,10 +155,10 @@ export const SignupHelpText = ({
);
}
return (
// Algorithm sign-up ended, direct sign-up starting or started
// Lottery sign-up ended, direct sign-up starting or started
<p>
<FontAwesomeIcon icon={"dice-three"} />{" "}
{t("signup.help.algorithmSignupEnded")}
{t("signup.help.lotterySignupEnded")}
{t("signup.help.directSignupStarts")}
<b>
{getFormattedInterval(directSignupStartTime, programStartTime, timeNow)}
Expand Down
2 changes: 1 addition & 1 deletion playwright/tests/lotterySignup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { config } from "shared/config";
test("Add lottery signup", async ({ page, request }) => {
logTestStart("Add lottery signup");
await populateDb(request);
await postSettings(request, { signupStrategy: SignupStrategy.ALGORITHM });
await postSettings(request, { signupStrategy: SignupStrategy.LOTTERY });
await postTestSettings(request, {
testTime: config.event().eventStartTime,
});
Expand Down
8 changes: 4 additions & 4 deletions server/src/features/program-item/programItemUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
unwrapResult,
} from "shared/utils/result";
import { MongoDbError } from "shared/types/api/errors";
import { tooEearlyForAlgorithmSignup } from "shared/utils/tooEearlyForAlgorithmSignup";
import { tooEarlyForLotterySignup } from "shared/utils/tooEarlyForLotterySignup";
import { UserGroup } from "shared/types/models/user";

export const removeDeletedProgramItems = async (
Expand Down Expand Up @@ -136,15 +136,15 @@ const getSignupStrategyForProgramItem = (
const start = dayjs(programItem.startTime);
const { directSignupPhaseStart, twoPhaseSignupProgramTypes } = config.event();

if (settings.signupStrategy !== SignupStrategy.ALGORITHM_AND_DIRECT) {
if (settings.signupStrategy !== SignupStrategy.LOTTERY_AND_DIRECT) {
return settings.signupStrategy;
}

if (!twoPhaseSignupProgramTypes.includes(programItem.programType)) {
return SignupStrategy.DIRECT;
}

if (tooEearlyForAlgorithmSignup(programItem.startTime)) {
if (tooEarlyForLotterySignup(programItem.startTime)) {
return SignupStrategy.DIRECT;
}

Expand All @@ -155,7 +155,7 @@ const getSignupStrategyForProgramItem = (
return SignupStrategy.DIRECT;
}

return SignupStrategy.ALGORITHM;
return SignupStrategy.LOTTERY;
};

const getDirectSignupsForProgramItem = (
Expand Down
3 changes: 2 additions & 1 deletion server/src/features/results/resultsRepository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { faker } from "@faker-js/faker";
import { ResultsModel } from "server/features/results/resultsSchema";
import { UserAssignmentResult } from "shared/types/models/result";
import { saveResult } from "server/features/results/resultsRepository";
import { AssignmentStrategy } from "shared/config/eventConfigTypes";

beforeEach(async () => {
await mongoose.connect(globalThis.__MONGO_URI__, {
Expand All @@ -18,7 +19,7 @@ afterEach(async () => {
test("should insert new result into collection", async () => {
const signupResultData: UserAssignmentResult[] = [];
const startTime = "2019-07-26T14:00:00.000Z";
const algorithm = "group";
const algorithm = AssignmentStrategy.PADG;
const message = "Test assign result message";

await saveResult(signupResultData, startTime, algorithm, message);
Expand Down
2 changes: 1 addition & 1 deletion server/src/features/settings/settingsController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe(`POST ${ApiEndpoint.SETTINGS}`, () => {
hiddenProgramItems: [],
appOpen: true,
signupQuestions: [testSignupQuestion],
signupStrategy: SignupStrategy.ALGORITHM,
signupStrategy: SignupStrategy.LOTTERY,
programUpdateLastRun: "2023-05-07T07:00:00.000Z",
assignmentLastRun: "2023-05-07T07:00:00.000Z",
latestServerStartTime: "2023-05-07T07:00:00.000Z",
Expand Down
2 changes: 1 addition & 1 deletion shared/config/eventConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const eventConfig: EventConfig = {

hideParticipantListProgramTypes: [ProgramType.FLEAMARKET],

// These program items have their signup always open even if signup mode is set to algorithm
// These program items have their signup always open even if signup mode is set to lottery
directSignupAlwaysOpenIds: [],

// Add these to Konsti under 'other' program type
Expand Down
6 changes: 3 additions & 3 deletions shared/config/eventConfigTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { SignupQuestion } from "shared/types/models/settings";

export enum SignupStrategy {
DIRECT = "direct",
ALGORITHM = "algorithm",
ALGORITHM_AND_DIRECT = "algorithm+direct",
LOTTERY = "lottery",
LOTTERY_AND_DIRECT = "lottery+direct",
}

export enum AssignmentStrategy {
Expand Down Expand Up @@ -49,7 +49,7 @@ export interface EventConfig {
directSignupAlwaysOpenIds: string[];
requireRegistrationCode: boolean;
twoPhaseSignupProgramTypes: ProgramType[];
manualSignupMode: SignupStrategy.ALGORITHM | SignupStrategy.DIRECT | "none";
manualSignupMode: SignupStrategy.LOTTERY | SignupStrategy.DIRECT | "none";
signupOpen: boolean;
resultsVisible: boolean;
addToKonstiOther: string[];
Expand Down
2 changes: 1 addition & 1 deletion shared/config/past-events/hitpoint2023.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const eventConfig: Partial<EventConfig> = {

directSignupWindows: null,

// These program items have their signup always open even if signup mode is set to algorithm
// These program items have their signup always open even if signup mode is set to lottery
directSignupAlwaysOpenIds: [],

// Add these to Konsti under 'other' program type
Expand Down
2 changes: 1 addition & 1 deletion shared/config/past-events/ropecon2023.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const eventConfig: Partial<EventConfig> = {
],
},

// These program items have their signup always open even if signup mode is set to algorithm
// These program items have their signup always open even if signup mode is set to lottery
directSignupAlwaysOpenIds: [],

// Add these to Konsti under 'other' program type
Expand Down
2 changes: 1 addition & 1 deletion shared/config/past-events/ropecon2024.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const eventConfig: Partial<EventConfig> = {

rollingSignupStartProgramTypes: [ProgramType.WORKSHOP, ProgramType.OTHER],

// These program items have their signup always open even if signup mode is set to algorithm
// These program items have their signup always open even if signup mode is set to lottery
directSignupAlwaysOpenIds: [
"pathfinder-society-4-99-blessings-of-the-forest", // Pathfinder Society #4-99 Blessings of the Forest
],
Expand Down
2 changes: 1 addition & 1 deletion shared/config/past-events/solmukohta2024.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const eventConfig: Partial<EventConfig> = {
],
},

// These program items have their signup always open even if signup mode is set to algorithm
// These program items have their signup always open even if signup mode is set to lottery
directSignupAlwaysOpenIds: [],

// Add these to Konsti under 'other' program type
Expand Down
2 changes: 1 addition & 1 deletion shared/config/serverConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const commonConfig = {
enableRemoveOverlapSignups: true,

// Default DB values
defaultSignupStrategy: SignupStrategy.ALGORITHM_AND_DIRECT,
defaultSignupStrategy: SignupStrategy.LOTTERY_AND_DIRECT,
defaultLoginProvider: LoginProvider.LOCAL,

// Event settings
Expand Down
Loading

0 comments on commit 49060b1

Please sign in to comment.