Skip to content

Commit 88c195b

Browse files
committed
Improvements on the code
1 parent 502d6ab commit 88c195b

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

sentry/src/analytics_recorder.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ use slog::{error, Logger};
1010
pub fn get_payout(channel: &Channel, event: &Event) -> BigNum {
1111
match event {
1212
Event::Impression { .. } => channel.spec.min_per_impression.clone(),
13-
Event::Click { .. } => {
14-
if let Some(pricing) = channel.spec.pricing_bounds.clone() {
15-
if let Some(click) = pricing.click {
16-
return click.min;
17-
}
18-
}
19-
20-
Default::default()
21-
}
13+
Event::Click { .. } => channel
14+
.spec
15+
.pricing_bounds
16+
.as_ref()
17+
.and_then(|pricing_bound| pricing_bound.click.as_ref())
18+
.map(|click| click.min.clone())
19+
.unwrap_or_default(),
2220
_ => Default::default(),
2321
}
2422
}
@@ -84,7 +82,7 @@ pub async fn record(
8482
.ignore();
8583
}
8684

87-
if let Some(country) = session.country.clone() {
85+
if let Some(country) = &session.country {
8886
db.zincr(
8987
format!(
9088
"{}:{}:{}:{}",
@@ -129,6 +127,6 @@ pub async fn record(
129127
});
130128

131129
if let Err(err) = db.query_async::<_, Option<String>>(&mut conn).await {
132-
error!(&logger, "Server error: {}", err; "module" => "analytics-recorder");
130+
error!(&logger, "Redis Database error: {}", err; "module" => "analytics-recorder");
133131
}
134132
}

sentry/src/db/event_aggregate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub async fn latest_new_state(
5555
pub async fn latest_heartbeats(
5656
pool: &DbPool,
5757
channel_id: &ChannelId,
58-
validator_id: ValidatorId,
58+
validator_id: &ValidatorId,
5959
) -> Result<Vec<HeartbeatValidatorMessage>, RunError<bb8_postgres::tokio_postgres::Error>> {
6060
pool
6161
.run(move |connection| {

sentry/src/routes/channel.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ pub async fn last_approved<A: Adapter>(
138138
let heartbeats = if query.with_heartbeat.is_some() {
139139
let result = try_join_all(
140140
validators
141-
.into_iter()
142-
.map(|validator| latest_heartbeats(&app.pool, &channel_id, validator.id.clone())),
141+
.iter()
142+
.map(|validator| latest_heartbeats(&app.pool, &channel_id, &validator.id)),
143143
)
144144
.await?;
145145
Some(result.into_iter().flatten().collect::<Vec<_>>())

0 commit comments

Comments
 (0)