Skip to content

Commit

Permalink
add constants for sample merge statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
grandsbor committed Jul 7, 2020
1 parent 44c7d63 commit e033ae2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
5 changes: 5 additions & 0 deletions lib/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
define('MA_SAMPLES_STATUS_HOMONYMOUS', 4);
define('MA_SAMPLES_STATUS_MANUAL_EDIT', 5); // for non-merged samples

define('MA_MERGE_STATUS_NOT_MERGED', 0);
define('MA_MERGE_STATUS_AUTO_OK', 1);
define('MA_MERGE_STATUS_MANUAL_OK', 2);
define('MA_MERGE_STATUS_POST_OK', 3);

define('MA_ANNOTATORS_PER_SAMPLE', 4);
define('MA_DEFAULT_POOL_SIZE', 50);
define('MA_ANSWER_OTHER', 99);
Expand Down
13 changes: 8 additions & 5 deletions lib/lib_qa.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ function get_merge_fails($status=0, $show_checked=false) {
require_once('lib_annot.php');
// stats
$res = sql_pe("
SELECT SUM(merge_status = 2) AS checked, COUNT(*) AS total
SELECT SUM(merge_status = ".MA_MERGE_STATUS_MANUAL_OK.") AS checked, COUNT(*) AS total
FROM morph_annot_moderated_samples
JOIN morph_annot_samples s USING (sample_id)
JOIN morph_annot_pools p USING (pool_id)
WHERE p.status = ".MA_POOLS_STATUS_ARCHIVED."
AND merge_status IN (0, 2)
AND merge_status IN (".MA_MERGE_STATUS_NOT_MERGED.", ".MA_MERGE_STATUS_MANUAL_OK.")
");
$row = $res[0];
$data = array(
Expand All @@ -135,6 +135,9 @@ function get_merge_fails($status=0, $show_checked=false) {
'ready' => $row['checked'] * 100 / $row['total']
);
// main query
$statuses = [MA_MERGE_STATUS_NOT_MERGED];
if ($show_checked)
$statuses[] = MA_MERGE_STATUS_MANUAL_OK;
$res = sql_query("
SELECT sample_id, p.pool_name, p.pool_id, p.revision AS pool_revision, pt.grammemes,
ms.status, ms.answer, s.tf_id, tokens.tf_text, c.comment, merge_status, tfr.rev_text as cur_rev
Expand All @@ -146,7 +149,7 @@ function get_merge_fails($status=0, $show_checked=false) {
LEFT JOIN tokens USING (tf_id)
LEFT JOIN tf_revisions tfr ON (tokens.tf_id = tfr.tf_id AND is_last = 1)
WHERE p.status = ".MA_POOLS_STATUS_ARCHIVED."
AND merge_status in (0".($show_checked ? ", 2" : "").")
AND merge_status in (".join(',', $statuses).")
ORDER BY merge_status, p.pool_type, status, tf_text, sample_id
");

Expand Down Expand Up @@ -193,7 +196,7 @@ function get_merge_fails($status=0, $show_checked=false) {
}
++$data['total'][$r['status']];
++$data['total'][0];
if ($r['merge_status'])
if ($r['merge_status'] == MA_MERGE_STATUS_MANUAL_OK)
++$data['checked'][$r['status']];
}
return $data;
Expand All @@ -205,7 +208,7 @@ function save_merge_fail_status($sample_id, $is_checked) {
SET merge_status = ?
WHERE sample_id = ?
LIMIT 1
", array($is_checked ? 2 : 0, $sample_id));
", array($is_checked ? MA_MERGE_STATUS_MANUAL_OK : MA_MERGE_STATUS_NOT_MERGED, $sample_id));
}
function save_merge_fail_comment($sample_id, $comment_text) {
check_permission(PERM_MORPH_SUPERMODER);
Expand Down
3 changes: 2 additions & 1 deletion templates/qa/merge_fails.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{$MISPRINT = $smarty.const.MA_SAMPLES_STATUS_MISPRINT}
{$HOMONYMY = $smarty.const.MA_SAMPLES_STATUS_HOMONYMOUS}
{$EDIT = $smarty.const.MA_SAMPLES_STATUS_MANUAL_EDIT}
{$MANUAL = $smarty.const.MA_MERGE_STATUS_MANUAL_OK}
<h1>Отмодерированные примеры, которые не изменили корпус</h1>
<div>
{if empty($smarty.get.show_checked)}
Expand Down Expand Up @@ -58,7 +59,7 @@
</td>
<td>{$sample.mod_answer}</td>
<td>{$sample.prod_answer}</td>
<td><input type="checkbox" {if $sample.merge_status == 2}checked="checked"{/if} class="approve-sample" data-id="{$sample.id}"/></td>
<td><input type="checkbox" {if $sample.merge_status == $MANUAL}checked="checked"{/if} class="approve-sample" data-id="{$sample.id}"/></td>
<td class="comment-cell" data-id="{$sample.id}" contenteditable>{$sample.comment}</td>
</tr>
{/foreach}
Expand Down

0 comments on commit e033ae2

Please sign in to comment.