mirror of
https://github.com/zotero/zotero.git
synced 2026-10-04 02:31:47 +00:00
Local API: Improve search debugging
Use our own method in order to debug scopes, with a new getter for that property.
This commit is contained in:
parent
7da9c0669d
commit
e921a4bc7f
2 changed files with 16 additions and 1 deletions
|
|
@ -93,6 +93,9 @@ Zotero.defineProperty(Zotero.Search.prototype, 'synced', {
|
|||
Zotero.defineProperty(Zotero.Search.prototype, 'conditions', {
|
||||
get: function () { return this.getConditions(); }
|
||||
});
|
||||
Zotero.defineProperty(Zotero.Search.prototype, 'scope', {
|
||||
get: function() { return this._scope; }
|
||||
});
|
||||
Zotero.defineProperty(Zotero.Search.prototype, '_canHaveParent', {
|
||||
value: false
|
||||
});
|
||||
|
|
|
|||
|
|
@ -661,7 +661,7 @@ Zotero.Server.LocalAPI.Items = class extends LocalAPIEndpoint {
|
|||
);
|
||||
|
||||
Zotero.debug('Executing local API search');
|
||||
Zotero.debug(search.toJSON());
|
||||
Zotero.debug(searchToDebugJSON(search));
|
||||
// Searches sometimes return duplicate IDs; de-duplicate first
|
||||
// TODO: Fix in search.js
|
||||
let uniqueResultIDs = [...new Set(await search.search())];
|
||||
|
|
@ -1042,4 +1042,16 @@ function buildSearchFromSearchSyntax(parentSearch, searchStrings, condition) {
|
|||
return parentSearch;
|
||||
}
|
||||
|
||||
function searchToDebugJSON(search) {
|
||||
return {
|
||||
conditions: Object.values(search.conditions).map(condition => ({
|
||||
condition: condition.condition,
|
||||
operator: condition.operator,
|
||||
value: condition.value
|
||||
})),
|
||||
libraryID: search.libraryID,
|
||||
scope: search.scope ? searchToDebugJSON(search.scope) : undefined
|
||||
};
|
||||
}
|
||||
|
||||
class BadRequestError extends Error {}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue