Search restrictions and search_getting_ids
I had to jump through quite a few hoops with the Find Duplicates plugin and facing some similar (but not identical) issues with Quality Check.
The issue is search restrictions and a clean way of passing a valid restriction to search_getting_ids().
Originally in QualityCheck I applied an actual search to the library view (like "formats:epub") before grabbing all the ids in the view. Thus I was able to avoid thinking about restrictions, as they were applied transparently in the background to the view, and whether the restriction was or was not in place was irrelevant to my plugin.
However this approach does not work if the user has highlighting turned on, as the set of ids I was getting back from the model of course cover all rows with just the epub ones highlighted.
So instead I changed to use "db.search_getting_ids()" which is a nicer approach anyway (since I don't have to change the view).
The second parameter is the search restriction to be applied. This is where things come unstuck, which is likely entirely due to my ignorance. I need to get a search restriction value to pass to the search_getting_ids() call every time I want to use it, in order to respect any search restriction that might be applied.
Where do I get a value from that represents a search restriction that search_getting_ids will understand? I cannot use gui.search.search_restriction as that only works for "current" type search restrictions, not for saved searches.
Hopefully there is a simple value somewhere I can use... ?
|