All files / utils/moderation constants.js

100% Statements 12/12
100% Branches 0/0
100% Functions 0/0
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63                        25x     25x     25x     25x     25x 25x     25x     25x   25x             25x             25x   25x                          
/**
 * Parameters of the community moderation engine — see
 * docs/architecture/MODERATION.md. Per-subject parameters (votes needed, quota
 * cost) live with each subject type, in subjects/.
 */
 
/**
 * The review queue (`pendingIndex`) is split into a few shards so writes spread
 * over several partitions. Few enough that one bounded request can read all of
 * them when the queue is short: the quota waiver ("nothing left to review")
 * depends on seeing the whole queue in that case.
 */
const PENDING_SHARDS = ['P#0', 'P#1', 'P#2', 'P#3']
 
/** Rows read per Query page of the review queue. */
const QUEUE_PAGE_SIZE = 20
 
/** Hard ceiling on Query calls per "find tasks to review" request (never a scan). */
const QUEUE_QUERY_BUDGET = 6
 
/** Tasks returned to a reviewer per request. */
const MAX_TASKS_PER_REQUEST = 5
 
/** Reputation change of a voter whose vote matches the final decision / does not. */
const REPUTATION_AGREE = 2
const REPUTATION_DISAGREE = -1
 
/** A decided task (and its votes) lives 30 days, then DynamoDB TTL removes it. */
const DECIDED_TASK_TTL_SECONDS = 30 * 24 * 60 * 60
 
/** Safety-net TTL of a vote row; a task is normally decided long before. */
const VOTE_TTL_SECONDS = 90 * 24 * 60 * 60
 
const DECISION = { APPROVED: 'approved', REJECTED: 'rejected' }
 
/**
 * What happens to a pending subject that can no longer be reviewed (its entity
 * stopped being public, or stopped taking comments): it is deleted, undecided.
 * Passed to `buildAuthorNotification` in place of a decision.
 */
const DISCARDED = 'discarded'
 
/**
 * The registered subject types (subjects/index.js), named here so that code
 * outside the engine (comment endpoints, cleanups) can refer to them without
 * loading the subjects.
 */
const SUBJECT_TYPE = { ITEM_COMMENT: 'item-comment', PACK_COMMENT: 'pack-comment' }
 
module.exports = {
  SUBJECT_TYPE,
  PENDING_SHARDS,
  QUEUE_PAGE_SIZE,
  QUEUE_QUERY_BUDGET,
  MAX_TASKS_PER_REQUEST,
  REPUTATION_AGREE,
  REPUTATION_DISAGREE,
  DECIDED_TASK_TTL_SECONDS,
  VOTE_TTL_SECONDS,
  DECISION,
  DISCARDED
}