@@ -2,11 +2,11 @@ use crate::db::DbPool;
2
2
use bb8:: RunError ;
3
3
// use bb8_postgres::tokio_postgres::types::{ToSql, FromSql};
4
4
use chrono:: { DateTime , Utc } ;
5
+ use postgres_types:: { FromSql , ToSql } ;
5
6
use primitives:: sentry:: EventAggregate ;
6
- use primitives:: { ChannelId , ValidatorId } ;
7
7
use primitives:: BigNum ;
8
+ use primitives:: { ChannelId , ValidatorId } ;
8
9
use std:: ops:: Add ;
9
- use postgres_types:: { ToSql , FromSql } ;
10
10
11
11
pub async fn list_event_aggregates (
12
12
pool : & DbPool ,
@@ -65,7 +65,6 @@ struct EventData {
65
65
event_payout : String ,
66
66
}
67
67
68
-
69
68
pub async fn insert_event_aggregate (
70
69
pool : & DbPool ,
71
70
channel_id : & ChannelId ,
@@ -83,18 +82,15 @@ pub async fn insert_event_aggregate(
83
82
let mut total_event_payouts: BigNum = 0 . into ( ) ;
84
83
for ( earner, event_count) in event_counts {
85
84
let event_payout = aggr. event_payouts [ earner] . clone ( ) ;
86
- data. extend ( vec ! [
87
- EventData {
88
- id: id. clone( ) ,
89
- event_type: event_type. clone( ) ,
90
- earner: Some ( earner. clone( ) ) ,
91
- event_count: event_count. to_string( ) ,
92
- event_payout: event_payout. to_string( ) ,
93
- }
94
-
95
- ] ) ;
96
-
97
- // total sum
85
+ data. extend ( vec ! [ EventData {
86
+ id: id. clone( ) ,
87
+ event_type: event_type. clone( ) ,
88
+ earner: Some ( earner. clone( ) ) ,
89
+ event_count: event_count. to_string( ) ,
90
+ event_payout: event_payout. to_string( ) ,
91
+ } ] ) ;
92
+
93
+ // total sum
98
94
total_event_counts = event_count. add ( & total_event_counts) ;
99
95
total_event_payouts = total_event_payouts. add ( event_payout) ;
100
96
@@ -117,15 +113,13 @@ pub async fn insert_event_aggregate(
117
113
index += 5 ;
118
114
}
119
115
// extend with
120
- data. extend ( vec ! [
121
- EventData {
122
- id: id. clone( ) ,
123
- event_type: event_type. clone( ) ,
124
- earner: None ,
125
- event_count: total_event_counts. to_string( ) ,
126
- event_payout: total_event_payouts. to_string( ) ,
127
- }
128
- ] ) ;
116
+ data. extend ( vec ! [ EventData {
117
+ id: id. clone( ) ,
118
+ event_type: event_type. clone( ) ,
119
+ earner: None ,
120
+ event_count: total_event_counts. to_string( ) ,
121
+ event_payout: total_event_payouts. to_string( ) ,
122
+ } ] ) ;
129
123
130
124
values. push ( format ! (
131
125
"(${}, ${}, ${}, ${}, ${})" ,
@@ -136,8 +130,6 @@ pub async fn insert_event_aggregate(
136
130
index + 5
137
131
) ) ;
138
132
index += 5 ;
139
-
140
-
141
133
}
142
134
}
143
135
0 commit comments