Skip to content

Commit a4aa100

Browse files
committed
fix: apply proper formatting
1 parent 31de185 commit a4aa100

File tree

6 files changed

+25
-27
lines changed

6 files changed

+25
-27
lines changed

sentry/src/access.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub async fn check_access(
8484
.as_ref()
8585
.map(|ev_sub| ev_sub.allow.as_slice())
8686
.unwrap_or_else(|| &default_rules);
87-
87+
8888
// first, find an applicable access rule
8989
let rules = allow_rules
9090
.iter()

sentry/src/db.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ pub async fn setup_migrations(environment: &str) {
8282
};
8383
}
8484

85-
let mut migrations = vec![
86-
make_migration!("20190806011140_initial-tables")
87-
];
85+
let mut migrations = vec![make_migration!("20190806011140_initial-tables")];
8886

8987
if environment == "development" {
9088
// seeds database tables for testing

sentry/src/db/event_aggregate.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
use crate::db::DbPool;
22
use bb8::RunError;
33
// use bb8_postgres::tokio_postgres::types::{ToSql, FromSql};
4+
use bb8_postgres::tokio_postgres::binary_copy::BinaryCopyInWriter;
5+
use bb8_postgres::tokio_postgres::types::Type;
6+
use bb8_postgres::tokio_postgres::Error;
47
use chrono::{DateTime, Utc};
8+
use futures::pin_mut;
59
use postgres_types::{FromSql, ToSql};
610
use primitives::sentry::EventAggregate;
711
use primitives::BigNum;
812
use primitives::{ChannelId, ValidatorId};
913
use std::ops::Add;
10-
use bb8_postgres::tokio_postgres::binary_copy::BinaryCopyInWriter;
11-
use bb8_postgres::tokio_postgres::types::{Type};
12-
use futures::{pin_mut};
13-
use bb8_postgres::tokio_postgres::{Error};
14-
1514

1615
pub async fn list_event_aggregates(
1716
pool: &DbPool,
@@ -25,10 +24,7 @@ pub async fn list_event_aggregates(
2524
where_clauses.push(format!("channel_id = '{}'", id));
2625

2726
if let Some(from) = from {
28-
where_clauses.push(format!(
29-
"earner = '{}'",
30-
from.to_string()
31-
));
27+
where_clauses.push(format!("earner = '{}'", from.to_string()));
3228
where_clauses.push("event_type = 'IMPRESSION'".to_string());
3329
} else {
3430
where_clauses.push("earner is NOT NULL".to_string());
@@ -71,9 +67,8 @@ pub async fn list_event_aggregates(
7167
as data
7268
FROM event_aggregates WHERE {} GROUP BY channel_id, event_type, created ORDER BY created DESC LIMIT {}
7369
) SELECT channel_id, created, jsonb_object_agg(event_type , data) as events FROM aggregates GROUP BY channel_id, created
74-
"
75-
, where_clause, limit);
76-
70+
", where_clause, limit);
71+
7772
match connection.prepare(&statement).await {
7873
Ok(stmt) => {
7974
match connection.query(&stmt, params.as_slice()).await {
@@ -101,7 +96,7 @@ struct EventData {
10196
earner: Option<String>,
10297
event_count: String,
10398
event_payout: String,
104-
created: DateTime<Utc>
99+
created: DateTime<Utc>,
105100
}
106101

107102
pub async fn insert_event_aggregate(
@@ -132,7 +127,6 @@ pub async fn insert_event_aggregate(
132127
// total sum
133128
total_event_counts = event_count.add(&total_event_counts);
134129
total_event_payouts = total_event_payouts.add(event_payout);
135-
136130
}
137131

138132
data.extend(vec![EventData {
@@ -146,7 +140,6 @@ pub async fn insert_event_aggregate(
146140
}
147141
}
148142

149-
150143
let result = pool
151144
.run(move |connection| {
152145
async move {
@@ -174,10 +167,9 @@ pub async fn insert_event_aggregate(
174167
Ok((true, connection))
175168
}
176169
}
177-
178170
}
179171
})
180172
.await?;
181173

182174
Ok(result)
183-
}
175+
}

sentry/src/event_aggregator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl EventAggregator {
116116
println!("storing data in ");
117117
store(&app.pool, &channel.id, self.aggregate.clone()).await;
118118
}
119-
119+
120120
println!("finished succesfully");
121121

122122
Ok(())

sentry/src/routes/channel.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ pub async fn insert_events<A: Adapter + 'static>(
123123
let into_body = req.into_body();
124124
let body = hyper::body::to_bytes(into_body).await?;
125125
let request_body = serde_json::from_slice::<HashMap<String, Vec<Event>>>(&body)?;
126-
let events = request_body.get("events").ok_or_else(|| ResponseError::BadRequest("invalid request".to_string()))?;
127-
126+
let events = request_body
127+
.get("events")
128+
.ok_or_else(|| ResponseError::BadRequest("invalid request".to_string()))?;
129+
128130
println!("working on something");
129131

130132
app.event_aggregator

sentry/src/routes/event_aggregate.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,17 @@ pub async fn list_channel_event_aggregates<A: Adapter>(
3232
let from = if channel.spec.validators.find(&session.uid).is_some() {
3333
None
3434
} else {
35-
Some(session.uid.clone())
35+
Some(session.uid.clone())
3636
};
3737

38-
let event_aggregates =
39-
list_event_aggregates(&app.pool, &channel.id, app.config.events_find_limit, &from, &query.after).await?;
38+
let event_aggregates = list_event_aggregates(
39+
&app.pool,
40+
&channel.id,
41+
app.config.events_find_limit,
42+
&from,
43+
&query.after,
44+
)
45+
.await?;
4046

4147
let response = EventAggregateResponse {
4248
channel: channel.clone(),

0 commit comments

Comments
 (0)