From 536f49e5dacda94642d9fa4be7f51ff59907f2e8 Mon Sep 17 00:00:00 2001 From: Eddie Kohler Date: Wed, 13 May 2020 08:18:44 -0400 Subject: [PATCH] Adjust the tag rank download. And drop tagIndex support from Conf::paper_result. --- src/conference.php | 7 ----- src/listactions/la_getrank.php | 52 ++++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/conference.php b/src/conference.php index 76ade0eb3..b5510850a 100644 --- a/src/conference.php +++ b/src/conference.php @@ -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) @@ -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)"; diff --git a/src/listactions/la_getrank.php b/src/listactions/la_getrank.php index a3df3e053..cabf29def 100644 --- a/src/listactions/la_getrank.php +++ b/src/listactions/la_getrank.php @@ -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 @@ -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);