correctly recalculate document count
This commit is contained in:
@@ -70,7 +70,6 @@ var costco = function() {
|
|||||||
function(updatedDocs) {
|
function(updatedDocs) {
|
||||||
util.notify(updatedDocs.length + " documents updated successfully");
|
util.notify(updatedDocs.length + " documents updated successfully");
|
||||||
recline.initializeTable(app.offset);
|
recline.initializeTable(app.offset);
|
||||||
recline.updateDocCount();
|
|
||||||
dfd.resolve(updatedDocs);
|
dfd.resolve(updatedDocs);
|
||||||
},
|
},
|
||||||
function(err) {
|
function(err) {
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ var recline = function() {
|
|||||||
|
|
||||||
if (rows.length < 1) {
|
if (rows.length < 1) {
|
||||||
util.render('dataTable', 'data-table-container');
|
util.render('dataTable', 'data-table-container');
|
||||||
updateDocCount();
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -138,22 +137,18 @@ var recline = function() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateDocCount() {
|
function updateDocCount(totalDocs) {
|
||||||
return couch.request({url: app.baseURL + 'api/_all_docs?' + $.param({startkey: '"_design/"', endkey: '"_design0"'})}).then(
|
return couch.request({url: app.baseURL + 'api/_all_docs?' + $.param({startkey: '"_design/"', endkey: '"_design0"'})}).then(
|
||||||
function ( data ) {
|
function ( data ) {
|
||||||
var ddocCount = data.rows.length;
|
var ddocCount = data.rows.length;
|
||||||
$('#docCount').text(app.dbInfo.doc_count - ddocCount + " documents");
|
$('#docCount').text(totalDocs - ddocCount + " documents");
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDbInfo() {
|
||||||
function bootstrap() {
|
var dfd = $.Deferred();
|
||||||
util.registerEmitter();
|
return couch.request({url: app.baseURL + "api"}).then(function(dbInfo) {
|
||||||
util.listenFor(['esc', 'return']);
|
|
||||||
|
|
||||||
couch.request({url: app.baseURL + "api"}).then(function( dbInfo ) {
|
|
||||||
|
|
||||||
app.dbInfo = dbInfo;
|
app.dbInfo = dbInfo;
|
||||||
|
|
||||||
$.extend(app.dbInfo, {
|
$.extend(app.dbInfo, {
|
||||||
@@ -163,11 +158,23 @@ var recline = function() {
|
|||||||
|
|
||||||
if( util.inURL("_rewrite", app.baseURL) ) app.dbInfo.db_name = "api";
|
if( util.inURL("_rewrite", app.baseURL) ) app.dbInfo.db_name = "api";
|
||||||
|
|
||||||
|
dfd.resolve(dbInfo);
|
||||||
|
});
|
||||||
|
return dfd.promise();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function bootstrap() {
|
||||||
|
util.registerEmitter();
|
||||||
|
util.listenFor(['esc', 'return']);
|
||||||
|
|
||||||
|
getDbInfo().then(function( dbInfo ) {
|
||||||
|
|
||||||
util.render('tableContainer', app.container);
|
util.render('tableContainer', app.container);
|
||||||
util.render('title', 'project-title', app.dbInfo);
|
util.render('title', 'project-title', app.dbInfo);
|
||||||
util.render( 'generating', 'project-actions' );
|
util.render( 'generating', 'project-actions' );
|
||||||
|
|
||||||
updateDocCount();
|
updateDocCount(app.dbInfo.doc_count);
|
||||||
|
|
||||||
couch.session().then(function(session) {
|
couch.session().then(function(session) {
|
||||||
if ( session.userCtx.name ) {
|
if ( session.userCtx.name ) {
|
||||||
@@ -185,10 +192,12 @@ var recline = function() {
|
|||||||
function initializeTable(offset) {
|
function initializeTable(offset) {
|
||||||
$('.large-loader').show();
|
$('.large-loader').show();
|
||||||
couch.request({url: app.baseURL + 'api/headers'}).then(function ( headers ) {
|
couch.request({url: app.baseURL + 'api/headers'}).then(function ( headers ) {
|
||||||
|
getDbInfo().then(function(dbInfo) {
|
||||||
$('.large-loader').hide();
|
$('.large-loader').hide();
|
||||||
|
updateDocCount(dbInfo.doc_count);
|
||||||
|
});
|
||||||
app.headers = headers;
|
app.headers = headers;
|
||||||
app.csvUrl = app.baseURL + 'api/csv?headers=' + escape(JSON.stringify(headers));
|
app.csvUrl = app.baseURL + 'api/csv?headers=' + escape(JSON.stringify(headers));
|
||||||
|
|
||||||
util.render( 'actions', 'project-actions', $.extend({}, app.dbInfo, {url: app.csvUrl}) );
|
util.render( 'actions', 'project-actions', $.extend({}, app.dbInfo, {url: app.csvUrl}) );
|
||||||
fetchRows(false, offset);
|
fetchRows(false, offset);
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user