-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from evansiroky/download-fix
bunch 'o stuff
- Loading branch information
Showing
74 changed files
with
549 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,6 @@ notifications: | |
|
||
node_js: | ||
- '6' | ||
- '5' | ||
- '4' | ||
|
||
env: | ||
- COVERAGE=false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,47 @@ | ||
var path = require('path'), | ||
downloadGtfs = require('./lib/download.js'), | ||
Database = require('./models'), | ||
loadgtfs = require('./lib/gtfsLoader.js'); | ||
|
||
module.exports = function(config) { | ||
const downloadGtfs = require('./lib/download.js') | ||
const loadgtfs = require('./lib/gtfsLoader.js') | ||
const operations = require('./lib/operations') | ||
const Database = require('./models') | ||
|
||
var connectToDatabase = function(rawModels) { | ||
var db = Database(config.database, config.sequelizeOptions ? config.sequelizeOptions : {}); | ||
if(!rawModels && config.spatial) { | ||
db.stop = db.sequelize.import('models/spatial/stop.js'); | ||
db.shape_gis = db.sequelize.import('models/spatial/shape_gis.js'); | ||
db.trip = db.sequelize.import('models/spatial/trip.js'); | ||
module.exports = function (config) { | ||
const connectToDatabase = function (rawModels) { | ||
const db = Database(config.database, config.sequelizeOptions ? config.sequelizeOptions : {}) | ||
if (!rawModels && config.spatial) { | ||
db.stop = db.sequelize.import('models/spatial/stop.js') | ||
db.shape_gis = db.sequelize.import('models/spatial/shape_gis.js') | ||
db.trip = db.sequelize.import('models/spatial/trip.js') | ||
// reassociate spatially-enable models | ||
db.stop.associate(db); | ||
db.shape_gis.associate(db); | ||
db.trip.associate(db); | ||
db.stop.associate(db) | ||
db.shape_gis.associate(db) | ||
db.trip.associate(db) | ||
} | ||
return db; | ||
return db | ||
} | ||
|
||
var download = function(callback) { | ||
downloadGtfs(config.gtfsUrl, config.downloadsDir, callback); | ||
const download = function (callback) { | ||
downloadGtfs(config.gtfsUrl, config.downloadsDir, callback) | ||
} | ||
|
||
var loadGtfs = function(callback) { | ||
const interpolateStopTimes = function (callback) { | ||
const db = connectToDatabase() | ||
operations.interpolateStopTimes(db, callback) | ||
} | ||
|
||
const loadGtfs = function (callback) { | ||
loadgtfs(config.downloadsDir, | ||
config.gtfsFileOrFolder, | ||
connectToDatabase(true), | ||
config.spatial, | ||
callback); | ||
config.interpolateStopTimes, | ||
callback) | ||
} | ||
|
||
return { | ||
config: config, | ||
connectToDatabase: connectToDatabase, | ||
downloadGtfs: download, | ||
interpolateStopTimes: interpolateStopTimes, | ||
loadGtfs: loadGtfs | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.