Skip to content

Commit

Permalink
Merge pull request #1592 from merico-dev/1591-cant-apply-preset-datas…
Browse files Browse the repository at this point in the history
…ource-of-type-merico_metric_system

1591 cant apply preset datasource of type merico metric system
  • Loading branch information
GerilLeto authored Dec 17, 2024
2 parents 0e4299e + eca9e4e commit 752b012
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/api",
"version": "14.3.3",
"version": "14.3.4",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
19 changes: 19 additions & 0 deletions api/src/preset/scripts/configure_datasources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class PresetDatasources {
@ValidateNested({ each: true })
@Type(() => DatabaseSource)
http: DatabaseSource[];

@ValidateNested({ each: true })
@Type(() => DatabaseSource)
merico_metric_system: DatabaseSource[];
}

async function upsert() {
Expand Down Expand Up @@ -112,6 +116,21 @@ async function upsert() {
dataSource.is_preset = true;
await datasourceRepo.save(dataSource);
}

for (const source of data.merico_metric_system) {
const { key } = validateClass(DatabaseSource, source);
const config = validateClass(BaseConfig, source.config);
let dataSource: DataSource | null;
dataSource = await datasourceRepo.findOneBy({ type: 'merico_metric_system', key });
if (!dataSource) {
dataSource = new DataSource();
dataSource.type = 'merico_metric_system';
dataSource.key = key;
}
dataSource.config = config;
dataSource.is_preset = true;
await datasourceRepo.save(dataSource);
}
await queryRunner.commitTransaction();
console.info('Finished upsert of preset datasources');
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/dashboard",
"version": "14.3.3",
"version": "14.3.4",
"license": "Apache-2.0",
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/root",
"version": "14.3.3",
"version": "14.3.4",
"private": true,
"workspaces": [
"api",
Expand Down
2 changes: 1 addition & 1 deletion settings-form/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/settings-form",
"version": "14.3.3",
"version": "14.3.4",
"license": "Apache-2.0",
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@devtable/website",
"private": true,
"license": "Apache-2.0",
"version": "14.3.3",
"version": "14.3.4",
"scripts": {
"dev": "vite",
"preview": "vite preview"
Expand Down

0 comments on commit 752b012

Please sign in to comment.