<commit_before><?php

/**
 * Job.UpdatePaymentReference API specification (optional)
 * This is used for documentation and validation.
 *
 * @param array $spec description of fields supported by this API call
 * @return void
 * @see http://wiki.civicrm.org/confluence/display/CRMDOC/API+Architecture+Standards
 */
function _civicrm_api3_job_update_payment_reference_spec(&$spec) {
}

/**
 * Job.UpdatePaymentReference API
 *
 * @param array $params
 * @return array API result descriptor
 * @see civicrm_api3_create_success
 * @see civicrm_api3_create_error
 * @throws API_Exception
 */
function civicrm_api3_job_update_payment_reference($params) {

  if (!isset($params['step'])) {
    $params['step'] = 100;
  }

  $total = CRM_Core_DAO::singleValueQuery('SELECT count(1) FROM civicrm_contact WHERE is_deleted=0');

  $customFieldId = civicrm_api3('CustomField', 'getvalue', [
    'name' => 'paymentReference',
    'return' => 'id',
  ]);

  $count = 0;
  $offset = 0;

  while ($offset < $total) {
    $sql = 'SELECT id FROM civicrm_contact WHERE is_deleted=0 LIMIT %1 OFFSET %2';
    $dao = CRM_Core_DAO::executeQuery($sql, [
      '1' => [$params['step'], 'Integer'],
      '2' => [$offset, 'Integer'],
    ]);
    while ($dao->fetch()) {
      $cid = $dao->id;
      civicrm_api3('Contact', 'create', [
        'id' => $cid,
        'custom_' . $customFieldId => CRM_Paymentreference_Utils::paymentReference(8, $cid),
      ]);
      $count++;
    }
    CRM_Core_DAO::freeResult();
    $offset += $params['step'];
  }

  $returnValues = array('nr updates' => $count, 'step' => $params['step']);
  return civicrm_api3_create_success($returnValues, $params, 'Job', 'UpdatePaymentReference');

}<commit_msg>Moet 8100 zijn<commit_after><?php

/**
 * Job.UpdatePaymentReference API specification (optional)
 * This is used for documentation and validation.
 *
 * @param array $spec description of fields supported by this API call
 * @return void
 * @see http://wiki.civicrm.org/confluence/display/CRMDOC/API+Architecture+Standards
 */
function _civicrm_api3_job_update_payment_reference_spec(&$spec) {
}

/**
 * Job.UpdatePaymentReference API
 *
 * @param array $params
 * @return array API result descriptor
 * @see civicrm_api3_create_success
 * @see civicrm_api3_create_error
 * @throws API_Exception
 */
function civicrm_api3_job_update_payment_reference($params) {

  if (!isset($params['step'])) {
    $params['step'] = 100;
  }

  $total = CRM_Core_DAO::singleValueQuery('SELECT count(1) FROM civicrm_contact WHERE is_deleted=0');

  $customFieldId = civicrm_api3('CustomField', 'getvalue', [
    'name' => 'paymentReference',
    'return' => 'id',
  ]);

  $count = 0;
  $offset = 0;

  while ($offset < $total) {
    $sql = 'SELECT id FROM civicrm_contact WHERE is_deleted=0 LIMIT %1 OFFSET %2';
    $dao = CRM_Core_DAO::executeQuery($sql, [
      '1' => [$params['step'], 'Integer'],
      '2' => [$offset, 'Integer'],
    ]);
    while ($dao->fetch()) {
      $cid = $dao->id;
      civicrm_api3('Contact', 'create', [
        'id' => $cid,
        'custom_' . $customFieldId => CRM_Paymentreference_Utils::paymentReference(8100, $cid),
      ]);
      $count++;
    }
    CRM_Core_DAO::freeResult();
    $offset += $params['step'];
  }

  $returnValues = array('nr updates' => $count, 'step' => $params['step']);
  return civicrm_api3_create_success($returnValues, $params, 'Job', 'UpdatePaymentReference');

}
{'fraction_non_alphanumeric': 0.16121495327102803, 'fraction_numerical': 0.013726635514018691, 'mean_word_length': 4.229007633587786, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, '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': '2632463', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1140, 'n_words': 238}