@@ -771,7 +771,6 @@ export class Message {
771771 } catch ( error ) {
772772 this . data = "" ;
773773 cli . _logger . error ( error ) ;
774- console . log ( JSON . stringify ( error , null , 2 ) ) ;
775774 //msg.error = JSON.stringify(error, null, 2);
776775 if ( msg !== null && msg !== undefined ) msg . error = "Request failed!"
777776 }
@@ -1115,23 +1114,30 @@ export class Message {
11151114 for ( var i = 0 ; i < list . body . items . length ; i ++ ) {
11161115 if ( ! Util . IsNullEmpty ( Config . stripe_api_secret ) ) {
11171116 var item = list . body . items [ i ] ;
1117+ var name = item . metadata . name ;
11181118 var create = item . metadata . creationTimestamp ;
11191119 var billed = item . metadata . labels . billed ;
11201120 var image = item . spec . containers [ 0 ] . image
11211121 var userid = item . metadata . labels . userid ;
1122+ var date = new Date ( ) ;
1123+ var a : number = ( date as any ) - ( create as any ) ;
1124+ // var diffminutes = a / (1000 * 60);
1125+ var diffhours = a / ( 1000 * 60 * 60 ) ;
11221126 if ( image . indexOf ( "openflownodered" ) > 0 && ! Util . IsNullEmpty ( userid ) ) {
11231127 try {
1124- var date = new Date ( ) ;
1125- var a : number = ( date as any ) - ( create as any ) ;
1126- // var diffminutes = a / (1000 * 60);
1127- var diffhours = a / ( 1000 * 60 * 60 ) ;
11281128 if ( billed != "true" && diffhours > 24 ) {
1129- cli . _logger . debug ( "[" + cli . user . username + "] Remove un billed nodered instance " + item . metadata . name + " that has been running for " + diffhours + " hours" ) ;
1130- await this . _DeleteNoderedInstance ( userid , cli . user . _id , cli . user . username , rootjwt ) ;
1129+ cli . _logger . debug ( "[" + cli . user . username + "] Remove un billed nodered instance " + name + " that has been running for " + diffhours + " hours" ) ;
1130+ // await this._DeleteNoderedInstance(userid, cli.user._id, cli.user.username, rootjwt);
11311131 }
1132- // console.log(item.metadata. name + " " + diffminutes + " min / " + diffhours + " hours");
1132+ // console.log(name + " " + diffminutes + " min / " + diffhours + " hours");
11331133 } catch ( error ) {
11341134 }
1135+ } else if ( image . indexOf ( "openflownodered" ) > 0 ) {
1136+ if ( billed != "true" && diffhours > 24 ) {
1137+ console . log ( "unbilled " + name + " with no userid, should be removed, it has been running for " + diffhours + " hours" ) ;
1138+ } else {
1139+ console . log ( "unbilled " + name + " with no userid, has been running for " + diffhours + " hours" ) ;
1140+ }
11351141 }
11361142 }
11371143
@@ -1822,7 +1828,6 @@ export class Message {
18221828 customer = await this . Stripe < stripe_customer > ( "GET" , "customers" , null , null , billing . stripeid ) ;
18231829 }
18241830 }
1825- console . log ( JSON . stringify ( customer . discount , null , 2 ) )
18261831 if ( customer != null && Util . IsNullEmpty ( billing . coupon ) && customer . discount != null ) {
18271832 var payload : any = { coupon : "" } ;
18281833 customer = await this . Stripe < stripe_customer > ( "POST" , "customers" , billing . stripeid , payload , null ) ;
0 commit comments