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

status.js 821B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. throw err;
  10. }
  11. var position = -1;
  12. jobs.some(function(job, i) {
  13. if (job.id === req.params.id) {
  14. position = i;
  15. return true;
  16. }
  17. });
  18. if (position >= 0) {
  19. return res.json({ status: "queued", position: position });
  20. }
  21. if (hash === null) {
  22. hash = { status: "unknown" };
  23. }
  24. ["numFrames", "framesComplete"].forEach(function(key) {
  25. if (key in hash) {
  26. hash[key] = +hash[key];
  27. }
  28. });
  29. res.json(hash);
  30. });
  31. };