Skip to content

Commit

Permalink
refactor-TextSearchResource (#446)
Browse files Browse the repository at this point in the history
* refactor-TextSearchResource

* Remove obsolete snapshot

* Delete ChapterLink and Pagination to refactor

---------

Co-authored-by: fsimonjetz <[email protected]>
  • Loading branch information
kartikpaliwal and fsimonjetz authored Feb 22, 2024
1 parent 75e699b commit a749ede
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 1,119 deletions.
70 changes: 1 addition & 69 deletions src/corpus/application/TextService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { fragment, fragmentDto, lines } from 'test-support/test-fragment'
import BibliographyService from 'bibliography/application/BibliographyService'
import { ExtantLines } from 'corpus/domain/extant-lines'
import { ChapterDisplay } from 'corpus/domain/chapter'
import textLineFixture, { textLineDto } from 'test-support/lines/text-line'
import { chapterDisplayDtoFactory } from 'test-support/chapter-fixtures'
import {
bibliographyEntryFactory,
Expand Down Expand Up @@ -202,40 +201,6 @@ const manuscriptsDto = {

const textsDto = [textDto]

const matchingLine = {
...chapterDto.lines[0],
translation: [
{
language: 'de',
extent: null,
parts: [
{
text: 'Test text',
type: 'StringPart',
},
],
content: [],
},
],
}

const chapterInfoDto = {
id: {
textId: {
genre: 'L',
category: 1,
index: 2,
},
stage: 'Old Babyblonian',
name: 'My Chapter',
},
siglums: { '1': 'NinSchb' },
matchingLines: [matchingLine],
matchingColophonLines: {
'1': [textLineDto],
},
}

const extantLines: ExtantLines = {
NinNA1a: {
o: [
Expand Down Expand Up @@ -457,40 +422,7 @@ const testData: TestData<TextService>[] = [
[`${chapterUrl}/manuscripts`, false],
Bluebird.resolve(chapterDto.manuscripts)
),
new TestData(
'searchTransliteration',
['kur', 0],
apiClient.fetchJson,
{
chapterInfos: [
{
...chapterInfoDto,
matchingLines: [
{
...chapter.lines[0],
translation: [
new TranslationLine({
language: 'de',
extent: null,
parts: [
{
text: 'Test text',
type: 'StringPart',
},
],
content: [],
}),
],
},
],
matchingColophonLines: { '1': [textLineFixture] },
},
],
totalCount: 1,
},
['/textsearch?paginationIndex=0&transliteration=kur', false],
Bluebird.resolve({ chapterInfos: [chapterInfoDto], totalCount: 1 })
),

new TestData(
'updateAlignment',
[chapterId, chapter.alignment],
Expand Down
27 changes: 0 additions & 27 deletions src/corpus/application/TextService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ import {
fromDto,
fromLineDetailsDto,
fromManuscriptDto,
fromMatchingColophonLinesDto,
fromMatchingLineDto,
fromSiglumAndTransliterationDto,
LineVariantDisplayDto,
toAlignmentDto,
Expand All @@ -54,7 +52,6 @@ import TranslationLine from 'transliteration/domain/translation-line'
import { NoteLine, NoteLineDto } from 'transliteration/domain/note-line'
import { fromTransliterationLineDto } from 'transliteration/application/dtos'
import { ParallelLine } from 'transliteration/domain/parallel-line'
import ChapterInfosPagination from 'corpus/domain/ChapterInfosPagination'
import { CorpusQuery } from 'query/CorpusQuery'
import { CorpusQueryResult } from 'query/QueryResult'
import { ChapterSlugs, TextSlugs } from 'router/sitemap'
Expand Down Expand Up @@ -369,30 +366,6 @@ export default class TextService {
.then((dtos) => dtos.map(fromDto))
}

searchTransliteration(
transliteration: string,
paginationIndex: number
): Bluebird<ChapterInfosPagination> {
return this.apiClient
.fetchJson(
`/textsearch?${stringify({
transliteration: transliteration,
paginationIndex: paginationIndex,
})}`,
false
)
.then((result) => {
const chapterInfos = result.chapterInfos.map((dto) => ({
...dto,
matchingLines: dto.matchingLines.map(fromMatchingLineDto),
matchingColophonLines: fromMatchingColophonLinesDto(
dto.matchingColophonLines
),
}))
return { chapterInfos: chapterInfos, totalCount: result.totalCount }
})
}

searchLemma(
lemmaId: string,
genre: string | null | undefined = null
Expand Down
21 changes: 0 additions & 21 deletions src/corpus/ui/ChapterLink.tsx

This file was deleted.

Loading

0 comments on commit a749ede

Please sign in to comment.