<commit_before><?php

final class PhabricatorFactChartFunction
  extends PhabricatorChartFunction {

  const FUNCTIONKEY = 'fact';

  private $fact;
  private $map;
  private $refs;

  protected function newArguments() {
    $key_argument = $this->newArgument()
      ->setName('fact-key')
      ->setType('fact-key');

    $parser = $this->getArgumentParser();
    $parser->parseArgument($key_argument);

    $fact = $this->getArgument('fact-key');
    $this->fact = $fact;

    return $fact->getFunctionArguments();
  }

  public function loadData() {
    $fact = $this->fact;

    $key_id = id(new PhabricatorFactKeyDimension())
      ->newDimensionID($fact->getKey());
    if (!$key_id) {
      return;
    }

    $table = $fact->newDatapoint();
    $conn = $table->establishConnection('r');
    $table_name = $table->getTableName();

    $where = array();

    $where[] = qsprintf(
      $conn,
      'keyID = %d',
      $key_id);

    $parser = $this->getArgumentParser();

    $parts = $fact->buildWhereClauseParts($conn, $parser);
    foreach ($parts as $part) {
      $where[] = $part;
    }

    $data = queryfx_all(
      $conn,
      'SELECT id, value, epoch FROM %T WHERE %LA ORDER BY epoch ASC',
      $table_name,
      $where);

    $map = array();
    $refs = array();<commit_msg>Return empty data if fact dimension is missing, not yet available<commit_after><?php

final class PhabricatorFactChartFunction
  extends PhabricatorChartFunction {

  const FUNCTIONKEY = 'fact';

  private $fact;
  private $map;
  private $refs;

  protected function newArguments() {
    $key_argument = $this->newArgument()
      ->setName('fact-key')
      ->setType('fact-key');

    $parser = $this->getArgumentParser();
    $parser->parseArgument($key_argument);

    $fact = $this->getArgument('fact-key');
    $this->fact = $fact;

    return $fact->getFunctionArguments();
  }

  public function loadData() {
    $fact = $this->fact;

    $key_id = id(new PhabricatorFactKeyDimension())
      ->newDimensionID($fact->getKey());
    if (!$key_id) {
      $this->map = array();
      return;
    }

    $table = $fact->newDatapoint();
    $conn = $table->establishConnection('r');
    $table_name = $table->getTableName();

    $where = array();

    $where[] = qsprintf(
      $conn,
      'keyID = %d',
      $key_id);

    $parser = $this->getArgumentParser();

    $parts = $fact->buildWhereClauseParts($conn, $parser);
    foreach ($parts as $part) {
      $where[] = $part;
    }

    $data = queryfx_all(
      $conn,
      'SELECT id, value, epoch FROM %T WHERE %LA ORDER BY epoch ASC',
      $table_name,
      $where);

    $map = array();
    $refs = array();
{'fraction_non_alphanumeric': 0.16454749439042632, 'fraction_numerical': 0.0, 'mean_word_length': 2.974739970282318, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, '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': '3870322', 'n_tokens_mistral': 889, 'n_tokens_neox': 864, 'n_words': 189}