Skip to content

Commit

Permalink
ever closer to populating db with sequences!
Browse files Browse the repository at this point in the history
ref #10-splitter-adapter
  • Loading branch information
maxgrossman committed Jun 13, 2018
1 parent ec7925b commit fb444f7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.env
.DS_Store
./db/posm-paths.sqlite3
./db/*
./testData/danbjoseph
.python_version
.vscode
Expand Down
19 changes: 10 additions & 9 deletions handlers/sequence/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ exports.insertImages = (sequence) => {
})
.then(async (values) => {
try {
await db.raw(
`INSERT INTO Images (
id, path, time, seqId, userId, loc
) VALUES ${values}`
)
await db.raw(`
SELECT load_extension('mod_spatialite');
INSERT INTO Images (
id, path, time, seqId, userId, GeomFromText('POINT(${loc.lat} ${loc.lon})')
) VALUES ${values}
`)
} catch (e) {
throw e;
}
Expand All @@ -38,11 +39,11 @@ exports.insertSequence = (sequence) => {
Promise.map(sequence, image => { return { id : image.id, loc: image.loc }})
.then(async (sequenceImages) => {
try {
await db.raw(
`INSERT INTO Sequences (
await db.raw(`
INSERT INTO Sequences (
id, userId, images
) VALUES (${sequenceId}, ${userId}, JSON(${sequenceImages})`
)
) VALUES (${sequenceId}, ${userId}, JSON(${sequenceImages})
`)
} catch (e) {
throw e;
}
Expand Down
4 changes: 2 additions & 2 deletions handlers/sequence/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const Boom = require('boom');
const db = require('../../connection');
const uuidv4 = require('uuid/v4');
const buildSequences = require('../../adapters/sequence');
// const insertImages = require('./helpers').insertImages;
// const insertSequence = require('./helpers').insertSequence;
const insertImages = require('./helpers').insertImages;
const insertSequence = require('./helpers').insertSequence;

module.exports = async (r, h) => {
try {
Expand Down

0 comments on commit fb444f7

Please sign in to comment.