Turn audio into a shareable video. forked from nypublicradio/audiogram

status.js 869B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. var queue = require("d3").queue,
  2. transports = require("../lib/transports");
  3. module.exports = function(req, res) {
  4. queue(1)
  5. .defer(transports.getJobList)
  6. .defer(transports.getHash, req.params.id)
  7. .await(function(err, jobs, hash) {
  8. if (err) {
  9. res.status(500).json("Unknown error.");
  10. throw err;
  11. }
  12. var position = -1;
  13. jobs.some(function(job, i) {
  14. if (job.id === req.params.id) {
  15. position = i;
  16. return true;
  17. }
  18. });
  19. if (position >= 0) {
  20. return res.json({ status: "queued", position: position });
  21. }
  22. if (hash === null) {
  23. hash = { status: "unknown" };
  24. }
  25. ["numFrames", "framesComplete"].forEach(function(key) {
  26. if (key in hash) {
  27. hash[key] = +hash[key];
  28. }
  29. });
  30. res.json(hash);
  31. });
  32. };