Comparing version 0.2.1 to 0.2.2
@@ -7,3 +7,3 @@ { | ||
], | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"homepage": "https://github.com/chbrown/bcycle", | ||
@@ -17,2 +17,3 @@ "repository": "git://github.com/chbrown/bcycle.git", | ||
"http-enhanced": "*", | ||
"moment": "*", | ||
"regex-router": "*", | ||
@@ -19,0 +20,0 @@ "request": "*", |
@@ -5,2 +5,3 @@ /// <reference path="type_declarations/index.d.ts" /> | ||
var url = require('url'); | ||
var moment = require('moment'); | ||
var Router = require('regex-router'); | ||
@@ -17,10 +18,18 @@ var database_1 = require('./database'); | ||
'kiosk.latitude', 'kiosk.longitude', 'kiosk.time_zone', 'kiosk.status', 'kiosk.is_event_based', | ||
'status.docks_available', 'status.bikes_available', | ||
'status.docks_available', 'status.bikes_available', 'status.fetched', | ||
]) | ||
.orderBy('fetched DESC') | ||
.limit(1000); | ||
.orderBy('fetched DESC'); | ||
if (urlObj.query.programId) { | ||
// if you specify a particular program, you get a whole day's worth | ||
var program_id = parseInt(urlObj.query.programId, 10); | ||
query = query.whereEqual({ program_id: program_id }); | ||
var one_day_ago = (new Date().getTime()); | ||
query = query | ||
.whereEqual({ program_id: program_id }) | ||
.where('fetched > ?', moment().subtract(1, 'day').toDate()); | ||
} | ||
else { | ||
// if you don't specify a program, you only get the last 1000 | ||
var limit = Math.min(parseInt(urlObj.query.limit || 1000, 10), 1000); | ||
query = query.limit(limit); | ||
} | ||
query.execute(function (error, statuses) { | ||
@@ -32,2 +41,17 @@ if (error) | ||
}); | ||
R.get(/^\/programs(\?|$)/, function (req, res) { | ||
database_1.db.Select('program INNER JOIN kiosk ON kiosk.program_id = program.id') | ||
.add([ | ||
'program.id', 'program.name', 'program.latitude', 'program.longitude', | ||
// ::integer converts from long so that `pg` parses it as a number | ||
'COUNT(kiosk.id)::integer AS kiosks', | ||
]) | ||
.orderBy('program.name') | ||
.groupBy('program.id') | ||
.execute(function (error, programs) { | ||
if (error) | ||
return res.error(error); | ||
res.json(programs); | ||
}); | ||
}); | ||
/** GET /info | ||
@@ -34,0 +58,0 @@ Show npm-search-server package metadata |
@@ -5,2 +5,3 @@ /// <reference path="type_declarations/index.d.ts" /> | ||
import url = require('url'); | ||
import moment = require('moment'); | ||
import Router = require('regex-router'); | ||
@@ -21,11 +22,19 @@ | ||
'kiosk.latitude', 'kiosk.longitude', 'kiosk.time_zone', 'kiosk.status', 'kiosk.is_event_based', | ||
'status.docks_available', 'status.bikes_available', | ||
'status.docks_available', 'status.bikes_available', 'status.fetched', | ||
]) | ||
.orderBy('fetched DESC') | ||
.limit(1000); | ||
if (urlObj.query.programId) { | ||
// if you specify a particular program, you get a whole day's worth | ||
var program_id = parseInt(urlObj.query.programId, 10); | ||
query = query.whereEqual({program_id: program_id}); | ||
var one_day_ago = (new Date().getTime()) | ||
query = query | ||
.whereEqual({program_id: program_id}) | ||
.where('fetched > ?', moment().subtract(1, 'day').toDate()); | ||
} | ||
else { | ||
// if you don't specify a program, you only get the last 1000 | ||
var limit = Math.min(parseInt(urlObj.query.limit || 1000, 10), 1000); | ||
query = query.limit(limit); | ||
} | ||
@@ -39,2 +48,18 @@ query.execute((error: Error, statuses: Status[]) => { | ||
R.get(/^\/programs(\?|$)/, (req, res: any) => { | ||
db.Select('program INNER JOIN kiosk ON kiosk.program_id = program.id') | ||
.add([ | ||
'program.id', 'program.name', 'program.latitude', 'program.longitude', | ||
// ::integer converts from long so that `pg` parses it as a number | ||
'COUNT(kiosk.id)::integer AS kiosks', | ||
]) | ||
.orderBy('program.name') | ||
.groupBy('program.id') | ||
.execute((error: Error, programs: Program[]) => { | ||
if (error) return res.error(error); | ||
res.json(programs); | ||
}); | ||
}); | ||
/** GET /info | ||
@@ -41,0 +66,0 @@ Show npm-search-server package metadata |
/// <reference path="DefinitelyTyped/async/async.d.ts" /> | ||
/// <reference path="DefinitelyTyped/node/node.d.ts" /> | ||
/// <reference path="DefinitelyTyped/request/request.d.ts" /> | ||
/// <reference path="DefinitelyTyped/moment/moment.d.ts" /> | ||
/// <reference path="../node_modules/regex-router/regex-router.d.ts" /> |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
130777
18
2897
1
8
9
+ Addedmoment@*
+ Addedmoment@2.30.1(transitive)