Skip to content

Commit

Permalink
Refactor Museum type and repetitions
Browse files Browse the repository at this point in the history
  • Loading branch information
kartikpaliwal committed Feb 20, 2024
1 parent 7116a3b commit f7df1c9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/fragmentarium/domain/Fragment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ import {
year2017,
year2018,
} from 'test-support/record-fixtures'
import { Museums, MuseumKey } from './museum'
import { Museums } from './museum'
import { LooseDollarLine } from 'transliteration/domain/dollar-lines'
import { Genres } from 'fragmentarium/domain/Genres'
import Reference from 'bibliography/domain/Reference'
import BibliographyEntry from 'bibliography/domain/BibliographyEntry'
import { PeriodModifiers, Periods } from 'common/period'
const museumKey: MuseumKey = 'THE_BRITISH_MUSEUM'
const museumData = Museums[museumKey]

const config: Parameters<typeof Fragment['create']>[0] = {
number: 'K.1',
accession: '1',
Expand Down Expand Up @@ -85,7 +84,7 @@ const config: Parameters<typeof Fragment['create']>[0] = {
text: 'Some notes',
parts: [{ text: 'Some notes', type: 'StringPart' }],
},
museum: museumData,
museum: Museums['THE_BRITISH_MUSEUM'],
references: [
new Reference(
'DISCUSSION',
Expand Down
3 changes: 1 addition & 2 deletions src/fragmentarium/domain/museum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ export const Museums = {
},
} as const

export type Museum = typeof Museums[keyof typeof Museums]
export type MuseumKey = keyof typeof Museums

export interface FragmentLink {
Expand All @@ -220,7 +219,7 @@ export interface FragmentLink {
readonly url: string
}

export interface MuseumData {
export interface Museum {
readonly name: string
readonly city: string
readonly country: string
Expand Down
3 changes: 1 addition & 2 deletions src/fragmentarium/infrastructure/FragmentRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,11 @@ export function createJoins(joins): Joins {

function createFragment(dto: FragmentDto): Fragment {
const museumKey: MuseumKey = dto.museum
const museumData = Museums[museumKey]
return Fragment.create({
...dto,
number: museumNumberToString(dto.museumNumber),
accession: dto.accession ? museumNumberToString(dto.accession) : '',
museum: museumData,
museum: Museums[museumKey],
joins: createJoins(dto.joins),
measures: {
length: dto.length.value || null,
Expand Down

0 comments on commit f7df1c9

Please sign in to comment.