Skip to content

Commit 6318c78

Browse files
committed
memory issue fix
1 parent 3cb6679 commit 6318c78

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ WORKDIR /app
55
COPY package*.json ./
66

77
RUN yarn install
8-
#RUN npm install nodemon@latest -g
98

109
COPY . .
1110

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
"private": true,
88
"scripts": {
99
"start": "babel-node src/index.js",
10-
"dev": "nodemon -e js,graphql src/index.js --exec \"node --require dotenv/config --require babel-register\"",
11-
"imp": "nodemon -e js,graphql --exec \"babel-node scripts/import.js\"",
12-
"impAll": "nodemon -e js,graphql --exec \"babel-node scripts/importAll.js\"",
10+
"dev":
11+
"nodemon -L -e js,graphql src/index.js --exec \"node --require dotenv/config --require babel-register\"",
1312
"lint": "eslint .",
1413
"clean": "rm -rf build && mkdir build",
1514
"build": "babel -d build src -s",

src/graphql/client.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import { InMemoryCache } from 'apollo-cache-inmemory';
44
import fetch from 'node-fetch';
55
import CONSTANTS from '../config/constants';
66

7-
const client = new ApolloClient({
7+
8+
const createClient = () => new ApolloClient({
89
link: new HttpLink({
910
// ssrMode: true,
1011
uri: CONSTANTS.BUNDESTAGIO_SERVER_URL,
1112
fetch,
1213
}),
1314
cache: new InMemoryCache(),
1415
});
15-
export default client;
16+
export default createClient;

src/scripts/import.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
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
33

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";
77

8-
export default async (procedureIds) => {
8+
export default async procedureIds => {
9+
const client = createClient();
910
// Start Importing
1011
const { data: { procedures } } = await client.query({
1112
query: getProcedures,
1213
variables: { IDs: procedureIds },
14+
fetchPolicy: "network-only"
1315
});
1416
// Start Inserting
15-
const promises = await procedures.map(async (bIoProcedure) => {
17+
const promises = await procedures.map(async bIoProcedure => {
1618
const newBIoProcedure = { ...bIoProcedure };
1719
if (bIoProcedure && bIoProcedure.history) {
1820
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+
);
2025
if (btWithDecisions.length > 0) {
2126
newBIoProcedure.voteDate = new Date(btWithDecisions.pop().date);
22-
} else if (newBIoProcedure.currentStatus === 'Zurückgezogen') {
27+
} else if (newBIoProcedure.currentStatus === "Zurückgezogen") {
2328
newBIoProcedure.voteDate = lastHistory.date;
2429
}
2530

@@ -31,8 +36,8 @@ export default async (procedureIds) => {
3136
{ procedureId: newBIoProcedure.procedureId },
3237
newBIoProcedure,
3338
{
34-
upsert: true,
35-
},
39+
upsert: true
40+
}
3641
);
3742
});
3843
const result = await Promise.all(promises);

0 commit comments

Comments
 (0)