Skip to content

Commit

Permalink
removed newspaper from search facet bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
theorm committed Dec 26, 2024
1 parent 076c245 commit 1e49b3e
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions src/models/search-facets.model.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
const Topic = require('./topics.model')
const Year = require('./years.model')
const Newspaper = require('./newspapers.model')
const Entity = require('./entities.model')
const Collection = require('./collections.model')

const FACET_TYPES_WITH_ITEMS = [
'newspaper',
'language',
'topic',
'person',
'location',
'collection',
'year',
]
const FACET_TYPES_WITH_ITEMS = ['newspaper', 'language', 'topic', 'person', 'location', 'collection', 'year']

const FACET_TYPES_WITH_CACHED_ITEMS = {
newspaper: Newspaper,
topic: Topic,
year: Year,
}

class SearchFacetBucket {
constructor ({ type = 'facet', val = '', count = -1 } = {}) {
constructor({ type = 'facet', val = '', count = -1 } = {}) {
this.count = parseInt(count, 10)
this.val = String(val)

Expand All @@ -46,7 +37,7 @@ class SearchFacetBucket {
}

class SearchFacetRangeBucket {
constructor ({ val = undefined, count = -1, min = 0, max = 0, gap = 0 } = {}) {
constructor({ val = undefined, count = -1, min = 0, max = 0, gap = 0 } = {}) {
this.val = val
this.count = parseInt(count, 10)
// if value is integer and gap is 1, then it's a single value
Expand All @@ -61,7 +52,7 @@ class SearchFacetRangeBucket {
}

class SearchFacet {
constructor ({
constructor({
type = 'facet',
buckets = [],
numBuckets = -1,
Expand All @@ -72,14 +63,14 @@ class SearchFacet {
this.type = type
this.numBuckets = parseInt(numBuckets, 10)
this.buckets = gap
? buckets.map((d) => new SearchFacetRangeBucket({ ...d, min, max, gap }))
: buckets.map((d) => new SearchFacetBucket({ type, ...d }))
? buckets.map(d => new SearchFacetRangeBucket({ ...d, min, max, gap }))
: buckets.map(d => new SearchFacetBucket({ type, ...d }))
this.min = min
this.max = max
this.gap = gap
}

getItems () {
getItems() {
return this.buckets.map(({ item, count }) => ({
...item,
count,
Expand Down

0 comments on commit 1e49b3e

Please sign in to comment.