Skip to content

Commit

Permalink
Fixing stupid bugs, removing Skip button, better loading process
Browse files Browse the repository at this point in the history
  • Loading branch information
synhershko committed Sep 20, 2011
1 parent 45f8625 commit 8f4fae4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
29 changes: 17 additions & 12 deletions Orev/Controllers/JudgeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,20 @@ public JsonResult SaveJudgment(string topicId, string corpusId, string docId, st
{
// TODO: input validation

var j = new Judgment
{
CorpusId = corpusId,
TopicId = topicId,
DocumentId = docId,
UserJudgement = verdict,
UserId = "users/" + User.Identity.Name
};

RavenSession.Store(j);
RavenSession.SaveChanges();
if (verdict != Judgment.Verdict.Skip)
{
var j = new Judgment
{
CorpusId = corpusId,
TopicId = topicId,
DocumentId = docId,
UserJudgement = verdict,
UserId = "users/" + User.Identity.Name
};

RavenSession.Store(j);
RavenSession.SaveChanges();
}
}

var query = RavenSession.Advanced.LuceneQuery<CorpusDocument, CorpusDocuments_ByNextUnrated>()
Expand All @@ -94,13 +97,15 @@ public JsonResult SaveJudgment(string topicId, string corpusId, string docId, st

// Topics:* AND -Topics:topics/1 AND CorpusId:corpus/1

// TODO: Introduce randomization

var nextDoc = query.WaitForNonStaleResultsAsOfNow(TimeSpan.FromSeconds(10)).FirstOrDefault();
if (nextDoc == null)
return Json(new { corpusDone = true, });

return Json(new
{
docId = nextDoc.Id.ToIntId(),
docId = nextDoc.Id,
docContents = nextDoc.Content,
docTitle = nextDoc.Title,
});
Expand Down
13 changes: 11 additions & 2 deletions Orev/Views/Judge/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<div id="judgingContainer">
<input type="button" id="relevantBtn" value="Yes, it is relevant" />
<input type="button" id="irrelevantBtn" value="No, it is off topic" />
<!-- <input type="button" id="skipBtn" value="Skip this one" /> -->

<div id="documentViewerTitle"></div>
<div id="documentViewer"></div>
Expand All @@ -51,10 +52,14 @@
else {
$('#documentViewer').html(result.docContents);
$('#documentViewerTitle').html(result.docTitle);
currentDocumentId = result.docId;
}
}
function saveJudgment(docId, jdgmnt) {
$('#documentViewer').html('');
$('#documentViewerTitle').html('Loading next document...');
$.ajax({
type: 'POST',
//contentType: 'application/json; charset=utf-8',
Expand All @@ -80,9 +85,13 @@
});
$("#irrelevantBtn").click(function(e) {
saveJudgment(currentDocumentId, "NonRelevant");
saveJudgment(currentDocumentId, "NotRelevant");
});
/*
$("#skipBtn").click(function (e) {
saveJudgment(currentDocumentId, "Skip");
});*/
});
</script>
}

0 comments on commit 8f4fae4

Please sign in to comment.