Skip to content

Commit

Permalink
feat(projects): save results in DynamoDB - EUBFR-32 (#14)
Browse files Browse the repository at this point in the history
* feat(projects): save results in DynamoDB - EUBFR-32

* Save to DB

* Remove records when the file is deleted

* Remove junk

* Batch Delete Items

* Remove dead code

* Add HTTP endpoint to retrieve the list of all projects
  • Loading branch information
yhuard authored and kalinchernev committed Oct 5, 2017
1 parent 32b1310 commit 13a3808
Show file tree
Hide file tree
Showing 27 changed files with 471 additions and 231 deletions.
39 changes: 0 additions & 39 deletions lib/dynamodb/actions/save.js

This file was deleted.

74 changes: 0 additions & 74 deletions lib/dynamodb/helpers/normalize.js

This file was deleted.

1 change: 0 additions & 1 deletion lib/dynamodb/index.js

This file was deleted.

9 changes: 0 additions & 9 deletions lib/dynamodb/package.json

This file was deleted.

72 changes: 0 additions & 72 deletions lib/dynamodb/tables/projects.js

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"lerna": "2.3.1",
"lint-staged": "4.2.3",
"npm-run-all": "4.1.1",
"prettier": "1.7.3"
"prettier": "1.7.4"
},
"workspaces": ["lib/*", "services/**"]
"workspaces": ["services/**"]
}
4 changes: 4 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ cd ../cleaner
# Deploy ETL
cd ../etl/budg/csv
./node_modules/.bin/serverless deploy -v

# Deploy value store - projects
cd ../../../../value-store/projects
./node_modules/.bin/serverless deploy -v
4 changes: 2 additions & 2 deletions services/ingestion/cleaner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"test:unit": "jest --testPathPattern=unit"
},
"devDependencies": {
"aws-sdk": "2.125.0",
"aws-sdk": "2.127.0",
"babel-core": "6.26.0",
"babel-loader": "7.1.2",
"babel-plugin-transform-runtime": "6.23.0",
"babel-preset-es2015": "6.24.1",
"babel-preset-stage-3": "6.24.1",
"jest": "21.2.1",
"serverless": "1.23.0",
"serverless-webpack": "3.1.0",
"serverless-webpack": "3.1.1",
"webpack": "3.6.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion services/ingestion/cleaner/src/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const onObjectRemoved = (event, context, callback) => {

const params = {
Bucket: BUCKET,
Key: `${s3record.s3.object.key}.data`,
Key: `${s3record.s3.object.key}.ndjson`,
};
console.log('params', params);

Expand Down
4 changes: 2 additions & 2 deletions services/ingestion/etl/budg/csv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"test:unit": "jest --testPathPattern=unit"
},
"devDependencies": {
"aws-sdk": "2.125.0",
"aws-sdk": "2.127.0",
"babel-core": "6.26.0",
"babel-loader": "7.1.2",
"babel-plugin-transform-runtime": "6.23.0",
"babel-preset-es2015": "6.24.1",
"babel-preset-stage-3": "6.24.1",
"jest": "21.2.1",
"serverless": "1.23.0",
"serverless-webpack": "3.1.0",
"serverless-webpack": "3.1.1",
"webpack": "3.6.0"
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions services/ingestion/etl/budg/csv/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ functions:
parseCsv:
handler: src/handler.parseCsv
name: ${self:provider.stage}-${self:service}-parseCsv
memorySize: 256
environment:
BUCKET: ${self:custom.bucketName}
events:
Expand Down
5 changes: 3 additions & 2 deletions services/ingestion/etl/budg/csv/src/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const parseCsv = (event, context, callback) => {
const transformer = transform(
(record, cb) => {
const data = transformRecord(record);
cb(null, `${JSON.stringify(data)}\r\n`);
cb(null, `${JSON.stringify(data)}\n`);
},
{ parallel: 10 }
);
Expand All @@ -59,8 +59,9 @@ export const parseCsv = (event, context, callback) => {

const params = {
Bucket: BUCKET,
Key: `${message.object.key}.data`,
Key: `${message.object.key}.ndjson`,
Body: pass,
ContentType: 'application/x-ndjson',
};

s3.upload(params, err => {
Expand Down
1 change: 1 addition & 0 deletions services/ingestion/etl/budg/csv/src/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default record => {

// Map the fields
return {
project_id: record.Nid,
title: record.Name,
cover_image: record.Visual,
programme_name: record['Programme name'],
Expand Down
4 changes: 2 additions & 2 deletions services/ingestion/manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"test:unit": "jest --testPathPattern=unit"
},
"devDependencies": {
"aws-sdk": "2.125.0",
"aws-sdk": "2.127.0",
"babel-core": "6.26.0",
"babel-loader": "7.1.2",
"babel-plugin-transform-runtime": "6.23.0",
"babel-preset-es2015": "6.24.1",
"babel-preset-stage-3": "6.24.1",
"jest": "21.2.1",
"serverless": "1.23.0",
"serverless-webpack": "3.1.0",
"serverless-webpack": "3.1.1",
"webpack": "3.6.0"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions services/storage/meta-index/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test:unit": "jest --testPathPattern=unit"
},
"devDependencies": {
"aws-sdk": "2.125.0",
"aws-sdk": "2.127.0",
"babel-core": "6.26.0",
"babel-loader": "7.1.2",
"babel-plugin-transform-runtime": "6.23.0",
Expand All @@ -16,7 +16,7 @@
"jest": "21.2.1",
"serverless": "1.23.0",
"serverless-dynamodb-autoscaling": "0.6.2",
"serverless-webpack": "3.1.0",
"serverless-webpack": "3.1.1",
"webpack": "3.6.0"
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions services/storage/meta-index/src/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const onObjectCreated = (event, context, callback) => {
// Save record
const documentClient = new AWS.DynamoDB.DocumentClient({
apiVersion: '2012-08-10',
convertEmptyValues: true,
});

const params = {
Expand Down
4 changes: 2 additions & 2 deletions services/storage/signed-uploads/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
"start": "sls offline start"
},
"devDependencies": {
"aws-sdk": "2.125.0",
"aws-sdk": "2.127.0",
"babel-core": "6.26.0",
"babel-loader": "7.1.2",
"babel-plugin-transform-runtime": "6.23.0",
"babel-preset-es2015": "6.24.1",
"babel-preset-stage-3": "6.24.1",
"serverless": "1.23.0",
"serverless-offline": "3.16.0",
"serverless-webpack": "3.1.0",
"serverless-webpack": "3.1.1",
"webpack": "3.6.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion services/storage/signed-uploads/src/upsert.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable import/prefer-default-export */

import AWS from 'aws-sdk';
import AWS from 'aws-sdk'; // eslint-disable-line import/no-extraneous-dependencies

const bucket = process.env.BUCKET;
const region = process.env.REGION;
Expand Down
4 changes: 4 additions & 0 deletions services/value-store/projects/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"plugins": ["transform-runtime"],
"presets": ["es2015", "stage-3"]
}
1 change: 1 addition & 0 deletions services/value-store/projects/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Storage - Meta Index
Loading

0 comments on commit 13a3808

Please sign in to comment.