Guest User

Untitled

a guest
Jan 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. DataManager::ivDataQueryStream = (testId, minTime, maxTime, callback) ->
  2.  
  3. # If minTime and maxTime have been provided, set a flag to limit time extents of query
  4. unless isNaN(minTime)
  5. timeLimits = true
  6.  
  7. # Load the max number of IV data points to be displayed from CONFIG
  8. maxIvDataPoints = CONFIG.maxIvDataPoints
  9.  
  10. # Construct a count query to determine the number if IV data points in range
  11. ivCountQuery = TestDataPoint.count({})
  12. ivCountQuery.where "testId", testId
  13.  
  14. if timeLimits
  15. ivCountQuery.gt "testTime", minTime
  16. ivCountQuery.lt "testTime", maxTime
  17.  
  18. ivCountQuery.exec (err, count) ->
  19.  
  20. ivDisplayQuery = TestDataPoint.find({})
  21. ivDisplayQuery.where "testId", testId
  22.  
  23. if timeLimits
  24. ivDisplayQuery.gt "testTime", minTime
  25. ivDisplayQuery.lt "testTime", maxTime
  26.  
  27. # If the data set is too large, use modulo to sample, keeping the total data series
  28. # for display below maxIvDataPoints
  29. if count > maxIvDataPoints
  30. dataMod = Math.ceil count/maxIvDataPoints
  31.  
  32. ivDisplayQuery.mod "dataPoint", dataMod, 1
  33.  
  34. ivDisplayQuery.sort "dataPoint" #, 1 <-- new sort syntax for Mongoose 3.x
  35. callback ivDisplayQuery.stream()
Add Comment
Please, Sign In to add comment