<commit_before>"use strict"
const logger = require('../config/logger').mainLogger

const ACCESSLEVELS = require('../models/user').ACCESSLEVELS

/**
 * View only started runs to public
 * @param user
 * @param run
 */
function authViewRun(user, run) {
  if (user == null) {
    return run.started !== undefined && run.started
  } else {
    return authRun(user, run, ACCESSLEVELS.NONE + 1)
  }
}
module.exports.authViewRun = authViewRun

function authRun(user, run, level) {
  if (user == null) {
    return false
  }

  if (user.superDuperAdmin) {
    return true
  }

  if (authCompetition(user, run.competition, level)) {
    for (let i = 0; i < run.judges.length; i++) {
      const comp = user.competitions[i]
      if (comp[i].id == competitionId && comp[i].accessLevel >= authLevels) {
        return true
      }
    }
  }
  return false
}
module.exports.authRun = authRun

function authCompetition(user, competitionId, level) {
  if (user == null) {
    return false
  }

  if (user.superDuperAdmin) {
    return true
  }

  if (user.competitions != undefined) {
    for (let i = 0; i < user.competitions.length; i++) {
      const comp = user.competitions[i]
      if (comp != null && comp[i].id == competitionId && comp[i].accessLevel >= level) {
        return true
      }
    }
  }
  return false
}
module.exports.authCompetition = authCompetition<commit_msg>Removed incorrect indexing<commit_after>"use strict"
const logger = require('../config/logger').mainLogger

const ACCESSLEVELS = require('../models/user').ACCESSLEVELS

/**
 * View only started runs to public
 * @param user
 * @param run
 */
function authViewRun(user, run) {
  if (user == null) {
    return run.started !== undefined && run.started
  } else {
    return authRun(user, run, ACCESSLEVELS.NONE + 1)
  }
}
module.exports.authViewRun = authViewRun

function authRun(user, run, level) {
  if (user == null) {
    return false
  }

  if (user.superDuperAdmin) {
    return true
  }

  if (authCompetition(user, run.competition, level)) {
    for (let i = 0; i < run.judges.length; i++) {
      const comp = user.competitions[i]
      if (comp[i].id == competitionId && comp[i].accessLevel >= authLevels) {
        return true
      }
    }
  }
  return false
}
module.exports.authRun = authRun

function authCompetition(user, competitionId, level) {
  if (user == null) {
    return false
  }

  if (user.superDuperAdmin) {
    return true
  }

  if (user.competitions != undefined) {
    for (let i = 0; i < user.competitions.length; i++) {
      const comp = user.competitions[i]
      if (comp.id == competitionId && comp.accessLevel >= level) {
        return true
      }
    }
  }
  return false
}
module.exports.authCompetition = authCompetition
{'fraction_non_alphanumeric': 0.13455210237659965, 'fraction_numerical': 0.0021937842778793418, 'mean_word_length': 2.959479015918958, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '470390', 'n_tokens_mistral': 913, 'n_tokens_neox': 891, 'n_words': 225}