Skip to content

Commit

Permalink
fix: make casing consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
ssilve1989 committed Mar 31, 2024
1 parent c84557a commit 4dde71f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
4 changes: 1 addition & 3 deletions src/commands/signup/signup-interaction.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { capitalCase } from 'change-case';
import { IsEnum, IsString, IsUrl, ValidateIf } from 'class-validator';
import { ToCasing } from '../../common/decorators/to-casing.js';
import { ToLowercase } from '../../common/decorators/to-lowercase.js';
import { TransformUrl } from '../../common/decorators/transform-url.js';
import { Encounter } from '../../encounters/encounters.consts.js';
Expand All @@ -13,7 +11,7 @@ class SignupInteractionDto
availability: string;

@IsString()
@ToCasing(capitalCase)
@ToLowercase()
character: string;

@IsString()
Expand Down
2 changes: 1 addition & 1 deletion src/common/decorators/to-casing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ type CaseTransformer = (value: string) => string;
* @returns
*/
export const ToCasing = (fn: CaseTransformer) =>
Transform(({ value }) => fn(value));
Transform(({ value }) => value && fn(value));

Check warning on line 12 in src/common/decorators/to-casing.ts

View check run for this annotation

Codecov / codecov/patch

src/common/decorators/to-casing.ts#L12

Added line #L12 was not covered by tests
25 changes: 15 additions & 10 deletions src/sheets/sheets.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { sheets_v4 } from '@googleapis/sheets';
import { Inject, Injectable, Logger } from '@nestjs/common';
import { ConfigType } from '@nestjs/config';
import * as Sentry from '@sentry/node';
import { capitalCase } from 'change-case';
import { AsyncQueue } from '../common/async-queue/async-queue.js';
import { PartyType, SignupDocument } from '../firebase/models/signup.model.js';
import { SignupCompositeKeyProps } from '../firebase/models/signup.model.js';
Expand Down Expand Up @@ -212,17 +213,12 @@ class SheetsService {
// }

private async upsertClearParty(
{
encounter,
character,
role,
world,
discordId,
progPoint = '',
}: Omit<SignupDocument, 'partyType'>,
signup: Omit<SignupDocument, 'partyType'>,
spreadsheetId: string,
) {
const cellValues = [character, world, role, progPoint];
const { encounter, character, world, discordId } = signup;
const cellValues = this.getCellValues(signup);

Check warning on line 220 in src/sheets/sheets.service.ts

View check run for this annotation

Codecov / codecov/patch

src/sheets/sheets.service.ts#L219-L220

Added lines #L219 - L220 were not covered by tests

const { SHEET_EARLY_PROG_NAME, SHEET_PROG_NAME } = this.config;
// need to check if we should remove prior signups from either earlyprog or mid prog sheet
const requests = [];
Expand Down Expand Up @@ -307,7 +303,7 @@ class SheetsService {
// with how the prog sheet is setup visually with multiple column groups spanning different row lengths
const rowOffset = values ? values.length + 1 : PROG_SHEET_STARTING_ROW;

const cellValues = [character, world, role, progPoint];
const cellValues = this.getCellValues(signup);

Check warning on line 306 in src/sheets/sheets.service.ts

View check run for this annotation

Codecov / codecov/patch

src/sheets/sheets.service.ts#L306

Added line #L306 was not covered by tests

const updateRange =
row === -1
Expand Down Expand Up @@ -421,6 +417,15 @@ class SheetsService {

return sheetId;
}

private getCellValues({
character,
world,
role,
progPoint = '',
}: SignupDocument) {
return [capitalCase(character), capitalCase(world), role, progPoint];

Check warning on line 427 in src/sheets/sheets.service.ts

View check run for this annotation

Codecov / codecov/patch

src/sheets/sheets.service.ts#L425-L427

Added lines #L425 - L427 were not covered by tests
}
}

export { SheetsService };

0 comments on commit 4dde71f

Please sign in to comment.