www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 3aae8d3f897e1876e6274859074f43e9892ef4aa
parent 152c9bf9e7ee421d8e56db29adef7680b392c096
Author: Dan Stillman <dstillman@zotero.org>
Date:   Tue,  6 Jun 2006 19:06:40 +0000

Fix Scholar.getItems() to not trigger an SQL query for every item


Diffstat:
Mchrome/chromeFiles/content/scholar/xpcom/data_access.js | 16+++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/xpcom/data_access.js b/chrome/chromeFiles/content/scholar/xpcom/data_access.js @@ -802,6 +802,7 @@ Scholar.Items = new function(){ var loaded = new Array(); if (!arguments[0]){ + Scholar.debug('No arguments provided to Items.get()'); return false; } @@ -820,7 +821,7 @@ Scholar.Items = new function(){ } // If single id, return the object directly - if (arguments[0] && typeof arguments[0]!='Object' + if (arguments[0] && typeof arguments[0]!='object' && typeof arguments[1]=='undefined'){ return _items[arguments[0]]; } @@ -829,7 +830,7 @@ Scholar.Items = new function(){ for (i=0; i<ids.length; i++){ loaded[ids[i]] = _items[ids[i]]; } - + return loaded; } @@ -944,7 +945,6 @@ Scholar.Items = new function(){ + 'LEFT JOIN creators C ON (IC.creatorID=C.creatorID) ' + 'WHERE (IC.orderIndex=0 OR IC.orderIndex IS NULL)'; - Scholar.debug(arguments[0]); if (arguments[0]){ sql += ' AND I.itemID IN (' + Scholar.join(arguments,',') + ')'; } @@ -1828,13 +1828,11 @@ Scholar.getItems = function(parent){ return toReturn; } + // Items.get() returns an array indexed by itemID, + // so we have to turn it into a regular numeric array from 0 + var items = Scholar.Items.get(children) for (var i=0, len=children.length; i<len; i++){ - var obj = Scholar.Items.get(children[i]); - if (!obj){ - throw ('Item ' + children[i] + ' not found'); - } - - toReturn.push(obj); + toReturn.push(items[children[i]]); } return toReturn;