Removed useless 'project_id' column from 'build_meta' table.

This commit is contained in:
Dmitry Khomutov 2017-10-15 00:48:53 +07:00
commit 9e57de043e
7 changed files with 36 additions and 160 deletions

View file

@ -44,38 +44,6 @@ class BuildMetaStore extends Store
return null;
}
/**
* Get multiple BuildMeta by ProjectId.
* @return array
*/
public function getByProjectId($value, $limit = 1000, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build_meta}} WHERE {{project_id}} = :project_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':project_id', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
if ($stmt->execute()) {
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$map = function ($item) {
return new BuildMeta($item);
};
$rtn = array_map($map, $res);
$count = count($rtn);
return ['items' => $rtn, 'count' => $count];
} else {
return ['items' => [], 'count' => 0];
}
}
/**
* Get multiple BuildMeta by BuildId.
* @return array

View file

@ -269,8 +269,7 @@ class BuildStore extends Store
$query = 'SELECT bm.build_id, bm.meta_key, bm.meta_value
FROM {{build_meta}} AS {{bm}}
LEFT JOIN {{build}} AS {{b}} ON b.id = bm.build_id
WHERE bm.meta_key = :key
AND bm.project_id = :projectId';
WHERE bm.meta_key = :key AND b.project_id = :projectId';
// If we're getting comparative meta data, include previous builds
// otherwise just include the specified build ID:
@ -318,20 +317,20 @@ class BuildStore extends Store
/**
* Set a metadata value for a given project and build ID.
* @param $projectId
*
* @param $buildId
* @param $key
* @param $value
*
* @return bool
*/
public function setMeta($projectId, $buildId, $key, $value)
public function setMeta($buildId, $key, $value)
{
$cols = '{{project_id}}, {{build_id}}, {{meta_key}}, {{meta_value}}';
$query = 'INSERT INTO {{build_meta}} ('.$cols.') VALUES (:projectId, :buildId, :key, :value)';
$cols = '{{build_id}}, {{meta_key}}, {{meta_value}}';
$query = 'INSERT INTO {{build_meta}} ('.$cols.') VALUES (:buildId, :key, :value)';
$stmt = Database::getConnection('read')->prepareCommon($query);
$stmt->bindValue(':key', $key, \PDO::PARAM_STR);
$stmt->bindValue(':projectId', (int)$projectId, \PDO::PARAM_INT);
$stmt->bindValue(':buildId', (int)$buildId, \PDO::PARAM_INT);
$stmt->bindValue(':value', $value, \PDO::PARAM_STR);