Skip to content

Commit

Permalink
Adjust the tag rank download.
Browse files Browse the repository at this point in the history
And drop tagIndex support from Conf::paper_result.
  • Loading branch information
kohler committed May 13, 2020
1 parent 8162dd9 commit 536f49e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 22 deletions.
7 changes: 0 additions & 7 deletions src/conference.php
Original file line number Diff line number Diff line change
Expand Up @@ -3337,8 +3337,6 @@ function paper_result($options, Contact $user = null) {
// "commenterName" Include commenter names
// "tags" Include paperTags
// "minimal" Only include minimal paper fields
// "tagIndex" => $tag Include tagIndex of named tag
// "tagIndex" => tag array -- include tagIndex, tagIndex1, ...
// "topics"
// "options"
// "scores" => array(fields to score)
Expand Down Expand Up @@ -3463,11 +3461,6 @@ function paper_result($options, Contact $user = null) {
|| $this->has_tracks()) {
$cols[] = "(select group_concat(' ', tag, '#', tagIndex order by tag separator '') from PaperTag where PaperTag.paperId=Paper.paperId) paperTags";
}
if (($tagindexes = $options["tagIndex"] ?? false)) {
foreach (mkarray($tagindexes) as $i => $tag) {
$cols[] = "(select tagIndex from PaperTag where PaperTag.paperId=Paper.paperId and PaperTag.tag='" . sqlq($tag) . "') tagIndex" . ($i ? : "");
}
}

if ($options["reviewerPreference"] ?? false) {
$joins[] = "left join PaperReviewPreference on (PaperReviewPreference.paperId=Paper.paperId and PaperReviewPreference.contactId=$contactId)";
Expand Down
52 changes: 37 additions & 15 deletions src/listactions/la_getrank.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,44 @@ function run(Contact $user, $qreq, $ssel) {
}
$tagger = new Tagger($user);
if (($tag = $tagger->check($qreq->tag, Tagger::NOVALUE | Tagger::NOCHAIR))) {
$real = "";
$null = "\n";
$lastIndex = null;
foreach ($user->paper_set($ssel, ["tagIndex" => $tag, "order" => "order by tagIndex, Paper.paperId"]) as $prow) {
$real = $null = "";
$pset = $user->paper_set($ssel, ["tags" => true]);
$pset->sort_by(function ($p1, $p2) use ($tag) {
$tv1 = $p1->tag_value($tag);
$tv2 = $p2->tag_value($tag);
if ($tv1 === false && $tv2 === false) {
return $p1->paperId - $p2->paperId;
} else if ($tv1 === false || $tv2 === false) {
return $tv1 === false ? 1 : -1;
} else if ($tv1 != $tv2) {
return $tv1 < $tv2 ? -1 : 1;
} else {
return $p1->paperId - $p2->paperId;
}
});
$lastIndex = false;
foreach ($pset as $prow) {
if ($user->can_change_tag($prow, $tag, null, 1)) {
$csvt = CsvGenerator::quote($prow->title);
if ($prow->tagIndex === null) {
$null .= "X,$prow->paperId,$csvt\n";
} else if ($real === "" || $lastIndex == $prow->tagIndex - 1) {
$real .= ",$prow->paperId,$csvt\n";
} else if ($lastIndex == $prow->tagIndex) {
$real .= "=,$prow->paperId,$csvt\n";
$tv = $prow->tag_value($tag);
$tail = ",$prow->paperId,$csvt\n";
if ($tv === false || $lastIndex === false) {
$delta = $tv;
} else {
$delta = $tv - $lastIndex;
}
if ($tv === false) {
$null .= "X" . $tail;
} else if ($delta == 1) {
$real .= $tail;
} else if ($delta == 0) {
$real .= "=" . $tail;
} else if ($delta == 2 || $delta == 3 || $delta == 4 || $delta == 5) {
$real .= str_repeat(">", $delta) . $tail;
} else {
$real .= str_repeat(">", min($prow->tagIndex - $lastIndex, 5)) . ",$prow->paperId,$csvt\n";
$real .= $tv . $tail;
}
$lastIndex = $prow->tagIndex;
$lastIndex = $tv;
}
}
$text = "action,paper,title
Expand All @@ -42,9 +64,9 @@ function run(Contact $user, $qreq, $ssel) {
# rearranging the lines. A line starting with \"=\" marks a paper with the
# same rank as the preceding paper. Lines starting with \">>\", \">>>\",
# and so forth indicate rank gaps between papers. When you are done,
# upload the file at\n"
. "# " . $user->conf->hoturl_absolute("offline", null, Conf::HOTURL_RAW) . "\n\n"
. $real . $null;
# upload the file here:\n"
. "# " . $user->conf->hoturl_absolute("offline", null, Conf::HOTURL_RAW) . "\n\n"
. $real . ($real === "" ? "" : "\n") . $null;
downloadText($text, "rank");
} else {
Conf::msg_error($tagger->error_html);
Expand Down

0 comments on commit 536f49e

Please sign in to comment.