File tree Expand file tree Collapse file tree 3 files changed +15
-11
lines changed
repo/eventsRepo/emitNewStatements Expand file tree Collapse file tree 3 files changed +15
-11
lines changed Original file line number Diff line number Diff line change 11import Member from 'jscommons/dist/utils/Member' ;
22
33export interface Opts {
4- readonly ids : string [ ] ;
4+ readonly statementProperties : string [ ] ;
55}
66
77type Signature = Member < Opts , void > ;
Original file line number Diff line number Diff line change @@ -5,11 +5,11 @@ const EVENT_NAME = 'statement.new';
55const CHANNEL_NAME = 'statement.notify' ;
66
77export default ( config : FacadeConfig ) : Signature => {
8- return async ( { ids } ) => {
8+ return async ( { statementProperties } ) => {
99 const client = await config . client ( ) ;
1010 const listName = `${ config . prefix } :${ EVENT_NAME } ` ;
1111 const channelName = `${ config . prefix } :${ CHANNEL_NAME } ` ;
12- await client . rpush ( listName , ...ids ) ;
12+ await client . rpush ( listName , ...statementProperties ) ;
1313 client . publish ( channelName , '' ) ;
1414 } ;
1515} ;
Original file line number Diff line number Diff line change @@ -54,9 +54,12 @@ export default (config: Config) => {
5454 return postValidatedModel . statement . id ;
5555 } ) ;
5656
57- const unstoredStatementIds = unstoredModels . map ( ( unstoredModel ) => {
58- return unstoredModel . statement . id ;
59- } ) ;
57+ const unstoredStatementProperties = unstoredModels . map (
58+ ( unstoredModel ) => JSON . stringify ( {
59+ statementId : unstoredModel . statement . id ,
60+ organisationId : unstoredModel . organisation ,
61+ } ) ,
62+ ) ;
6063
6164 // Completes actions that do not need to be awaited.
6265 const unawaitedUpdates : Promise < any > = Promise . all ( [
@@ -71,11 +74,12 @@ export default (config: Config) => {
7174 } ) ;
7275
7376 await awaitUpdates ( config , unawaitedUpdates ) ;
74- if ( unstoredStatementIds . length !== 0 ) {
75- config . repo . emitNewStatements ( { ids : unstoredStatementIds } ) . catch ( ( err ) => {
76- /* istanbul ignore next */
77- console . error ( err ) ; // tslint:disable-line:no-console
78- } ) ;
77+ if ( unstoredStatementProperties . length !== 0 ) {
78+ config . repo . emitNewStatements ( { statementProperties : unstoredStatementProperties } )
79+ . catch ( ( err ) => {
80+ /* istanbul ignore next */
81+ console . error ( err ) ; // tslint:disable-line:no-console
82+ } ) ;
7983 }
8084
8185 const tracker = await config . tracker ;
You can’t perform that action at this time.
0 commit comments