Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change case of AscentType enum keys and values to all lowercase. #176

Merged
merged 2 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 35 additions & 35 deletions src/activities/entities/activity-route.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,57 +15,57 @@ import { Pitch } from '../../crags/entities/pitch.entity';
import { User } from '../../users/entities/user.entity';

export enum AscentType {
ONSIGHT = 'onsight',
FLASH = 'flash',
REDPOINT = 'redpoint',
REPEAT = 'repeat',
ALLFREE = 'allfree',
AID = 'aid',
ATTEMPT = 'attempt',
T_ONSIGHT = 't_onsight',
T_FLASH = 't_flash',
T_REDPOINT = 't_redpoint',
T_REPEAT = 't_repeat',
T_ALLFREE = 't_allfree',
T_AID = 't_aid',
T_ATTEMPT = 't_attempt',
TICK = 'tick',
onsight = 'onsight',
flash = 'flash',
redpoint = 'redpoint',
repeat = 'repeat',
allfree = 'allfree',
aid = 'aid',
attempt = 'attempt',
t_onsight = 't_onsight',
t_flash = 't_flash',
t_redpoint = 't_redpoint',
t_repeat = 't_repeat',
t_allfree = 't_allfree',
t_aid = 't_aid',
t_attempt = 't_attempt',
tick = 'tick',
}
registerEnumType(AscentType, {
name: 'AscentType',
});

export const tickAscentTypes = new Set([
AscentType.ONSIGHT,
AscentType.FLASH,
AscentType.REDPOINT,
AscentType.REPEAT,
AscentType.onsight,
AscentType.flash,
AscentType.redpoint,
AscentType.repeat,
]);

export const firstTickAscentTypes = new Set([
AscentType.ONSIGHT,
AscentType.FLASH,
AscentType.REDPOINT,
AscentType.onsight,
AscentType.flash,
AscentType.redpoint,
]);

export const trTickAscentTypes = new Set([
AscentType.T_ONSIGHT,
AscentType.T_FLASH,
AscentType.T_REDPOINT,
AscentType.T_REPEAT,
AscentType.t_onsight,
AscentType.t_flash,
AscentType.t_redpoint,
AscentType.t_repeat,
]);

export const firstTrTickAscentTypes = new Set([
AscentType.T_ONSIGHT,
AscentType.T_FLASH,
AscentType.T_REDPOINT,
AscentType.t_onsight,
AscentType.t_flash,
AscentType.t_redpoint,
]);

export enum PublishType {
PUBLIC = 'public',
CLUB = 'club',
LOG = 'log',
PRIVATE = 'private',
public = 'public',
club = 'club',
log = 'log',
private = 'private',
}
registerEnumType(PublishType, {
name: 'PublishType',
Expand Down Expand Up @@ -115,15 +115,15 @@ export class ActivityRoute extends BaseEntity {
@Column({
type: 'enum',
enum: AscentType,
default: AscentType.REDPOINT,
default: AscentType.redpoint,
})
@Field((type) => AscentType)
ascentType: AscentType;

@Column({
type: 'enum',
enum: PublishType,
default: PublishType.PRIVATE,
default: PublishType.private,
})
@Field((type) => PublishType)
publish: PublishType;
Expand Down
22 changes: 11 additions & 11 deletions src/activities/services/activity-routes.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,46 +247,46 @@ export class ActivityRoutesService {
// boulders cannot be onsighted at all
if (routeTypeId === 'boulder') {
if (
ascentType === AscentType.ONSIGHT ||
ascentType === AscentType.T_ONSIGHT
ascentType === AscentType.onsight ||
ascentType === AscentType.t_onsight
)
return false;
}

// already tried routes cannot be onsighted or flashed
if (routeTried) {
if (
ascentType === AscentType.ONSIGHT ||
ascentType === AscentType.T_ONSIGHT ||
ascentType === AscentType.FLASH ||
ascentType === AscentType.T_FLASH
ascentType === AscentType.onsight ||
ascentType === AscentType.t_onsight ||
ascentType === AscentType.flash ||
ascentType === AscentType.t_flash
)
return false;
}

// already ticked routes cannot be redpointed (flash, sight included above)
if (routeTicked) {
if (
ascentType === AscentType.REDPOINT ||
ascentType === AscentType.T_REDPOINT
ascentType === AscentType.redpoint ||
ascentType === AscentType.t_redpoint
)
return false;
}

// routes one already 'ticked' on toprope cannot be tr redpointed
if (routeTrTicked) {
if (ascentType === AscentType.T_REDPOINT) {
if (ascentType === AscentType.t_redpoint) {
return false;
}
}

// routes not ticked before cannot be repeated
if (ascentType === AscentType.REPEAT && !routeTicked) {
if (ascentType === AscentType.repeat && !routeTicked) {
return false;
}

// routes not ticked (real or tr) before cannot be toprope repeated
if (ascentType === AscentType.T_REPEAT && !(routeTicked || routeTrTicked)) {
if (ascentType === AscentType.t_repeat && !(routeTicked || routeTrTicked)) {
return false;
}

Expand Down
32 changes: 16 additions & 16 deletions src/crags/entities/crag.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,34 @@ export enum CragType {
}

export enum Orientation {
NORTH = 'north',
NORTHEAST = 'northeast',
EAST = 'east',
SOUTHEAST = 'southeast',
SOUTH = 'south',
SOUTHWEST = 'southwest',
WEST = 'west',
NORTHWEST = 'northwest',
north = 'north',
northeast = 'northeast',
east = 'east',
southeast = 'southeast',
south = 'south',
southwest = 'southwest',
west = 'west',
northwest = 'northwest',
}
registerEnumType(Orientation, {
name: 'Orientation',
});

export enum WallAngle {
SLAB = 'slab',
VERTICAL = 'vertical',
OVERHANG = 'overhang',
ROOF = 'roof',
slab = 'slab',
vertical = 'vertical',
overhang = 'overhang',
roof = 'roof',
}
registerEnumType(WallAngle, {
name: 'WallAngle',
});

export enum Season {
SPRING = 'spring',
SUMMER = 'summer',
AUTUMN = 'autumn',
WINTER = 'winter',
spring = 'spring',
summer = 'summer',
autumn = 'autumn',
winter = 'winter',
}
registerEnumType(Season, {
name: 'Season',
Expand Down
30 changes: 15 additions & 15 deletions src/crags/utils/calculate-scores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,35 +50,35 @@ function calculateScore(
const scoreTypeFactor = scoreType === 'order' ? 1 : 0;

switch (ascentType) {
case AscentType.ONSIGHT:
case AscentType.onsight:
return difficulty + 100;
case AscentType.FLASH:
case AscentType.flash:
return difficulty + 50;
case AscentType.REDPOINT:
case AscentType.redpoint:
return difficulty;
case AscentType.REPEAT:
case AscentType.repeat:
return (difficulty - 10) * scoreTypeFactor;
case AscentType.ALLFREE:
case AscentType.allfree:
return difficulty * 0.01 * scoreTypeFactor;
case AscentType.AID:
case AscentType.aid:
return difficulty * 0.001 * scoreTypeFactor;
case AscentType.ATTEMPT:
case AscentType.attempt:
return difficulty * 0.0001 * scoreTypeFactor;
case AscentType.T_ONSIGHT:
case AscentType.t_onsight:
return (difficulty + 100) * 0.0001 * scoreTypeFactor;
case AscentType.T_FLASH:
case AscentType.t_flash:
return (difficulty + 50) * 0.0001 * scoreTypeFactor;
case AscentType.T_REDPOINT:
case AscentType.t_redpoint:
return difficulty * 0.0001 * scoreTypeFactor;
case AscentType.T_REPEAT:
case AscentType.t_repeat:
return (difficulty - 10) * 0.0001 * scoreTypeFactor;
case AscentType.T_ALLFREE:
case AscentType.t_allfree:
return difficulty * 0.01 * 0.0001 * scoreTypeFactor;
case AscentType.T_AID:
case AscentType.t_aid:
return difficulty * 0.001 * 0.0001 * scoreTypeFactor;
case AscentType.T_ATTEMPT:
case AscentType.t_attempt:
return difficulty * 0.0001 * 0.0001 * scoreTypeFactor;
case AscentType.TICK:
case AscentType.tick:
// TODO: what is TICK ascent type, and is it even used?? prob not, 1 ar in db... suggest removal, discuss
return 0;
}
Expand Down
12 changes: 6 additions & 6 deletions src/crags/utils/convert-ascents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function convertFirstTickAfterToRepeat(
);

// Convert it to repeat
futureTick.ascentType = AscentType.REPEAT;
futureTick.ascentType = AscentType.repeat;
await queryRunner.manager.save(futureTick);
sideEffects.push({ before: futureTickBeforeChange, after: futureTick });
}
Expand Down Expand Up @@ -86,7 +86,7 @@ async function convertFirstTrTickAfterToTrRepeat(
);

// Convert it to toprope repeat
futureTrTick.ascentType = AscentType.T_REPEAT;
futureTrTick.ascentType = AscentType.t_repeat;
await queryRunner.manager.save(futureTrTick);
sideEffects.push({
before: futureTrTickBeforeChange,
Expand All @@ -110,7 +110,7 @@ async function convertFirstSightOrFlashAfterToRedpoint(
.where('ar.route_id = :routeId', { routeId: routeId })
.andWhere('ar.user_id = :userId', { userId: userId })
.andWhere('ar.ascent_type IN (:...aTypes)', {
aTypes: [AscentType.ONSIGHT, AscentType.FLASH],
aTypes: [AscentType.onsight, AscentType.flash],
})
.andWhere('ar.date > :arDate', { arDate: date })
.getOne(); // If data is valid there can only be one such ascent logged (or none)
Expand All @@ -126,7 +126,7 @@ async function convertFirstSightOrFlashAfterToRedpoint(
);

// Convert it to redpoint
futureSightOrFlash.ascentType = AscentType.REDPOINT;
futureSightOrFlash.ascentType = AscentType.redpoint;
await queryRunner.manager.save(futureSightOrFlash);
sideEffects.push({
before: futureSightOrFlashBeforeChange,
Expand All @@ -150,7 +150,7 @@ async function convertFirstTrSightOrFlashAfterToTrRedpoint(
.where('ar.route_id = :routeId', { routeId: routeId })
.andWhere('ar.user_id = :userId', { userId: userId })
.andWhere('ar.ascent_type IN (:...aTypes)', {
aTypes: [AscentType.T_ONSIGHT, AscentType.T_FLASH],
aTypes: [AscentType.t_onsight, AscentType.t_flash],
})
.andWhere('ar.date > :arDate', { arDate: date })
.getOne(); // If data is valid there can only be one such ascent logged (or none)
Expand All @@ -166,7 +166,7 @@ async function convertFirstTrSightOrFlashAfterToTrRedpoint(
);

// Convert it to toprope redpoint
futureTrSightOrFlash.ascentType = AscentType.T_REDPOINT;
futureTrSightOrFlash.ascentType = AscentType.t_redpoint;
await queryRunner.manager.save(futureTrSightOrFlash);
sideEffects.push({
before: futureTrSightOrFlashBeforeChange,
Expand Down
Loading
Loading