fixed by zero mongodb bug for aggregation

This commit is contained in:
David Baldwynn 2017-11-15 04:31:14 -08:00
parent 965962b5e0
commit 3606c9444b
3 changed files with 21 additions and 41 deletions

View File

@ -200,13 +200,21 @@ exports.getVisitorData = function(req, res) {
responses: "$responses",
visits: "$visits",
average_time: {
$divide : ["$total_time", "$responses"]
$cond: [
{ $eq: [ "$responses", 0 ] },
0,
{ $divide: ["$total_time", "$responses"] }
]
},
conversion_rate: {
$multiply: [
100,
{
$divide : ["$responses", "$visits"]
$cond: [
{ $eq: [ "$visits", 0 ] },
0,
{ $divide: ["$responses", "$visits"] }
]
}
]
}
@ -256,13 +264,21 @@ exports.getVisitorData = function(req, res) {
responses: "$responses",
visits: "$visits",
average_time: {
$divide : ["$total_time", "$responses"]
$cond: [
{ $eq: [ "$responses", 0 ] },
0,
{ $divide: ["$total_time", "$responses"] }
]
},
conversion_rate: {
$multiply: [
100,
{
$divide : ["$responses", "$visits"]
$cond: [
{ $eq: [ "$visits", 0 ] },
0,
{ $divide: ["$responses", "$visits"] }
]
}
]
}

View File

@ -24,9 +24,7 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
//Waits until deletionInProgress is false before running getSubmissions
$scope.$watch("deletionInProgress",function(newVal, oldVal){
if(newVal === oldVal) return;
if(newVal === false && $scope.waitingForDeletion) {
if(newVal !== oldVal && newVal === false && $scope.waitingForDeletion) {
$scope.getSubmissions();
$scope.waitingForDeletion = false;
}

View File

@ -55,38 +55,4 @@ angular.module('forms').run(['Menus',
directive.replace = true;
return $delegate;
});
}]).config(['$provide', function ($provide){
$provide.decorator('taOptions', ['$delegate', 'taRegisterTool', '$translate', '$window', 'taSelection', function(taOptions, taRegisterTool, $translate, $window, taSelection) {
taRegisterTool('insertField', {
display: '<div uib-dropdown is-open="isopen">\
<div class="btn btn-default" ng-disabled="isDisabled()" uib-dropdown-toggle>\
<span>{{ "ADD_VARIABLE_BUTTON" | translate }}</span>\
<b class="caret"></b>\
</div>\
<ul class="dropdown-menu" uib-dropdown-menu>\
<li ng-repeat="field in $root.myform.form_fields" ng-click="onClickField(field.globalId, field.title)">\
<a> {{field.title}} </a>\
</li>\
</ul>\
</div>',
class: 'btn-group',
onClickField: function(field_id, field_name){
if (taSelection.getSelectionElement().tagName && (taSelection.getSelectionElement().tagName.toLowerCase() === 'var' || taSelection.getSelectionElement().tagName.toLowerCase() === 'a')) {
// due to differences in implementation between FireFox and Chrome, we must move the
// insertion point past the <a> element, otherwise FireFox inserts inside the <a>
// With this change, both FireFox and Chrome behave the same way!
taSelection.setSelectionAfterElement(taSelection.getSelectionElement());
}
this.$editor().wrapSelection('insertHTML', ' <var class="tag field-' + field_id + '" contenteditable="false">' + field_name + '</var> ', true);
},
action: function(){
}
});
taOptions.defaultTagAttributes['var'] = {
'contenteditable': 'false'
};
return taOptions;
}]);
}]);