# HG changeset patch # User ymh # Date 1463044766 -7200 # Node ID 5f011170de740ad514e6367420ba2d15ecad5859 # Parent c77f06ff3e54c0c396d7f88a878f0f0cba0c0537 correct download of discourses fxtures diff -r c77f06ff3e54 -r 5f011170de74 cms/app-client/app/mirage/fixtures/discourses.js --- a/cms/app-client/app/mirage/fixtures/discourses.js Sun May 08 14:21:22 2016 +0200 +++ b/cms/app-client/app/mirage/fixtures/discourses.js Thu May 12 11:19:26 2016 +0200 @@ -1,1 +1,102 @@ -export default []; \ No newline at end of file +export default [ + { + "id": "http://ark.bnf.fr/ark:/12148/cb12481481z", + "count": 2524, + "label": "dialogue" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb11932135w", + "count": 1882, + "label": "entretiens" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb11955657q", + "count": 857, + "label": "lecture à haute voix" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb119317924", + "count": 653, + "label": "conversation" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb119829234", + "count": 629, + "label": "questionnaires" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb11937212q", + "count": 343, + "label": "narration" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb11946100d", + "count": 228, + "label": "paradigme (épistémologie)" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb119341539", + "count": 222, + "label": "discussion" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb11976851v", + "count": 219, + "label": "récits personnels" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb11936159v", + "count": 110, + "label": "contes" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb13319048g", + "count": 68, + "label": "chansons" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb11949715t", + "count": 43, + "label": "réunions" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb119783362", + "count": 36, + "label": "bavardage" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb11931724n", + "count": 23, + "label": "congrès et conférences" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb11957378b", + "count": 12, + "label": "musique instrumentale" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb119834877", + "count": 11, + "label": "récitation" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb12083158d", + "count": 11, + "label": "argumentation" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb11948542x", + "count": 7, + "label": "discours" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb120502737", + "count": 2, + "label": "enquêtes linguistiques" + }, + { + "id": "http://ark.bnf.fr/ark:/12148/cb11953414d", + "count": 1, + "label": "fables" + } +]; \ No newline at end of file diff -r c77f06ff3e54 -r 5f011170de74 common/corpus-common-addon/lib/commands/dl-fixtures.js --- a/common/corpus-common-addon/lib/commands/dl-fixtures.js Sun May 08 14:21:22 2016 +0200 +++ b/common/corpus-common-addon/lib/commands/dl-fixtures.js Thu May 12 11:19:26 2016 +0200 @@ -47,18 +47,15 @@ { name: 'page', type: Number, default: 1 , aliases: ['p'], description: 'number of page to download'}, { name: 'format', type: String, default: 'es6' , aliases: ['f'], description: 'Format for module export, es6 or require'} ], - dl_discourses: function(commandOptions) { - return this.dl_themes(commandOptions); - }, - dl_themes: function(commandOptions) { + dl_countmap: function(commandOptions, rootKey) { var done = Q.defer(); var that = this; request.get({url: commandOptions.url, json: true}, function (err, res, body) { var objectList = _.reduce( - _.keys(body.themes), - function(res, themeKey) { - var themeValue = body.themes[themeKey]; - res.push({id: themeKey, count: themeValue.count, label: themeValue.label}); + _.keys(body[rootKey]), + function(res, objKey) { + var objValue = body[rootKey][objKey]; + res.push({id: objKey, count: objValue.count, label: objValue.label}); return res; }, [] @@ -73,6 +70,12 @@ }); return done.promise; }, + dl_discourses: function(commandOptions) { + return this.dl_countmap(commandOptions, 'discourses'); + }, + dl_themes: function(commandOptions) { + return this.dl_countmap(commandOptions, 'themes'); + }, dl_documents: function(commandOptions, rawArgs) { // eslint-disable-line no-unused-vars var ids = [];