All files / server/src/features/assignment/utils getDynamicStartTime.ts

87.5% Statements 7/8
50% Branches 1/2
100% Functions 1/1
87.5% Lines 7/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26            43x     3x   3x 3x       3x         3x   3x    
import { config } from "shared/config";
import { getTimeNow } from "server/features/assignment/utils/getTimeNow";
import { logger } from "server/utils/logger";
import { Result, makeSuccessResult } from "shared/utils/result";
import { MongoDbError } from "shared/types/api/errors";
 
export const getDynamicStartTime = async (): Promise<
  Result<string, MongoDbError>
> => {
  const { directSignupPhaseStart } = config.event();
 
  const timeNowResult = await getTimeNow();
  Iif (!timeNowResult.ok) {
    return timeNowResult;
  }
 
  const dynamicStartTime = timeNowResult.value
    .startOf("minute")
    .add(directSignupPhaseStart, "minutes")
    .toISOString();
 
  logger.info(`Using dynamic start time: ${dynamicStartTime}`);
 
  return makeSuccessResult(dynamicStartTime);
};