Skip to content

Commit

Permalink
use Instance type and optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasHuber committed Jul 3, 2024
1 parent 2a51248 commit 5745bcd
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/server/src/schema/uuid/abstract-uuid/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
import { createEvent } from '~/schema/events/event'
import { SubjectResolver } from '~/schema/subject/resolvers'
import { decodePath, encodePath } from '~/schema/uuid/alias/utils'
import { Resolvers, QueryUuidArgs, TaxonomyTermType } from '~/types'
import { Instance, Resolvers, QueryUuidArgs, TaxonomyTermType } from '~/types'
import { isDefined } from '~/utils'

export const UuidResolver = createCachedResolver<
Expand Down Expand Up @@ -380,13 +380,16 @@ async function resolveUuidFromDatabase(
: null
const subjectName = subject ? toSlug(subject.name) : 'serlo'

let fallbackTitle: string = baseUuid.entityType
if (baseUuid.entityInstance === 'de') {
if (fallbackTitle === 'text-exercise') fallbackTitle = 'aufgabe'
else if (fallbackTitle === 'text-exercise-group') fallbackTitle = 'aufgabengruppe'
}

const slugTitle = toSlug(baseUuid.entityTitle ?? fallbackTitle)
const slugTitle = baseUuid.entityTitle
? toSlug(baseUuid.entityTitle)
: (() => {
if (baseUuid.entityInstance === Instance.De) {
if (baseUuid.entityType === 'text-exercise') return 'aufgabe'
if (baseUuid.entityType === 'text-exercise-group')
return 'aufgabengruppe'
}
return baseUuid.entityType
})()

const entity = {
...base,
Expand Down

0 comments on commit 5745bcd

Please sign in to comment.