<commit_before>"use strict"; // catch errors easier

const github = require("../github.js"); // GitHub wrapper initialization
const cfg = require("../config.js"); // config file
const newComment = require("../issues/newComment.js"); // create comment

module.exports = exports = function(areaLabel, issueNumber, repoName, repoOwner, issueLabelArray) {
  if (!cfg.areaLabels.has(areaLabel)) return; // if added label isn't an area label, return;
  const areaLabelTeam = cfg.areaLabels.get(areaLabel); // find corresponding area label team
  github.issues.getComments({
    owner: repoOwner,
    repo: repoName,
    number: issueNumber,
    per_page: 100
  }).then((issueComments) => {
    const labelComment = issueComments.data.find((issueComment) => {
      return issueComment.body.includes("this issue was labeled with the") && issueComment.user.login === cfg.username;
    });
    if (labelComment) {
      let issueLabels = []; // initialize array for area labels
      let labelTeams = [];
      issueLabelArray.forEach((issueLabel) => {
        const labelName = issueLabel.name; // label name
        if (cfg.areaLabels.has(labelName) && !issueLabels.includes(labelName)) {
          issueLabels.push(labelName); // push all associated area labels to array
          labelTeams.push(cfg.areaLabels.get(labelName)); // push all associated area labels to array
        }
      }); // add all issue label names and area label teams to issueLabels to labelTeams
      const areaLabelTeams = labelTeams.join(`, @${repoOwner}/`);
      const referencedAreaLabels = issueLabels.join("\", \""); // join corresponding area label teams into one string
      let labelGrammar;
      if (labelTeams.length > 1) {
        labelGrammar = "labels";
      } else if (labelTeams.length === 1) {
        labelGrammar = "label";
      } else return;
      const comment = `Hello @${repoOwner}/${areaLabelTeams} members, this issue was labeled with the "${referencedAreaLabels}" ${labelGrammar}, so you may want to check it out!`; // comment template
      github.issues.editComment({
        owner: repoOwner,
        repo: repoName,
        id: labelComment.id,
        body: comment
      }).catch(console.error);
    } else {
      const comment = `Hello @${repoOwner}/${areaLabelTeam} members, this issue was labeled with the **${areaLabel}** label, so you may want to check it out!`; // comment template
      newComment(repoOwner, repoName, issueNumber, comment); // create comment
    }
  });
};
<commit_msg>issues: Eliminate duplicate issue reference when labeled simultaneously.<commit_after>"use strict"; // catch errors easier

const github = require("../github.js"); // GitHub wrapper initialization
const cfg = require("../config.js"); // config file
const newComment = require("../issues/newComment.js"); // create comment
let referencedIssues = [];

module.exports = exports = function(areaLabel, issueNumber, repoName, repoOwner, issueLabelArray) {
  if (!cfg.areaLabels.has(areaLabel)) return; // if added label isn't an area label, return;
  github.issues.getComments({
    owner: repoOwner,
    repo: repoName,
    number: issueNumber,
    per_page: 100
  }).then((issueComments) => {
    let issueLabels = []; // initialize array for area labels
    let labelTeams = [];
    issueLabelArray.forEach((issueLabel) => {
      const labelName = issueLabel.name; // label name
      if (cfg.areaLabels.has(labelName) && !issueLabels.includes(labelName)) {
        issueLabels.push(labelName); // push all associated area labels to array
        labelTeams.push(cfg.areaLabels.get(labelName)); // push all associated area labels to array
      }
    }); // add all issue label names and area label teams to issueLabels to labelTeams
    const areaLabelTeams = labelTeams.join(`, @${repoOwner}/`);
    const referencedAreaLabels = issueLabels.join("**, **"); // join corresponding area label teams into one string
    let labelGrammar;
    if (labelTeams.length > 1) {
      labelGrammar = "labels";
    } else if (labelTeams.length === 1) {
      labelGrammar = "label";
    } else return;
    const comment = `Hello @${repoOwner}/${areaLabelTeams} members, this issue was labeled with the **${referencedAreaLabels}** ${labelGrammar}, so you may want to check it out!`; // comment template
    const labelComment = issueComments.data.find((issueComment) => {
      return issueComment.body.includes("this issue was labeled with the") && issueComment.user.login === cfg.username;
    });
    if (labelComment) {
      github.issues.editComment({
        owner: repoOwner,
        repo: repoName,
        id: labelComment.id,
        body: comment
      }).catch(console.error);
    } else {
      if (referencedIssues.includes(issueNumber)) return;
      newComment(repoOwner, repoName, issueNumber, comment); // create comment
      referencedIssues.push(issueNumber);
      setTimeout(() => {
        referencedIssues.splice(referencedIssues.indexOf(issueNumber), 1);
      }, 1000);
    }
  });
};

{'fraction_non_alphanumeric': 0.12792324605236857, 'fraction_numerical': 0.0029982010793523886, 'mean_word_length': 3.3588850174216027, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '2244591', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1355, 'n_words': 408}