Minor fix on app node fields
Remove offline_minutes from AppNodeWithReports and update query condition for active app node filter
This commit is contained in:
		
							parent
							
								
									dcacd7b6b0
								
							
						
					
					
						commit
						41b6b9b9d0
					
				| @ -231,7 +231,6 @@ pub struct AppNodeWithReports { | ||||
|     pub avail_ports: u32, | ||||
|     pub max_ports_per_app: u32, | ||||
|     pub price: u64, | ||||
|     pub offline_minutes: u64, | ||||
|     pub reports: Vec<Report>, | ||||
| } | ||||
| 
 | ||||
| @ -269,6 +268,8 @@ impl AppNodeWithReports { | ||||
|             filter_query += &format!("&& ip = '{}' ", filters.ip); | ||||
|         } | ||||
| 
 | ||||
|         filter_query += " && connected_at > disconnected_at "; | ||||
| 
 | ||||
|         if limit_one { | ||||
|             filter_query += "limit 1"; | ||||
|         } | ||||
|  | ||||
| @ -32,7 +32,7 @@ FOR $contract IN (select * from active_vm fetch out) { | ||||
| 
 | ||||
| FOR $app_contract IN (select * from active_app fetch out) { | ||||
|     LET $operator = (select * from $app_contract.out.operator)[0]; | ||||
|     LET $node_is_online = $app_contract.out.collected_at > $app_contract.out.disconnected_at; | ||||
|     LET $node_is_online = $app_contract.out.connected_at > $app_contract.out.disconnected_at; | ||||
|     LET $price_per_minute = fn::app_price_per_minute($app_contract.id); | ||||
|     LET $amount_due = (time::now() - $app_contract.collected_at).mins() * $price_per_minute; | ||||
|     LET $amount_paid = IF $amount_due > $app_contract.locked_nano { | ||||
| @ -43,7 +43,7 @@ FOR $app_contract IN (select * from active_app fetch out) { | ||||
|     LET $escrow_multiplier = IF $operator.escrow < 5_000_000_000_000 { 1 } ELSE { 5 }; | ||||
|     IF $node_is_online { | ||||
|         UPDATE $operator.id SET balance += $amount_paid * $escrow_multiplier; | ||||
|         UPDTE $app_contract.id SET | ||||
|         UPDATE $app_contract.id SET | ||||
|             locked_nano -= $amount_paid, | ||||
|             collected_at = time::now(); | ||||
|     } ELSE { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user