Skip to content

Commit

Permalink
fix: --task-tag parameter does not work with task-get command
Browse files Browse the repository at this point in the history
Fixes #225
  • Loading branch information
Göran Sander committed Mar 31, 2023
1 parent 1be932f commit 2201f36
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 103 deletions.
188 changes: 96 additions & 92 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,55 +134,55 @@
// ------------------------------------
// Export apps to QVF files
// ------------------------------------
"args": [
"app-export",
"--auth-type",
"cert",
"--host",
"192.168.100.109",
"--auth-cert-file",
"./cert/client.pem",
"--auth-cert-key-file",
"./cert/client_key.pem",
"--auth-user-dir",
"LAB",
"--auth-user-id",
"goran",
// "args": [
// "app-export",
// "--auth-type",
// "cert",
// "--host",
// "192.168.100.109",
// "--auth-cert-file",
// "./cert/client.pem",
// "--auth-cert-key-file",
// "./cert/client_key.pem",
// "--auth-user-dir",
// "LAB",
// "--auth-user-id",
// "goran",

"--app-tag",
"apiCreated",
"Ctrl-Q import",
// "--app-tag",
// "apiCreated",
// "Ctrl-Q import",

"--app-id",
"eb3ab049-d007-43d3-93da-5962f9208c65",
"2933711d-6638-41d4-a2d2-6dd2d965208b",
// "--app-id",
// "eb3ab049-d007-43d3-93da-5962f9208c65",
// "2933711d-6638-41d4-a2d2-6dd2d965208b",

"--exclude-app-data",
"false",
// "--exclude-app-data",
// "false",

"--qvf-name-format",
// "export-time",
"app-name",
"export-date",
// "--qvf-name-format",
// // "export-time",
// "app-name",
// "export-date",

"--qvf-name-separator",
"__",
// "--qvf-name-separator",
// "__",

"--output-dir",
"qvfs",
// "--output-dir",
// "qvfs",

// "--limit-export-count",
// "2",
// // "--limit-export-count",
// // "2",

"--sleep-app-export",
"500",
// "--sleep-app-export",
// "500",

"--qvf-overwrite",
// "--qvf-overwrite",

// "--dry-run"
// // "--dry-run"

"--metadata-file-create"
]
// "--metadata-file-create"
// ]


// ------------------------------------
Expand Down Expand Up @@ -311,61 +311,65 @@
// ------------------------------------
// Get reload tasks as CSV/Excel/JSON file
// ------------------------------------
// "args": [
// "task-get",
// "--auth-type",
// "cert",
// "--host",
// "192.168.100.109",
// "--auth-cert-file",
// "./cert/client.pem",
// "--auth-cert-key-file",
// "./cert/client_key.pem",
// "--auth-user-dir",
// "LAB",
// "--auth-user-id",
// "goran",
// // "--task-id",
// // "82bc3e66-c899-4e44-b52f-552145da5ee0",
// // "82bc3e66-c899-4e44-b52f-552145da5ee1",
// // "5748afa9-3abe-43ab-bb1f-127c48ced075",
// // "5520e710-91ad-41d2-aeb6-434cafbf366b",
// // "--task-tag",
// // "Abc 123",
// // "Butler 5.0 demo",

// "--output-format",
// "table",
"args": [
"task-get",
"--auth-type",
"cert",
"--host",
"192.168.100.109",
"--auth-cert-file",
"./cert/client.pem",
"--auth-cert-key-file",
"./cert/client_key.pem",
"--auth-user-dir",
"LAB",
"--auth-user-id",
"goran",
// "--task-id",
// "82bc3e66-c899-4e44-b52f-552145da5ee0",
// "82bc3e66-c899-4e44-b52f-552145da5ee1",
// "5748afa9-3abe-43ab-bb1f-127c48ced075",
// "5520e710-91ad-41d2-aeb6-434cafbf366b",
"--task-tag",
"Ctrl-Q demo",
// "Butler 5.0 demo",

"--output-format",
"table",

// "--output-dest",
// "file",
// "--output-file-name",
// // "tasks.xlsx",
// "tasks.csv",
// // "tasks2.json",
// // "tasks2.xlsx",
// "--output-file-format",
// // "excel",
// // "json",
// "csv",

// // "--text-color",
// // "no",

// "--output-file-overwrite",

// "--table-details",
// "common",
// // "lastexecution",
// "tag",
// // "customproperty",
// // "schematrigger",
// // "compositetrigger",
// // "comptimeconstraint",
// // "comprule",
// // "--log-level",
// // "debug"
// ]
"--output-dest",
"file",
"--output-file-name",
"tasks.xlsx",
// "tasks.csv",
// "tasks2.json",
// "tasks2.xlsx",
"--output-file-format",
"excel",
// "json",
// "csv",

"--output-file-name",
"reload-tasks.xlsx",

// "--text-color",
// "no",

"--output-file-overwrite",

// "--table-details",
// "common",
// "lastexecution",
// "tag",
// "customproperty",
// "schematrigger",
// "compositetrigger",
// "comptimeconstraint",
// "comprule",

// "--log-level",
// "debug"
]

// ------------------------------------
// Create custom property with user activity buckets
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1045,11 +1045,13 @@ Options:
-h, --help display help for command
```

The next example will export apps (including the data in them) that have either of two different tags set, plus two apps identified by app id.
If the QVF files exist a confirmation text will be shown for each existing app.
The name of the QVF files will be `<app name>_<exportdate>.qvf`.
QVF files will be stored in a subdirectory `qvf-export`.
An Excel file will be created, containing select metadata about the apps.
The next example will

- Export apps (including the data in them) that have either of two different tags set, plus two apps identified by app id.
- If the QVF files exist a confirmation text will be shown for each existing app.
- The name of the QVF files will be `<app name>_<exportdate>.qvf`.
- QVF files will be stored in a subdirectory `qvf-export`.
- An Excel file will be created, containing select metadata about the apps.

```
.\ctrl-q.exe app-export `
Expand Down Expand Up @@ -1133,7 +1135,7 @@ Mode LastWriteTime Length Name
```

The format of the created Excel file is almost identical as the one used when importing apps from QVF files, described [here](#source-file-columns-for-app-import-definitions).
The format of the created Excel file is almost identical to the one used when importing apps from QVF files, described [here](#source-file-columns-for-app-import-definitions).
The only difference is that the app export format includes an "App id" column, which is not required when importing apps.
App import will however work just fine if there is an "App id" column present, it just won't be used for anything.

Expand Down
2 changes: 1 addition & 1 deletion src/lib/cmd/exportapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const exportAppToFile = async (options) => {
}
return true;
} catch (err) {
logger.error(`GET TASK: ${err.stack}`);
logger.error(`EXPORT APP: ${err.stack}`);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/lib/cmd/importapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const importAppFromFile = async (options) => {
logger.debug(`Imported apps:\n${JSON.stringify(importedApps, null, 2)}`);
}
} catch (err) {
logger.error(`GET TASK: ${err.stack}`);
logger.error(`IMPORT APP: ${err.stack}`);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/lib/cmd/importtask.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ const importTaskFromFile = async (options) => {
await qlikSenseTasks.init(options, importedApps);
const taskList = await qlikSenseTasks.getTaskModelFromFile(tasksFromFile, tagsExisting, cpExisting);
} catch (err) {
logger.error(`GET TASK: ${err.stack}`);
logger.error(`IMPORT TASK: ${err.stack}`);
}
};

Expand Down
11 changes: 9 additions & 2 deletions src/lib/task/class_alltasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,13 @@ class QlikSenseTasks {
for (let i = 1; i < this.options.taskId.length; i += 1) {
filter += encodeURIComponent(` or id eq ${this.options.taskId[i]}`);
}
}

// Add closing parenthesis
if (this.options.taskId && this.options?.taskId.length >= 1) {
filter += encodeURIComponent(')');
logger.debug(`GET TASK: QRS query filter (incl ids): ${filter}`);
}
logger.debug(`GET TASK: QRS query filter (incl ids): ${filter}`);

// Add task tag(s) to query string
if (this.options.taskTag && this.options?.taskTag.length >= 1) {
Expand All @@ -769,9 +773,12 @@ class QlikSenseTasks {
for (let i = 1; i < this.options.taskTag.length; i += 1) {
filter += encodeURIComponent(` or tags.name eq '${this.options.taskTag[i]}'`);
}
}
// Add closing parenthesis
if (this.options.taskTag && this.options?.taskTag.length >= 1) {
filter += encodeURIComponent(')');
logger.debug(`GET TASK: QRS query filter (incl ids, tags): ${filter}`);
}
logger.debug(`GET TASK: QRS query filter (incl ids, tags): ${filter}`);

let axiosConfig;
if (filter === '') {
Expand Down

0 comments on commit 2201f36

Please sign in to comment.