Skip to content

Commit

Permalink
feat: update dump, remove log and fix filter
Browse files Browse the repository at this point in the history
  • Loading branch information
f-necas committed Dec 7, 2023
1 parent f909efc commit ed85f75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions libs/feature/search/src/lib/utils/service/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/reposit
import { ElasticsearchService } from '@geonetwork-ui/api/repository/gn4'
import { LangService } from '@geonetwork-ui/util/i18n'
import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface'
import { coerce, valid } from 'semver'

export type FieldValue = string | number
export interface FieldAvailableValue {
Expand Down Expand Up @@ -87,8 +86,11 @@ export class SimpleSearchField implements AbstractSearchField {
})
}

getValuesForFilter(filters: FieldFilters): Observable<FieldValue[]> {
const filter = filters[this.esFieldName]
getValuesForFilter(
filters: FieldFilters,
esFieldName: string = this.esFieldName
): Observable<FieldValue[]> {
const filter = filters[esFieldName]
if (!filter) return of([])
const values =
typeof filter === 'string'
Expand Down Expand Up @@ -397,14 +399,13 @@ export class ContactField extends SimpleSearchField {
private langService = this.injector.get(LangService)
private platformService = this.injector.get(PlatformServiceInterface)
public esFieldName: string
private esResearchName: string
private version: Observable<string> = this.platformService
.getApiVersion()
.pipe(map((version) => version))

constructor(public order: 'asc' | 'desc' = 'asc', public injector: Injector) {
super('OrgForResource', order, injector)
this.esFieldName = 'contactForResource.organisationObject.default.keyword'
this.esFieldName = 'OrgForResourceObject.default'
}

getFiltersForValues(values: FieldValue[]): Observable<FieldFilters> {
Expand All @@ -421,23 +422,11 @@ export class ContactField extends SimpleSearchField {
switchMap((version) =>
version == '4.2.2'
? super.getValuesForFilter(filters)
: this.tmpFunction(filters)
: super.getValuesForFilter(filters, this.esFieldName)
)
)
}

tmpFunction(filters: FieldFilters) {
const filter = filters[this.esFieldName]
console.log(filters)
if (!filter) return of([])
const values =
typeof filter === 'string'
? [filter]
: Object.keys(filter).filter((v) => filter[v])
console.log(values)
return of(values)
}

getTranslatedAggregations() {
return this.searchApiService
.search(
Expand Down Expand Up @@ -484,7 +473,7 @@ export class ContactField extends SimpleSearchField {
return this.version.pipe(
switchMap((version) =>
version == '4.2.2'
? super.getAvailableValues() //TODO copy from simplesearch field
? super.getAvailableValues()
: this.getTranslatedAggregations().pipe(
map((response) =>
response.map((tmp) => {
Expand Down
Binary file modified support-services/docker-entrypoint-initdb.d/dump
Binary file not shown.

0 comments on commit ed85f75

Please sign in to comment.