Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion robotframework_dashboard/abstractdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def run_start_exists(self, run_start: str) -> bool:

@abstractmethod
def insert_output_data(
self, output_data: dict, tags: list, run_alias: str, path: Path, project_version: str, timezone: str = ""
self, output_data: dict, tags: list, run_alias: str, path: Path, project_version: str, custom_filters, timezone
) -> None:
"""Mandatory: This function inserts the data of an output file into the database"""
pass # pragma: no cover
Expand Down
15 changes: 15 additions & 0 deletions robotframework_dashboard/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,20 @@ def _parse_arguments(self):
type=str,
default=None,
)
input_group.add_argument(
"--customfilters",
help=(
"Custom filter key=value pairs for the processed runs.\n"
" • Format: 'key1=value1:key2=value2'\n"
" • Each key becomes a separate filter dropdown in the dashboard\n"
"Examples:\n"
" • '--customfilters ComponentARelease=1.1:ComponentBRelease=2.5'\n"
),
dest="custom_filters",
metavar="FILTERS",
type=str,
default=None,
)
input_group.add_argument(
"-z",
"--timezone",
Expand Down Expand Up @@ -616,6 +630,7 @@ def _process_arguments(self, arguments):
"offline_dependencies": offline_dependencies,
"force_json_config": force_json_config,
"project_version": arguments.project_version,
"custom_filters": arguments.custom_filters,
"no_vacuum": no_vacuum,
"timezone": timezone,
"no_autoupdate": no_autoupdate,
Expand Down
19 changes: 13 additions & 6 deletions robotframework_dashboard/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ def get_keywords_length():
if run_table_length == 13: # -> column project_version not present
self.connection.cursor().execute(RUN_TABLE_UPDATE_PROJECT_VERSION)
self.connection.commit()
run_table_length = get_runs_length()
if run_table_length == 14: # -> column custom_filters not present
self.connection.cursor().execute(RUN_TABLE_UPDATE_CUSTOM_FILTERS)
self.connection.commit()

suite_table_length = get_suites_length()
if suite_table_length == 9:
Expand Down Expand Up @@ -140,12 +144,13 @@ def insert_output_data(
run_alias: str,
path: Union[Path, str],
project_version: str,
custom_filters: str = "",
timezone: str = "",
):
"""This function inserts the data of an output file into the database"""
try:
self._insert_runs(
output_data["runs"], tags, run_alias, path, project_version, timezone
output_data["runs"], tags, run_alias, path, project_version, custom_filters, timezone
)
self._insert_suites(output_data["suites"], run_alias, timezone)
self._insert_tests(output_data["tests"], run_alias, timezone)
Expand All @@ -154,7 +159,7 @@ def insert_output_data(
print(f" ERROR: something went wrong with the database: {error}")

def _insert_runs(
self, runs: list, tags: list, run_alias: str, path: Union[Path, str], project_version, timezone: str = ""
self, runs: list, tags: list, run_alias: str, path: Union[Path, str], project_version, custom_filters, timezone
):
"""Helper function to insert the run data with the run tags"""
full_runs = []
Expand All @@ -170,6 +175,7 @@ def _insert_runs(
str(path),
metadata,
project_version,
custom_filters,
)
full_runs.append(new_run)
self.connection.executemany(INSERT_INTO_RUNS, full_runs)
Expand Down Expand Up @@ -348,18 +354,19 @@ def _dict_from_row(self, row: sqlite3.Row):
def _get_runs(self):
"""Helper function to get the run data"""
data = self.connection.cursor().execute(SELECT_RUN_DATA).fetchall()
runs, names, aliases, tags = [], [], [], []
runs, names, aliases, tags, custom_filters = [], [], [], [], []
for entry in data:
entry = self._dict_from_row(entry)
runs.append(entry["run_start"])
names.append(entry["name"])
aliases.append(entry["run_alias"])
tags.append(entry["tags"])
return runs, names, aliases, tags
custom_filters.append(entry.get("custom_filters") or "")
return runs, names, aliases, tags, custom_filters

def list_runs(self):
"""This function gets all available runs and prints them to the console"""
run_starts, run_names, run_aliases, run_tags = self._get_runs()
run_starts, run_names, run_aliases, run_tags, _ = self._get_runs()
for index, run_start in enumerate(run_starts):
print(
f" Run {str(index).ljust(3, ' ')} | {run_start} | {run_names[index]}"
Expand All @@ -378,7 +385,7 @@ def _get_run_paths(self):

def remove_runs(self, remove_runs: list):
"""This function removes all provided runs and all their corresponding data"""
run_starts, run_names, run_aliases, run_tags = self._get_runs()
run_starts, run_names, run_aliases, run_tags, _ = self._get_runs()
console = ""
for run in remove_runs:
try:
Expand Down
3 changes: 3 additions & 0 deletions robotframework_dashboard/js/admin_page/admin_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function add_output_file() {
formData.append("file", file)
formData.append("tags", document.getElementById("outputFileTags").value)
formData.append("version", document.getElementById("outputFileVersion").value)
formData.append("custom_filters", document.getElementById("outputFileCustomFilters").value)

send_request("POST", "/add-output-file", formData, "addFileSpinner")
}
Expand Down Expand Up @@ -151,6 +152,7 @@ function get_outputs() {
run.name ?? "",
run.alias ?? "",
Array.isArray(run.tags) ? run.tags.join(", ") : (run.tags ?? ""),
run.custom_filters ?? "",
])

if (runTable) {
Expand All @@ -165,6 +167,7 @@ function get_outputs() {
{ title: "Run Name" },
{ title: "Run Alias" },
{ title: "Run Tags" },
{ title: "Custom Filters" },
],
data: data,
});
Expand Down
2 changes: 2 additions & 0 deletions robotframework_dashboard/js/eventlisteners.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
setup_lowest_highest_dates,
clear_all_filters,
setup_project_versions_in_select_filter_buttons,
setup_custom_filters_in_select_filter_buttons,
update_overview_version_select_list,
setup_metadata_filter,
build_profile_from_checks,
Expand Down Expand Up @@ -250,6 +251,7 @@ function setup_filter_modal() {
setup_runs_in_select_filter_buttons();
setup_runtags_in_select_filter_buttons();
setup_project_versions_in_select_filter_buttons();
setup_custom_filters_in_select_filter_buttons();
// snapshot the default/initial filter state so profile checkboxes can reflect changes
capture_default_filters();
// filter profiles setup
Expand Down
Loading
Loading