Closes #148, Optimize Zotero.Item.getSource()
This commit is contained in:
parent
b1a51f900d
commit
30b3898235
2 changed files with 7 additions and 2 deletions
|
@ -402,6 +402,9 @@ Zotero.Item.prototype.loadFromRow = function(row, reload) {
|
|||
this['_' + col] = row[col] ? parseInt(row[col]) : 0;
|
||||
break;
|
||||
|
||||
case 'sourceItemID':
|
||||
this['_sourceItem'] = row[col] || false;
|
||||
|
||||
default:
|
||||
this['_' + col] = row[col] ? row[col] : '';
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ Zotero.Items = new function() {
|
|||
_primaryFields = Zotero.DB.getColumns('items');
|
||||
_primaryFields.splice(_primaryFields.indexOf('clientDateModified'), 1);
|
||||
_primaryFields = _primaryFields.concat(
|
||||
['firstCreator', 'numNotes', 'numAttachments']
|
||||
['firstCreator', 'numNotes', 'numAttachments', 'sourceItemID']
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -749,7 +749,9 @@ Zotero.Items = new function() {
|
|||
+ "(SELECT COUNT(*) FROM itemNotes INo WHERE sourceItemID=I.itemID AND "
|
||||
+ "INo.itemID NOT IN (SELECT itemID FROM deletedItems)) AS numNotes, "
|
||||
+ "(SELECT COUNT(*) FROM itemAttachments IA WHERE sourceItemID=I.itemID AND "
|
||||
+ "IA.itemID NOT IN (SELECT itemID FROM deletedItems)) AS numAttachments "
|
||||
+ "IA.itemID NOT IN (SELECT itemID FROM deletedItems)) AS numAttachments, "
|
||||
+ "(CASE I.itemTypeID WHEN 14 THEN (SELECT sourceItemID FROM itemAttachments IA WHERE IA.itemID=I.itemID) "
|
||||
+ "WHEN 1 THEN (SELECT sourceItemID FROM itemNotes INo WHERE INo.itemID=I.itemID) END) AS sourceItemID "
|
||||
+ 'FROM items I WHERE 1';
|
||||
if (arguments[0]) {
|
||||
sql += ' AND I.itemID IN (' + Zotero.join(arguments[0], ',') + ')';
|
||||
|
|
Loading…
Reference in a new issue