/** * Constrain the query with an ApplicationSearch index, requiring values * exist in a given range. * * This constraint is useful for expressing date ranges: * * - Find events between July 1st and July 7th. * * The ends of the range are inclusive, so a `$min` of `3` and a `$max` of * `5` will match fields with values `3`, `4`, or `5`. Providing `null` for * either end of the range will leave that end of the constraint open. * * @param PhabricatorCustomFieldIndexStorage Table where the index is stored. * @param int|null Minimum permissible value, inclusive. * @param int|null Maximum permissible value, inclusive. * @return this * @task appsearch */ public function withApplicationSearchRangeConstraint(PhabricatorCustomFieldIndexStorage $index, $min, $max) { $index_type = $index->getIndexValueType(); if ($index_type != 'int') { throw new Exception(pht('Attempting to apply a range constraint to a field with index type ' . '"%s", expected type "%s".', $index_type, 'int')); } $this->applicationSearchConstraints[] = array('type' => $index->getIndexValueType(), 'cond' => 'range', 'table' => $index->getTableName(), 'index' => $index->getIndexKey(), 'value' => array($min, $max)); return $this; }
protected function getConfiguration() { return array(self::CONFIG_COLUMN_SCHEMA => array('indexKey' => 'bytes12', 'indexValue' => 'sint64'), self::CONFIG_KEY_SCHEMA => array('key_join' => array('columns' => array('objectPHID', 'indexKey', 'indexValue')), 'key_find' => array('columns' => array('indexKey', 'indexValue')))) + parent::getConfiguration(); }