<commit_before>import { Pull } from '../pull';
import { getUser } from "../page-context";

export function defaultCompare(a: Pull, b: Pull): number {
   return (
    // My pulls above pulls that aren't mine
    compareBool(a.isMine(), b.isMine()) ||
    // Pulls I have to CR/QA above those I don't
    compareBool(a.hasOutdatedSig(getUser()), b.hasOutdatedSig(getUser())) ||
    // Pulls I haven't touched vs those I have already CRed
    compareBool(!a.hasCurrentSig(getUser()), !b.hasCurrentSig(getUser()))
   );
}

export function QACompare(a: Pull, b: Pull): number {
   return (
      // Pulls I'm QAing above those I'm not
      compareBool(isQAingByMe(a), isQAingByMe(b)) ||
      // Pulls with no external_block above those with external_block
      compareBool(!a.getLabel('external_block'), !b.getLabel('external_block')) ||
      // Pulls with no QAing label above those with QAing
      compareBool(!a.getLabel('QAing'), !b.getLabel('QAing')) ||
      // Pulls with CR completed above those that need more
      compareBool(a.isCrDone(), b.isCrDone()) ||
      // Older pulls before younger pulls
      a.created_at.localeCompare(b.created_at)
   );
}

function isQAingByMe(pull: Pull): boolean {
   const label = pull.getLabel('QAing');
   return !!(label?.user == getUser());
}

function compareBool(a: boolean, b: boolean): number {
   return +b - +a;
}<commit_msg>[minor] sort.ts: remove unneeded boolean cast<commit_after>import { Pull } from '../pull';
import { getUser } from "../page-context";

export function defaultCompare(a: Pull, b: Pull): number {
   return (
    // My pulls above pulls that aren't mine
    compareBool(a.isMine(), b.isMine()) ||
    // Pulls I have to CR/QA above those I don't
    compareBool(a.hasOutdatedSig(getUser()), b.hasOutdatedSig(getUser())) ||
    // Pulls I haven't touched vs those I have already CRed
    compareBool(!a.hasCurrentSig(getUser()), !b.hasCurrentSig(getUser()))
   );
}

export function QACompare(a: Pull, b: Pull): number {
   return (
      // Pulls I'm QAing above those I'm not
      compareBool(isQAingByMe(a), isQAingByMe(b)) ||
      // Pulls with no external_block above those with external_block
      compareBool(!a.getLabel('external_block'), !b.getLabel('external_block')) ||
      // Pulls with no QAing label above those with QAing
      compareBool(!a.getLabel('QAing'), !b.getLabel('QAing')) ||
      // Pulls with CR completed above those that need more
      compareBool(a.isCrDone(), b.isCrDone()) ||
      // Older pulls before younger pulls
      a.created_at.localeCompare(b.created_at)
   );
}

function isQAingByMe(pull: Pull): boolean {
   const label = pull.getLabel('QAing');
   return label?.user == getUser();
}

function compareBool(a: boolean, b: boolean): number {
   return +b - +a;
}
{'fraction_non_alphanumeric': 0.14336917562724014, 'fraction_numerical': 0.0, 'mean_word_length': 3.5235008103727714, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1340295', 'n_tokens_mistral': 908, 'n_tokens_neox': 881, 'n_words': 249}