Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Better debugging output showing track names and lengths

  • Loading branch information...
commit e235dbf22800f4a5bfd3ddaf3631561bf485f9ae 1 parent 9d00e6e
@jhurliman authored
Showing with 61 additions and 15 deletions.
  1. +28 −12 controllers/debug.js
  2. +2 −1  package.json
  3. +31 −2 views/debug.jade
View
40 controllers/debug.js
@@ -1,3 +1,4 @@
+var async = require('async');
var urlParser = require('url');
var log = require('winston');
var fingerprinter = require('./fingerprinter');
@@ -51,20 +52,35 @@ exports.debugQuery = function(req, res) {
// TODO: Determine a useful set of data to return about the query and
// each match and return it in an HTML view
if (allMatches) {
- for (var i = 0; i < allMatches.length; i++) {
- var match = allMatches[i];
- match.codeLength = Math.ceil(match.length * fingerprinter.SECONDS_TO_TIMESTAMP);
- // Find each match that contributed to ascore
- getContributors(fp, match);
- delete match.codes;
- delete match.times;
- }
+ async.forEach(allMatches,
+ function(match, done) {
+ fingerprinter.getTrackMetadata(match, null, null, function(err) {
+ match.codeLength = Math.ceil(match.length * fingerprinter.SECONDS_TO_TIMESTAMP);
+ // Find each match that contributed to ascore
+ getContributors(fp, match);
+ delete match.codes;
+ delete match.times;
+
+ done(err);
+ });
+ },
+ function(err) {
+ if (err) {
+ return server.renderView(req, res, 500, 'debug.jade',
+ { err: 'Metadata lookup failed:' + err });
+ }
+
+ renderView();
+ }
+ );
}
- var json = JSON.stringify({ success: !!result.success, status: result.status,
- queryLen: fp.codes.length, matches: allMatches, queryTime: duration });
- return server.renderView(req, res, 200, 'debug.jade', { res: json,
- input: req.body.json });
+ function renderView() {
+ var json = JSON.stringify({ success: !!result.success, status: result.status,
+ queryLen: fp.codes.length, matches: allMatches, queryTime: duration });
+ return server.renderView(req, res, 200, 'debug.jade', { res: json,
+ input: req.body.json });
+ }
});
});
};
View
3  package.json
@@ -4,6 +4,7 @@
"dependencies": {
"mysql": "0.9.5",
"winston": "0.5.9",
- "jade": "0.20.3"
+ "jade": "0.20.3",
+ "async": "0.1.16"
}
}
View
33 views/debug.jade
@@ -1,7 +1,27 @@
!!! 5
html(lang="en")
head
+ meta(charset='utf-8')
title Echoprint Debug
+ link(href='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css', rel='stylesheet', type='text/css')
+ style(type='text/css')
+ .ui-progressbar {
+ height: 15px;
+ background: #ffffff;
+ background: -moz-linear-gradient(top, #ffffff 0%, #f7f7f7 44%, #ededed 100%);
+ background: -webkit-linear-gradient(top, #ffffff 0%,#f7f7f7 44%,#ededed 100%);
+ background: -o-linear-gradient(top, #ffffff 0%,#f7f7f7 44%,#ededed 100%);
+ background: -ms-linear-gradient(top, #ffffff 0%,#f7f7f7 44%,#ededed 100%);
+ background: linear-gradient(top, #ffffff 0%,#f7f7f7 44%,#ededed 100%);
+ }
+ .ui-widget-header {
+ background: #7abcff;
+ background: -moz-linear-gradient(top, #7abcff 0%, #60abf8 44%, #4096ee 100%);
+ background: -webkit-linear-gradient(top, #7abcff 0%,#60abf8 44%,#4096ee 100%);
+ background: -o-linear-gradient(top, #7abcff 0%,#60abf8 44%,#4096ee 100%);
+ background: -ms-linear-gradient(top, #7abcff 0%,#60abf8 44%,#4096ee 100%);
+ background: linear-gradient(top, #7abcff 0%,#60abf8 44%,#4096ee 100%);
+ }
body
h3 Echoprint Debug
@@ -22,6 +42,7 @@ html(lang="en")
table#matches(border=1)
script(src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js')
+ script(src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js')
- if (typeof(res) !== 'undefined')
script var res = !{res};
- else
@@ -38,16 +59,24 @@ html(lang="en")
for (var i = 0; i < res.matches.length; i++) {
var match = res.matches[i];
var trackTD = $(document.createElement('td'));
- trackTD.text(match.track_id);
+
+ var artistName = match.artist || '[Unnamed Artist]';
+ var trackName = match.track || '[Unnamed Track]';
+
+ trackTD.html(match.track_id + '<br>"' + artistName + ' - ' + trackName + '"');
+
+ console.log(match.contributors.length + ' / ' + res.queryLen);
+ var pctMatched = match.contributors.length / res.queryLen;
var graphsTD = $(document.createElement('td'));
+ $("<div></div>").progressbar({ value: pctMatched * 100 }).appendTo(graphsTD);
$('<canvas/>', {
name: match.track_id + '-lines',
css: {
margin: '0',
background: '#ffffff',
border: '1px solid black',
- width: '400px',
+ width: (Math.min(match.length, 600) * 1.3) + 'px',
height: '25px'
}
}).appendTo(graphsTD);
Please sign in to comment.
Something went wrong with that request. Please try again.