1
- import ProgressBar from ' cli-progress' ; // eslint-disable-line
2
- import program from ' commander' ; // eslint-disable-line
1
+ import ProgressBar from " cli-progress" ; // eslint-disable-line
2
+ import program from " commander" ; // eslint-disable-line
3
3
4
- import client from ' ../graphql/client' ;
5
- import Procedure from ' ../models/Procedure' ;
6
- import getProcedures from ' ../graphql/queries/getProcedures' ;
4
+ import createClient from " ../graphql/client" ;
5
+ import Procedure from " ../models/Procedure" ;
6
+ import getProcedures from " ../graphql/queries/getProcedures" ;
7
7
8
- export default async ( procedureIds ) => {
8
+ export default async procedureIds => {
9
+ const client = createClient ( ) ;
9
10
// Start Importing
10
11
const { data : { procedures } } = await client . query ( {
11
12
query : getProcedures ,
12
13
variables : { IDs : procedureIds } ,
14
+ fetchPolicy : "network-only"
13
15
} ) ;
14
16
// Start Inserting
15
- const promises = await procedures . map ( async ( bIoProcedure ) => {
17
+ const promises = await procedures . map ( async bIoProcedure => {
16
18
const newBIoProcedure = { ...bIoProcedure } ;
17
19
if ( bIoProcedure && bIoProcedure . history ) {
18
20
const [ lastHistory ] = newBIoProcedure . history . slice ( - 1 ) ;
19
- const btWithDecisions = bIoProcedure . history . filter ( ( { assignment, initiator } ) => assignment === 'BT' && initiator === '2. Beratung' ) ;
21
+ const btWithDecisions = bIoProcedure . history . filter (
22
+ ( { assignment, initiator } ) =>
23
+ assignment === "BT" && initiator === "2. Beratung"
24
+ ) ;
20
25
if ( btWithDecisions . length > 0 ) {
21
26
newBIoProcedure . voteDate = new Date ( btWithDecisions . pop ( ) . date ) ;
22
- } else if ( newBIoProcedure . currentStatus === ' Zurückgezogen' ) {
27
+ } else if ( newBIoProcedure . currentStatus === " Zurückgezogen" ) {
23
28
newBIoProcedure . voteDate = lastHistory . date ;
24
29
}
25
30
@@ -31,8 +36,8 @@ export default async (procedureIds) => {
31
36
{ procedureId : newBIoProcedure . procedureId } ,
32
37
newBIoProcedure ,
33
38
{
34
- upsert : true ,
35
- } ,
39
+ upsert : true
40
+ }
36
41
) ;
37
42
} ) ;
38
43
const result = await Promise . all ( promises ) ;
0 commit comments