Addition of Saving and Loading of Filter Presets [WIP]#4755
Addition of Saving and Loading of Filter Presets [WIP]#4755feyruzb wants to merge 21 commits intoEricsson:masterfrom
Conversation
There was a problem hiding this comment.
Overall good work, I've found only minor issues (even nitpicks) which can be fixed in no time. Please check the TODOs and comments with question marks and make them clear for the future. What I'm missing are the tests for the new functions. Please check them and write tests in the corresponding unit test folders.
web/api/completly-rebuild-thrift.sh
Outdated
| export PATH="$HOME/codechecker/build/CodeChecker/bin:$PATH" | ||
|
|
||
| echo "CodeChecker rebuild completed successfully!" | ||
| echo "You can now use CodeChecker commands." No newline at end of file |
There was a problem hiding this comment.
Add a new line to the end of the file, git can complain about missing new lines at the end of any text files.
web/api/report_server.thrift
Outdated
| // if the id is -1 a new preset filter is created | ||
| // the filter preset name must be unique. | ||
| // An error must be thrown if another preset exists with the same name. | ||
| // The encoding of the name must be unicode. (whitespaces allowed?) |
There was a problem hiding this comment.
In this line, "whitespaces allowed?" suggests me that this part is not yet complete. Please decide if either allowed or not and edit the comment accordingly.
| // Filter grouping api calls. | ||
| //============================================ | ||
|
|
||
| // Stores the given FilterPreset with the given id |
There was a problem hiding this comment.
I got a few questions / remarks regarding this part:
- Does it check the id of the incoming FilterPreset to decide if it exists or not? If so, please modify the first line accordingly (e.g. "If
thea preset exists with the given id, it overwrites the name, and all preset values.") - Fix the second line to match the first: "If the preset does not exist yet, it creates it with the given id.".
- The line "if the id is -1 a new preset filter is created" is confusing so if I add -1 as an id, it forcibly creates the filter? And if so, what will be the actual id after creation?
- Please make all new sentences start with a capital letter and finish with a dot.
web/api/report_server.thrift
Outdated
| FilterPreset getFilterPreset(1: i64 id) | ||
| throws (1: codechecker_api_shared.RequestFailed requestError); | ||
|
|
||
| // Removes the filterpreset with the given id |
There was a problem hiding this comment.
It should be written as "FilterPreset" to be uniform to the other comments.
| description=description)) | ||
| return results | ||
|
|
||
| # Stores the given FilterPreset with the given id |
There was a problem hiding this comment.
I suggest you do the same modifications I've suggested above for the same comment.
| if preset is None: | ||
| return None | ||
|
|
||
| # convert ORM to dict for ReportFilter |
There was a problem hiding this comment.
| # convert ORM to dict for ReportFilter | |
| # Convert ORM to dict for ReportFilter |
| if not token: | ||
| return "" | ||
|
|
||
| # special case for formatting confirmed bug. IN UI for some reason |
There was a problem hiding this comment.
| # special case for formatting confirmed bug. IN UI for some reason | |
| # Special case for formatting confirmed bug. IN UI for some reason |
| session.add(preset_entry) | ||
| session.commit() | ||
| return int(preset_entry.id) | ||
| return -1 |
There was a problem hiding this comment.
Not a terrible thing but some linters may complain about using magic numbers. You could create a const for it either here or in a global file (there might be already a file for status and error codes in codechecker) which you could use as a return value. E.g. FILTER_PRESET_ERROR = -1 or similar.
| Delete preset from products list based on preset_id. | ||
| """ | ||
| self.__require_admin() | ||
| LOG.info("deleting filter preset by id") |
There was a problem hiding this comment.
| LOG.info("deleting filter preset by id") | |
| LOG.info("Deleting filter preset by ID") |
| Returns the FilterPreset identified by id. | ||
| """ | ||
| self.__require_view() | ||
| LOG.info("Returning filter Preset by id") |
There was a problem hiding this comment.
| LOG.info("Returning filter Preset by id") | |
| LOG.info("Returning filter Preset by ID") |
|
One more thing which I've missed: Besides the unit tests, please also write functional tests, for the API too. |
3383a3f to
a738d47
Compare
481c8ad to
60a96ba
Compare
web/api/report_server.thrift
Outdated
|
|
||
| // Return name based on mapping based on value and classname. | ||
| // PERMISSION: PRODUCT_VIEW | ||
| string getNameByValueForFilter(1: string classname, |
There was a problem hiding this comment.
Where is this function used? If not needed, then it should be removed.
| help="Get report details for reports such as bug path " | ||
| "events, bug report points etc.") | ||
|
|
||
| parser.add_argument('--filterPreset', |
There was a problem hiding this comment.
Let's follow the naming conventions: --filter-preset.
| "is loaded from the server and applied to the " | ||
| "results. You can override specific filters by " | ||
| "providing additional filter arguments. Use " | ||
| "'CodeChecker cmd filterPreset list' to see " |
There was a problem hiding this comment.
Let's rename it filter-preset.
| action='store_true', | ||
| dest='force', | ||
| required=False, | ||
| help="Force deletion without confirmation.") |
There was a problem hiding this comment.
Resetting is forced here instead of deletion.
There was a problem hiding this comment.
Fixed, --force is deleted.
| __add_common_arguments(tasks, needs_product_url=False) | ||
|
|
||
| filter_preset = subcommands.add_parser( | ||
| 'filter_preset', |
There was a problem hiding this comment.
| 'filter_preset', | |
| 'filter-preset', |
| LOG.info("Filter preset was not deleted.") | ||
| sys.exit(0) | ||
|
|
||
| success = client.deleteFilterPreset(args.preset_id) |
There was a problem hiding this comment.
The function returns -1 in case of failure. That should be checked in the next statement. It would be even better if the function would throw an exception instead of returning -1 because that could explain the reason of error better.
web/api/report_server.thrift
Outdated
|
|
||
| // Removes the filterpreset with the given id | ||
| // returns the id of the filter preset removed | ||
| // and -1 in case of error. |
There was a problem hiding this comment.
The function should throw an error in case of error.
| ) | ||
|
|
||
| if preset is None: | ||
| return -1 |
There was a problem hiding this comment.
An error should be thrown. The return value of this function is FilterPreset according to the .thrift file.
|
|
||
| # Convert ORM to dict for ReportFilter | ||
| rf = preset.report_filter | ||
| if isinstance(rf, str): |
There was a problem hiding this comment.
How can this field be a different type? If it's possibly None, then that should be checked. I have the same question for the next fields, too.
| if not all_presets: | ||
| return [] | ||
|
|
||
| list_of_all_presets = [self.getFilterPreset(preset.id) for preset in all_presets] |
There was a problem hiding this comment.
The content of getFilterPreset() could go to a helper function that assembles a ReportFilter object based on a PresetFilter. This way it wouldn't be needed to do as many database queries as many presets we have.
There was a problem hiding this comment.
def transform(dbFilterPreset)
return thriftfilterpreset
getFilterPreset(id)
x = dbQuery(id)
transform(x)
listFilterPreset()
all = dbQuery
for blabla in all:
transform(blabla)
9aa6c06 to
3491e07
Compare
…oading presets when button pressed
3491e07 to
afc62e0
Compare
847d099 to
68e1cd3
Compare
68e1cd3 to
0132c0c
Compare
fa220f6 to
003fad6
Compare
This pull request introduces a new "filter preset" feature to CodeChecker, allowing users to create, manage, and apply named collections of filter configurations for analysis results. It includes updates to the Thrift API, CLI commands, and versioning to support this functionality. The most important changes are outlined below.
Filter Preset Feature Implementation
FilterPresetstruct and related API endpoints (storeFilterPreset,getFilterPreset,deleteFilterPreset,listFilterPreset) toreport_server.thriftfor managing filter presets on the server. [1] [2]cmd.py) to support newfilter-presetsubcommands (list,new,delete) for managing filter presets, and added a--filter-presetargument to allow users to apply a preset when running commands. [1] [2] [3]listoption can be used in 2 modes, first isjsonflag that displays full detailed information the rest likecsv,plaintextandtableuses summarization function that only displays existing filters in object.results.py.Versioning and Compatibility Updates
6.68.0inpackage.json,setup.py, andversion.pyto reflect the new feature and maintain compatibility.Developer Tooling
completly-rebuild-thrift.shto automate rebuilding the Thrift API and related environments for developers.Other API Enhancements
getNameByValueForFilterendpoint to the Thrift API for resolving names based on values and class names. !THIS FUNCTION IS GOING TO BE DELETED, IT IS IN PR UNTIL DECIDED OTHERWISE!