@@ -667,55 +667,55 @@ module openflow {
667667 var chart : chartset = null ;
668668 this . models = await this . api . Query ( "users" , { _type : "user" } , null , null ) ;
669669 if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
670- for ( var i = 0 ; i < this . models . length ; i ++ ) {
671- var user = this . models [ i ] as any ;
672- var d = new Date ( ) ;
673- // d.setMonth(d.getMonth() - 1);
674- d . setDate ( d . getDate ( ) - 7 ) ;
675- console . debug ( "get mapreduce for " + user . name ) ;
676- var stats = await this . api . MapReduce ( "audit" ,
677- function map ( ) {
678- var startDate = new Date ( this . _created ) ;
679- this . count = 1 ;
680- emit ( startDate . toISOString ( ) . split ( 'T' ) [ 0 ] , this ) ;
681- } , function reduce ( key , values ) {
682- var reducedObject = { count : 0 , value : 0 , avg : 0 , minrun : 0 , maxrun : 0 , run : 0 , _acl : [ ] } ;
683- values . forEach ( function ( value ) {
684- reducedObject . count += value . count ;
685- reducedObject . _acl = value . _acl ;
686- } ) ;
687- return reducedObject ;
688- } , function finalize ( key , reducedValue ) {
689- if ( reducedValue . count > 0 ) {
690- reducedValue . avg = reducedValue . value / reducedValue . count ;
691- }
692- return reducedValue ;
693- } , { userid : user . _id , "_created" : { "$gte" : new Date ( d . toISOString ( ) ) } } , { inline : 1 } , null ) ;
694-
695- chart = new chartset ( ) ;
696- chart . charttype = "line"
697- chart . data = [ ] ;
698- var days = daysBetween ( d , new Date ( ) ) ;
699- for ( var y = 0 ; y < days ; y ++ ) {
700- var startDate = new Date ( d ) ;
701- startDate . setDate ( d . getDate ( ) + y ) ;
702- var datestring = startDate . toISOString ( ) . split ( 'T' ) [ 0 ] ;
703- var exists = stats . filter ( m => m . _id == datestring ) ;
704- if ( exists . length > 0 ) {
705- chart . data . push ( exists [ 0 ] . value . count ) ;
706- } else {
707- chart . data . push ( 0 ) ;
708- }
709- //chart.labels.push(datestring);
710- if ( ( y % 2 ) == 0 || ( days == 30 && y == 30 ) ) {
711- chart . labels . push ( startDate . getDate ( ) . toString ( ) ) ;
712- } else {
713- chart . labels . push ( "" ) ;
714- }
715- }
716- user . chart = chart ;
670+ // for (var i = 0; i < this.models.length; i++) {
671+ // var user = this.models[i] as any;
672+ // var d = new Date();
673+ // // d.setMonth(d.getMonth() - 1);
674+ // d.setDate(d.getDate() - 7);
675+ // console.debug("get mapreduce for " + user.name);
676+ // var stats = await this.api.MapReduce("audit",
677+ // function map() {
678+ // var startDate = new Date(this._created);
679+ // this.count = 1;
680+ // emit(startDate.toISOString().split('T')[0], this);
681+ // }, function reduce(key, values) {
682+ // var reducedObject = { count: 0, value: 0, avg: 0, minrun: 0, maxrun: 0, run: 0, _acl: [] };
683+ // values.forEach(function (value) {
684+ // reducedObject.count += value.count;
685+ // reducedObject._acl = value._acl;
686+ // });
687+ // return reducedObject;
688+ // }, function finalize(key, reducedValue) {
689+ // if (reducedValue.count > 0) {
690+ // reducedValue.avg = reducedValue.value / reducedValue.count;
691+ // }
692+ // return reducedValue;
693+ // }, { userid: user._id, "_created": { "$gte": new Date(d.toISOString()) } }, { inline: 1 }, null);
694+
695+ // chart = new chartset();
696+ // chart.charttype = "line"
697+ // chart.data = [];
698+ // var days = daysBetween(d, new Date());
699+ // for (var y = 0; y < days; y++) {
700+ // var startDate = new Date(d);
701+ // startDate.setDate(d.getDate() + y);
702+ // var datestring = startDate.toISOString().split('T')[0];
703+ // var exists = stats.filter(m => m._id == datestring);
704+ // if (exists.length > 0) {
705+ // chart.data.push(exists[0].value.count);
706+ // } else {
707+ // chart.data.push(0);
708+ // }
709+ // //chart.labels.push(datestring);
710+ // if ((y % 2) == 0 || (days == 30 && y == 30)) {
711+ // chart.labels.push(startDate.getDate().toString());
712+ // } else {
713+ // chart.labels.push("");
714+ // }
715+ // }
716+ // user.chart = chart;
717717
718- }
718+ // }
719719 this . loading = false ;
720720 if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
721721 }
0 commit comments