Skip to content

Commit

Permalink
cleanup in config, return no suggested articles when no topics
Browse files Browse the repository at this point in the history
  • Loading branch information
theorm committed Jan 16, 2025
1 parent 7e404d6 commit 186eb62
Show file tree
Hide file tree
Showing 18 changed files with 315 additions and 1,164 deletions.
8 changes: 0 additions & 8 deletions config/default.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@
"secure": false
}
},
"neo4j": {
"host": "bolt://localhost:7687",
"project": "projectname",
"auth": {
"user": "neo4j",
"pass": "neo4j"
}
},
"proxy": {
"host": "http://localhost:3030",
"iiif": {
Expand Down
8 changes: 0 additions & 8 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@
"secure": true
}
},
"neo4j": {
"host": "bolt://localhost:7687",
"project": "impresso",
"auth": {
"user": "neo4j",
"pass": "neo4j"
}
},
"media": {
"host": "http://localhost:3030",
"path": "/media",
Expand Down
181 changes: 0 additions & 181 deletions src/cachedSolr.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { RedisClientOptions } from 'redis'
import { AuthenticationConfiguration } from '@feathersjs/authentication'
import { Sequelize } from 'sequelize'
import { CeleryClient } from './celery'
import type { CeleryConfig, Config, RedisConfig, SocksProxyConfig } from './models/generated/common'
import type { CeleryConfig, Config, RedisConfig, SolrServerProxy } from './models/generated/common'
import { ImpressoApplication } from './types'

const ajv = new Ajv()
Expand All @@ -15,7 +15,7 @@ ajv.addSchema(require('./schema/common/solrConfiguration.json'), 'solrConfigurat

type RedisConfiguration = RedisConfig & RedisClientOptions

export type { CeleryConfig, RedisConfiguration, SocksProxyConfig }
export type { CeleryConfig, RedisConfiguration, SolrServerProxy }

export interface LocalAuthenticationConfiguration extends AuthenticationConfiguration {
jwtOptions: {
Expand Down
14 changes: 7 additions & 7 deletions src/httpConnectionPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { request, RequestInfo, RequestInit, Dispatcher, Agent, RetryAgent, Retry
import { socksDispatcher, SocksProxies } from 'fetch-socks'
import { createPool, Factory, Pool } from 'generic-pool'
import { IncomingHttpHeaders } from 'undici/types/header'
import { SocksProxyConfig } from './configuration'
import { SolrServerProxy } from './configuration'

export { RequestInfo, RequestInit, Headers }

Expand Down Expand Up @@ -77,17 +77,17 @@ export class Response implements IResponse {
* because functions are sometimes not recognised by the pool.
*/
class ConnectionWrapper implements IConnectionWrapper {
socksProxyOptions?: SocksProxyConfig
socksProxyOptions?: SolrServerProxy

constructor(socksProxyOptions?: SocksProxyConfig) {
constructor(socksProxyOptions?: SolrServerProxy) {
this.socksProxyOptions = socksProxyOptions
}

_createBaseAgent(): Agent {
if (this.socksProxyOptions != null) {
const proxyConfig: SocksProxies = [
{
type: this.socksProxyOptions.type ?? 5,
type: 5,
host: this.socksProxyOptions.host,
port: this.socksProxyOptions.port,
},
Expand Down Expand Up @@ -138,9 +138,9 @@ class ConnectionWrapper implements IConnectionWrapper {
}

class ConnectionFactory implements Factory<IConnectionWrapper> {
socksProxyOptions?: SocksProxyConfig
socksProxyOptions?: SolrServerProxy

constructor(socksProxyOptions?: SocksProxyConfig) {
constructor(socksProxyOptions?: SolrServerProxy) {
this.socksProxyOptions = socksProxyOptions
}

Expand All @@ -156,7 +156,7 @@ class ConnectionFactory implements Factory<IConnectionWrapper> {
export interface InitHttpPoolOptions {
maxParallelConnections?: number
acquireTimeoutSec?: number
socksProxy?: SocksProxyConfig
socksProxy?: SolrServerProxy
}

export function initHttpPool({
Expand Down
5 changes: 3 additions & 2 deletions src/internalServices/simpleSolr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ class CachedDefaultSimpleSolrClient extends DefaultSimpleSolrClient {
constructor(
configuration: SolrConfiguration,
private cache: Cache,
private cachingStrategy?: CachingStrategy
private cachingStrategy?: CachingStrategy,
private cacheTtlSeconds = 60 * 60 * 24 * 30 // 30 days
) {
super(configuration)
}
Expand All @@ -317,7 +318,7 @@ class CachedDefaultSimpleSolrClient extends DefaultSimpleSolrClient {
const action = this.cachingStrategy?.(url, init.body as string, safeStringifyJson(response)) ?? 'cache'

if (action === 'cache') {
await this.cache.set(cacheKey, response)
await this.cache.set(cacheKey, response, this.cacheTtlSeconds)
}
return response
}
Expand Down
2 changes: 1 addition & 1 deletion src/jobs/updateMediaSourcesCache.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { consolidateMediaSources } from '../useCases/consolidateMediaSources'
import { WellKnownKeys } from '../cache'
import { ImpressoApplication } from '../types'
import { getSolrIndex, SolrNamespaces } from '../solr'
import { SolrNamespaces } from '../solr'

/**
* Consolidate media sources and store them in cache.
Expand Down
Loading

0 comments on commit 186eb62

Please sign in to comment.