@@ -31,9 +31,10 @@ export default async (data) => {
31
31
const update = [ ] ;
32
32
await Promise . all ( data . map ( async ( d ) => {
33
33
const period = parseInt ( d . period , 10 ) ;
34
- const { type, countBefore, changedIds } = d . types . find ( t => t . type === 'Gesetzgebung' ) ;
34
+ const { type, countBefore, changedIds } = d . types . find ( t => t . type === 'Gesetzgebung' || t . type === 'Antrag' ) ;
35
35
const group = groups . find ( c => c . period === period ) ;
36
- const localCount = group ? group . types . find ( ct => ct . type === type ) . count : 0 ;
36
+ const localGroup = group ? group . types . find ( ct => ct . type === type ) : null ;
37
+ const localCount = localGroup ? localGroup . count : 0 ;
37
38
// Append Changed IDs
38
39
update . concat ( changedIds ) ;
39
40
// Compare Counts Remote & Local
@@ -43,18 +44,18 @@ export default async (data) => {
43
44
query : getProcedureUpdates ,
44
45
variables : { period, type } ,
45
46
} ) ;
46
- // Find local Procedure Updates
47
+ // Find local Procedure Updates
47
48
const localProcedureUpdates = await ProcedureModel . find (
48
49
{ period, type } ,
49
50
{ procedureId : 1 , bioUpdateAt : 1 } ,
50
51
) ;
51
- // Compare
52
+ // Compare
52
53
procedureUpdates . forEach ( ( pu ) => {
53
54
const localData = localProcedureUpdates . find ( ld => ld . procedureId === pu . procedureId ) ;
54
55
if (
55
56
! localData ||
56
- ( pu . bioUpdateAt &&
57
- new Date ( localData . bioUpdateAt ) . getTime ( ) !== new Date ( pu . bioUpdateAt ) . getTime ( ) )
57
+ ( pu . bioUpdateAt &&
58
+ new Date ( localData . bioUpdateAt ) . getTime ( ) !== new Date ( pu . bioUpdateAt ) . getTime ( ) )
58
59
) {
59
60
update . push ( pu . procedureId ) ;
60
61
}
0 commit comments