[duplicates] DOIs are not case sensitive
This commit is contained in:
parent
d291084af6
commit
d30ab9cc4f
|
@ -124,6 +124,18 @@ Zotero.Duplicates.prototype._findDuplicates = function () {
|
|||
return str;
|
||||
}
|
||||
|
||||
function sortByValue(a, b) {
|
||||
if((a.value === null && b.value !== null)
|
||||
|| (a.value === undefined && b.value !== undefined)
|
||||
|| a.value < b.value) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(a.value === b.value) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} compareRows Comparison function, if not exact match
|
||||
* @param {Boolean} reprocessMatches Compare every row against every other,
|
||||
|
@ -181,8 +193,7 @@ Zotero.Duplicates.prototype._findDuplicates = function () {
|
|||
var sql = "SELECT itemID, value FROM items JOIN itemData USING (itemID) "
|
||||
+ "JOIN itemDataValues USING (valueID) "
|
||||
+ "WHERE libraryID=? AND itemTypeID=? AND fieldID=? "
|
||||
+ "AND itemID NOT IN (SELECT itemID FROM deletedItems) "
|
||||
+ "ORDER BY value";
|
||||
+ "AND itemID NOT IN (SELECT itemID FROM deletedItems)";
|
||||
var rows = Zotero.DB.query(
|
||||
sql,
|
||||
[
|
||||
|
@ -194,25 +205,28 @@ Zotero.Duplicates.prototype._findDuplicates = function () {
|
|||
var isbnCache = {};
|
||||
if (rows) {
|
||||
for each(var row in rows) {
|
||||
isbnCache[row.itemID] = (row.value+'').replace(/[^\dX]+/ig, '').toUpperCase(); //ignore formatting
|
||||
}
|
||||
row.value = (row.value+'').replace(/[^\dX]+/ig, '').toUpperCase(); //ignore formatting
|
||||
isbnCache[row.itemID] = row.value;
|
||||
}
|
||||
rows.sort(sortByValue);
|
||||
processRows();
|
||||
}
|
||||
|
||||
// DOI
|
||||
var sql = "SELECT itemID, value FROM items JOIN itemData USING (itemID) "
|
||||
+ "JOIN itemDataValues USING (valueID) "
|
||||
+ "WHERE libraryID=? AND fieldID=? AND REGEXP('^10\\.', value) "
|
||||
+ "AND itemID NOT IN (SELECT itemID FROM deletedItems) "
|
||||
+ "ORDER BY value";
|
||||
+ "AND itemID NOT IN (SELECT itemID FROM deletedItems)";
|
||||
var rows = Zotero.DB.query(sql, [this._libraryID, Zotero.ItemFields.getID('DOI')]);
|
||||
var doiCache = {};
|
||||
if (rows) {
|
||||
for each(var row in rows) {
|
||||
doiCache[row.itemID] = row.value.toString().trim();
|
||||
}
|
||||
row.value = (row.value+'').trim().toUpperCase(); //DOIs are case insensitive
|
||||
doiCache[row.itemID] = row.value;
|
||||
}
|
||||
rows.sort(sortByValue);
|
||||
processRows();
|
||||
}
|
||||
|
||||
// Get years
|
||||
var dateFields = [Zotero.ItemFields.getID('date')].concat(
|
||||
|
@ -242,24 +256,22 @@ Zotero.Duplicates.prototype._findDuplicates = function () {
|
|||
+ "WHERE libraryID=? AND fieldID BETWEEN 110 AND 113 "
|
||||
+ "AND itemTypeID NOT IN (1, 14) "
|
||||
+ "AND itemID NOT IN (SELECT itemID FROM deletedItems)";
|
||||
var rows = Zotero.DB.query(sql, [this._libraryID]) || [];
|
||||
// Normalize all values ahead of time
|
||||
var rows = Zotero.DB.query(sql, [this._libraryID]);
|
||||
if(rows) {
|
||||
//normalize all values ahead of time
|
||||
rows = rows.map(function(row) {
|
||||
row.value = normalizeString(row.value);
|
||||
return row;
|
||||
});
|
||||
// Sort rows by normalized values
|
||||
rows = rows.sort(function(a, b) {
|
||||
if(a.value === b.value) return 0;
|
||||
if(a.value < b.value) return -1;
|
||||
return 1;
|
||||
});
|
||||
//sort rows by normalized values
|
||||
rows.sort(sortByValue);
|
||||
|
||||
processRows(function (a, b) {
|
||||
var aTitle = a.value;
|
||||
var bTitle = b.value;
|
||||
|
||||
// If we stripped one of the strings completely, we can't compare them
|
||||
if (aTitle.length == 0 || bTitle.length == 0) {
|
||||
if(!aTitle || !bTitle) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -340,6 +352,7 @@ Zotero.Duplicates.prototype._findDuplicates = function () {
|
|||
|
||||
return 0;
|
||||
}, true);
|
||||
}
|
||||
|
||||
// Match on exact fields
|
||||
/*var fields = [''];
|
||||
|
|
Loading…
Reference in New Issue
Block a user