[MediaWiki-commits] [Gerrit] Bug fixes; incorrect indexing - change (mediawiki...citoid)

2014-11-21 Thread Mvolz (Code Review)
Mvolz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/174969

Change subject: Bug fixes; incorrect indexing
..

Bug fixes; incorrect indexing

Fixed several indexing issues.

In some cases (likely depending on Zotero version),
body is a either an Array of objects or an Array
of Array of objects, so convertTo methods were
fixed to deal with either case.

Additionally, convertTo methods incorrectly
produced bodies that were Array of Arrays
instead of Arrays.

Change-Id: I212abccef0f37584c6e3c2ee84293c55476ec237
---
M lib/zotero.js
1 file changed, 15 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/citoid 
refs/changes/69/174969/1

diff --git a/lib/zotero.js b/lib/zotero.js
index d2bba9e..f383ce4 100644
--- a/lib/zotero.js
+++ b/lib/zotero.js
@@ -51,7 +51,10 @@
 
 /*Specific conversion methods*/
 var convertToZoteroAsync = function (url, body, callback){
-   var citation = body[0][0];
+   var citation = body[0];
+   if (citation instanceof Array){
+   citation = citation[0];
+   }
 
async.waterfall([
function(cb){ //this function exists to pass url to fixURLAsync
@@ -60,13 +63,16 @@
fixURL, //must go directly after unnamed function that hands it 
url
fixAccessDate
], function (err, citation) {
-   callback([[citation]]);
+   callback([citation]);
});
 
 };
 
 var convertToMediawikiAsync = function (url, body, callback){
-   var citation = body[0][0];
+   var citation = body[0];
+   if (citation instanceof Array){
+   citation = citation[0];
+   }
 
async.waterfall([
function(cb){ //this function exists to pass url to fixURLAsync
@@ -79,7 +85,7 @@
fixISBN,
fixISSN
], function (err, citation) {
-   callback([[citation]]);
+   callback([citation]);
});
 
 };
@@ -87,7 +93,10 @@
 var convertToMWDeprecatedAsync = function (url, body, callback){
var zotCreators, creatorFieldName,
creatorTypeCount = {},
-   citation = body[0][0];
+   citation = body[0];
+   if (citation instanceof Array){
+   citation = citation[0];
+   }
 
async.waterfall([
function(cb){ //this function exists to pass url to fixURLAsync
@@ -122,7 +131,7 @@
fixISBN,
fixISSN
], function (err, citation) {
-   callback([[citation]]);
+   callback([citation]);
});
 
 };

-- 
To view, visit https://gerrit.wikimedia.org/r/174969
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I212abccef0f37584c6e3c2ee84293c55476ec237
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/citoid
Gerrit-Branch: master
Gerrit-Owner: Mvolz mv...@wikimedia.org

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Bug fixes; incorrect indexing - change (mediawiki...citoid)

2014-11-21 Thread Mvolz (Code Review)
Mvolz has submitted this change and it was merged.

Change subject: Bug fixes; incorrect indexing
..


Bug fixes; incorrect indexing

Fixed several indexing issues.

In some cases (likely depending on Zotero version),
body is a either an Array of objects or an Array
of Array of objects, so convertTo methods were
fixed to deal with either case.

Additionally, convertTo methods incorrectly
produced bodies that were Array of Arrays
instead of Arrays.

Change-Id: I212abccef0f37584c6e3c2ee84293c55476ec237
---
M lib/zotero.js
1 file changed, 15 insertions(+), 6 deletions(-)

Approvals:
  Mvolz: Verified; Looks good to me, approved



diff --git a/lib/zotero.js b/lib/zotero.js
index d2bba9e..f383ce4 100644
--- a/lib/zotero.js
+++ b/lib/zotero.js
@@ -51,7 +51,10 @@
 
 /*Specific conversion methods*/
 var convertToZoteroAsync = function (url, body, callback){
-   var citation = body[0][0];
+   var citation = body[0];
+   if (citation instanceof Array){
+   citation = citation[0];
+   }
 
async.waterfall([
function(cb){ //this function exists to pass url to fixURLAsync
@@ -60,13 +63,16 @@
fixURL, //must go directly after unnamed function that hands it 
url
fixAccessDate
], function (err, citation) {
-   callback([[citation]]);
+   callback([citation]);
});
 
 };
 
 var convertToMediawikiAsync = function (url, body, callback){
-   var citation = body[0][0];
+   var citation = body[0];
+   if (citation instanceof Array){
+   citation = citation[0];
+   }
 
async.waterfall([
function(cb){ //this function exists to pass url to fixURLAsync
@@ -79,7 +85,7 @@
fixISBN,
fixISSN
], function (err, citation) {
-   callback([[citation]]);
+   callback([citation]);
});
 
 };
@@ -87,7 +93,10 @@
 var convertToMWDeprecatedAsync = function (url, body, callback){
var zotCreators, creatorFieldName,
creatorTypeCount = {},
-   citation = body[0][0];
+   citation = body[0];
+   if (citation instanceof Array){
+   citation = citation[0];
+   }
 
async.waterfall([
function(cb){ //this function exists to pass url to fixURLAsync
@@ -122,7 +131,7 @@
fixISBN,
fixISSN
], function (err, citation) {
-   callback([[citation]]);
+   callback([citation]);
});
 
 };

-- 
To view, visit https://gerrit.wikimedia.org/r/174969
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I212abccef0f37584c6e3c2ee84293c55476ec237
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/citoid
Gerrit-Branch: master
Gerrit-Owner: Mvolz mv...@wikimedia.org
Gerrit-Reviewer: Mvolz mv...@wikimedia.org

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits