Skip to content

Commit e50e2f3

Browse files
committed
Make the cloumn used to locate a database row configurable.
1 parent 4bf65f2 commit e50e2f3

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

classes/DataWarehouse/Data/RawStatisticsConfiguration.php

+18
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,24 @@ public function getQueryTableDefinitions($realm)
156156
return $realmConfig['tables'];
157157
}
158158

159+
/**
160+
* Get the column name to use when looking up a record in the job viewer
161+
*
162+
* @param string $realm The name of a realm.
163+
* @return string
164+
*/
165+
public function getRecordIdentifierColumn($realm)
166+
{
167+
$realmConfig = $this->getRealmConfiguration($realm);
168+
if (!array_key_exists('record_identifier_column', $realmConfig)) {
169+
throw new Exception(sprintf(
170+
'Record Identifier setting not found for realm "%s"',
171+
$realm
172+
));
173+
}
174+
return $realmConfig['record_identifier_column'];
175+
}
176+
159177
/**
160178
* Get the field definitions for generating a query.
161179
*

classes/DataWarehouse/Query/Jobs/JobDataset.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public function __construct(
5151

5252
// This table is defined in the configuration file, but used in the section below.
5353
$factTable = $tables['jt'];
54-
5554
if (isset($parameters['primary_key'])) {
5655
$this->addPdoWhereCondition(new WhereCondition(new TableField($factTable, 'job_id'), "=", $parameters['primary_key']));
5756
} elseif (isset($parameters['job_identifier'])) {
@@ -62,7 +61,7 @@ public function __construct(
6261
$this->addPdoWhereCondition(new WhereCondition(new TableField($factTable, 'local_jobid'), '=', $matches[1]));
6362
$this->addPdoWhereCondition(new WhereCondition(new TableField($factTable, 'local_job_array_index'), '=', $matches[2]));
6463
} else {
65-
$this->addPdoWhereCondition(new WhereCondition(new TableField($factTable, 'local_job_id_raw'), '=', $matches[1]));
64+
$this->addPdoWhereCondition(new WhereCondition(new TableField($factTable, $config->getRecordIdentifierColumn('Jobs')), '=', $matches[1]));
6665
}
6766
} else {
6867
throw new Exception('invalid "job_identifier" query parameter');

configuration/rawstatistics.d/20_jobs.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@
376376
"documentation": "${HIERARCHY_BOTTOM_LEVEL_INFO}",
377377
"batchExport": true
378378
}
379-
]
379+
],
380+
"record_identifier_column": "local_jobid"
380381
}
381382
}

0 commit comments

Comments
 (0)