-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #448 from impresso/develop
Release v3.0.4
- Loading branch information
Showing
18 changed files
with
736 additions
and
599 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/schema/schemas/ArticleMatch.json → src/schema/schemas/ContentItemMatch.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/schema/schemas/ArticleRegion.json → src/schema/schemas/ContentItemRegion.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/schema/schemas/ArticleTopic.json → src/schema/schemas/ContentItemTopic.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { ServiceOptions } from '@feathersjs/feathers' | ||
import { createSwaggerServiceOptions } from 'feathers-swagger' | ||
import { ImpressoApplication } from '../../types' | ||
import { docs } from './articles.schema' | ||
|
||
// Initializes the `articles` service on path `/articles` | ||
const createService = require('./articles.class') | ||
const hooks = require('./articles.hooks') | ||
|
||
export default function (app: ImpressoApplication) { | ||
const paginate = app.get('paginate') | ||
|
||
/** | ||
* Even though the service is historically called 'articles' | ||
* it technically deals with content items. We keep the original prefix | ||
* for the internal use (web app), but expose it as 'content-items' for the public API. | ||
*/ | ||
const prefix = app.get('isPublicApi') ? '/content-items' : '/articles' | ||
|
||
const options = { | ||
name: 'articles', | ||
paginate, | ||
app, | ||
} | ||
|
||
const svc = createService(options) | ||
|
||
// Initialize our service with any options it requires | ||
app.use('/content-items', svc, { | ||
events: [], | ||
docs: createSwaggerServiceOptions({ schemas: {}, docs }), | ||
} as ServiceOptions) | ||
|
||
// Get our initialized service so that we can register hooks and filters | ||
const service = app.service('content-items') | ||
|
||
service.hooks(hooks) | ||
|
||
if (!app.get('isPublicApi')) { | ||
// Expose the service as 'articles' for the web app | ||
app.use('/articles', service) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,66 @@ | ||
/* eslint-disable no-unused-vars */ | ||
const debug = require('debug')('impresso/services:search'); | ||
const { NotFound, NotImplemented } = require('@feathersjs/errors'); | ||
const { protobuf } = require('impresso-jscommons'); | ||
const solr = require('../../solr'); | ||
const article = require('../../models/articles.model'); | ||
const debug = require('debug')('impresso/services:search-exporter') | ||
const { NotFound, NotImplemented } = require('@feathersjs/errors') | ||
const { protobuf } = require('impresso-jscommons') | ||
const solr = require('../../solr') | ||
const article = require('../../models/articles.model') | ||
|
||
class Service { | ||
constructor (options) { | ||
this.solr = solr.client(options.app.get('solr'), options.app.get('solrConnectionPool')); | ||
this.name = options.name; | ||
this.options = options || {}; | ||
this.app = options.app; | ||
constructor(options) { | ||
this.solr = solr.client(options.app.get('solr'), options.app.get('solrConnectionPool')) | ||
this.name = options.name | ||
this.options = options || {} | ||
this.app = options.app | ||
debug('Service created') | ||
} | ||
|
||
async create (data, params) { | ||
const client = this.app.get('celeryClient'); | ||
async create(data, params) { | ||
const client = this.app.get('celeryClient') | ||
if (!client) { | ||
return {}; | ||
return {} | ||
} | ||
|
||
const q = params.sanitized.sq; | ||
debug('[create] from solr query:', q, 'filters:', params.sanitized.filters); | ||
const q = params.sanitized.sq | ||
debug('[create] from solr query:', q, 'filters:', params.sanitized.filters) | ||
|
||
const pq = protobuf.searchQuery.serialize({ | ||
filters: params.sanitized.filters, | ||
}); | ||
debug('[create] protobuffered:', pq); | ||
}) | ||
debug('[create] protobuffered:', pq) | ||
|
||
return client.run({ | ||
task: 'impresso.tasks.export_query_as_csv', | ||
args: [ | ||
// user id | ||
params.user.id, | ||
// query | ||
q, | ||
// description | ||
data.sanitized.description || '', | ||
// query_hash | ||
pq, | ||
], | ||
}).catch((err) => { | ||
if (err.result.exc_type === 'DoesNotExist') { | ||
throw new NotFound(err.result.exc_message); | ||
} else if (err.result.exc_type === 'OperationalError') { | ||
// probably db is not availabe | ||
throw new NotImplemented(); | ||
} | ||
console.error(err); | ||
throw new NotImplemented(); | ||
}); | ||
return client | ||
.run({ | ||
task: 'impresso.tasks.export_query_as_csv', | ||
args: [ | ||
// user id | ||
params.user.id, | ||
// query | ||
q, | ||
// description | ||
data.sanitized.description || '', | ||
// query_hash | ||
pq, | ||
], | ||
}) | ||
.then(result => { | ||
debug('[create] result:', result) | ||
return { taskId: result.taskId } | ||
}) | ||
.catch(err => { | ||
if (err.result.exc_type === 'DoesNotExist') { | ||
throw new NotFound(err.result.exc_message) | ||
} else if (err.result.exc_type === 'OperationalError') { | ||
// probably db is not availabe | ||
throw new NotImplemented() | ||
} | ||
console.error(err) | ||
throw new NotImplemented() | ||
}) | ||
} | ||
} | ||
|
||
module.exports = function (options) { | ||
return new Service(options); | ||
}; | ||
return new Service(options) | ||
} | ||
|
||
module.exports.Service = Service; | ||
module.exports.Service = Service |
Oops, something went wrong.