Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DataManager::ivDataQueryStream = (testId, minTime, maxTime, callback) ->
- # If minTime and maxTime have been provided, set a flag to limit time extents of query
- unless isNaN(minTime)
- timeLimits = true
- # Load the max number of IV data points to be displayed from CONFIG
- maxIvDataPoints = CONFIG.maxIvDataPoints
- # Construct a count query to determine the number if IV data points in range
- ivCountQuery = TestDataPoint.count({})
- ivCountQuery.where "testId", testId
- if timeLimits
- ivCountQuery.gt "testTime", minTime
- ivCountQuery.lt "testTime", maxTime
- ivCountQuery.exec (err, count) ->
- ivDisplayQuery = TestDataPoint.find({})
- ivDisplayQuery.where "testId", testId
- if timeLimits
- ivDisplayQuery.gt "testTime", minTime
- ivDisplayQuery.lt "testTime", maxTime
- # If the data set is too large, use modulo to sample, keeping the total data series
- # for display below maxIvDataPoints
- if count > maxIvDataPoints
- dataMod = Math.ceil count/maxIvDataPoints
- ivDisplayQuery.mod "dataPoint", dataMod, 1
- ivDisplayQuery.sort "dataPoint" #, 1 <-- new sort syntax for Mongoose 3.x
- callback ivDisplayQuery.stream()
Add Comment
Please, Sign In to add comment