Skip to content

Commit 6887a68

Browse files
committed
fix: rename reports enum
1 parent 43f6fea commit 6887a68

File tree

4 files changed

+39
-41
lines changed

4 files changed

+39
-41
lines changed

primitives/src/sentry.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ pub struct LastApproved {
1717

1818
#[derive(Serialize, Deserialize, Debug)]
1919
pub struct NewStateValidatorMessage {
20-
pub from: String,
20+
pub from: ValidatorId,
2121
pub received: DateTime<Utc>,
2222
pub msg: MessageTypes,
2323
}
2424

2525
#[derive(Serialize, Deserialize, Debug)]
2626
pub struct ApproveStateValidatorMessage {
27-
pub from: String,
27+
pub from: ValidatorId,
2828
pub received: DateTime<Utc>,
2929
pub msg: MessageTypes,
3030
}
@@ -170,39 +170,39 @@ pub struct AdvancedAnalyticsResponse {
170170
#[derive(Serialize, Deserialize, Debug, Hash, PartialEq, Eq, Clone)]
171171
#[serde(rename_all = "camelCase")]
172172
pub enum PublisherReport {
173-
ReportPublisherToAdUnit,
174-
ReportPublisherToAdSlot,
175-
ReportPublisherToAdSlotPay,
176-
ReportPublisherToCountry,
177-
ReportPublisherToHostname,
173+
AdUnit,
174+
AdSlot,
175+
AdSlotPay,
176+
Country,
177+
Hostname,
178178
}
179179

180180
impl fmt::Display for PublisherReport {
181181
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
182182
match *self {
183-
PublisherReport::ReportPublisherToAdUnit => write!(f, "reportPublisherToAdUnit"),
184-
PublisherReport::ReportPublisherToAdSlot => write!(f, "reportPublisherToAdSlot"),
185-
PublisherReport::ReportPublisherToAdSlotPay => write!(f, "reportPublisherToAdSlotPay"),
186-
PublisherReport::ReportPublisherToCountry => write!(f, "reportPublisherToCountry"),
187-
PublisherReport::ReportPublisherToHostname => write!(f, "reportPublisherToHostname"),
183+
PublisherReport::AdUnit => write!(f, "reportPublisherToAdUnit"),
184+
PublisherReport::AdSlot => write!(f, "reportPublisherToAdSlot"),
185+
PublisherReport::AdSlotPay => write!(f, "reportPublisherToAdSlotPay"),
186+
PublisherReport::Country => write!(f, "reportPublisherToCountry"),
187+
PublisherReport::Hostname => write!(f, "reportPublisherToHostname"),
188188
}
189189
}
190190
}
191191

192192
#[derive(Serialize, Deserialize, Debug, Hash, PartialEq, Eq, Clone)]
193193
#[serde(rename_all = "camelCase")]
194194
pub enum ChannelReport {
195-
ReportChannelToAdUnit,
196-
ReportChannelToHostname,
197-
ReportChannelToHostnamePay,
195+
AdUnit,
196+
Hostname,
197+
HostnamePay,
198198
}
199199

200200
impl fmt::Display for ChannelReport {
201201
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
202202
match *self {
203-
ChannelReport::ReportChannelToAdUnit => write!(f, "reportPublisherToAdUnit"),
204-
ChannelReport::ReportChannelToHostname => write!(f, "reportChannelToHostname"),
205-
ChannelReport::ReportChannelToHostnamePay => write!(f, "reportChannelToHostnamePay"),
203+
ChannelReport::AdUnit => write!(f, "reportPublisherToAdUnit"),
204+
ChannelReport::Hostname => write!(f, "reportChannelToHostname"),
205+
ChannelReport::HostnamePay => write!(f, "reportChannelToHostnamePay"),
206206
}
207207
}
208208
}

sentry/src/analytics_recorder.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ pub fn get_payout(channel: &Channel, event: &Event) -> BigNum {
1313
Event::Click { .. } => {
1414
if let Some(pricing) = channel.spec.pricing_bounds.clone() {
1515
if let Some(click) = pricing.click {
16-
click.min
17-
} else {
18-
BigNum::from(0)
16+
return click.min;
1917
}
20-
} else {
21-
BigNum::from(0)
2218
}
19+
20+
BigNum::from(0)
2321
}
2422
_ => BigNum::from(0),
2523
}
@@ -60,7 +58,7 @@ pub async fn record(
6058
db.zincr(
6159
format!(
6260
"{}:{}:{}",
63-
PublisherReport::ReportPublisherToAdUnit,
61+
PublisherReport::AdUnit,
6462
event,
6563
publisher
6664
),
@@ -71,7 +69,7 @@ pub async fn record(
7169
db.zincr(
7270
format!(
7371
"{}:{}:{}",
74-
ChannelReport::ReportChannelToAdUnit,
72+
ChannelReport::AdUnit,
7573
event,
7674
publisher
7775
),
@@ -85,7 +83,7 @@ pub async fn record(
8583
db.zincr(
8684
format!(
8785
"{}:{}:{}",
88-
PublisherReport::ReportPublisherToAdSlot,
86+
PublisherReport::AdSlot,
8987
event,
9088
publisher
9189
),
@@ -96,7 +94,7 @@ pub async fn record(
9694
db.zincr(
9795
format!(
9896
"{}:{}:{}",
99-
PublisherReport::ReportPublisherToAdSlotPay,
97+
PublisherReport::AdSlotPay,
10098
event,
10199
publisher
102100
),
@@ -110,7 +108,7 @@ pub async fn record(
110108
db.zincr(
111109
format!(
112110
"{}:{}:{}:{}",
113-
PublisherReport::ReportPublisherToCountry,
111+
PublisherReport::Country,
114112
epoch().floor(),
115113
event,
116114
publisher
@@ -130,7 +128,7 @@ pub async fn record(
130128
db.zincr(
131129
format!(
132130
"{}:{}:{}",
133-
PublisherReport::ReportPublisherToHostname,
131+
PublisherReport::Hostname,
134132
event,
135133
publisher
136134
),
@@ -141,7 +139,7 @@ pub async fn record(
141139
db.zincr(
142140
format!(
143141
"{}:{}:{}",
144-
ChannelReport::ReportChannelToHostname,
142+
ChannelReport::Hostname,
145143
event,
146144
channel.id
147145
),
@@ -152,7 +150,7 @@ pub async fn record(
152150
db.zincr(
153151
format!(
154152
"{}:{}:{}",
155-
ChannelReport::ReportChannelToHostnamePay,
153+
ChannelReport::HostnamePay,
156154
event,
157155
channel.id
158156
),

sentry/src/db/analytics.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,18 @@ pub async fn get_advanced_reports(
186186
channel_ids: &[ChannelId],
187187
) -> Result<AdvancedAnalyticsResponse, Box<dyn Error>> {
188188
let publisher_reports = [
189-
PublisherReport::ReportPublisherToAdUnit,
190-
PublisherReport::ReportPublisherToAdSlot,
191-
PublisherReport::ReportPublisherToAdSlotPay,
192-
PublisherReport::ReportPublisherToCountry,
193-
PublisherReport::ReportPublisherToHostname,
189+
PublisherReport::AdUnit,
190+
PublisherReport::AdSlot,
191+
PublisherReport::AdSlotPay,
192+
PublisherReport::Country,
193+
PublisherReport::Hostname,
194194
];
195195

196196
let mut publisher_stats: HashMap<PublisherReport, HashMap<String, f64>> = HashMap::new();
197197

198198
for publisher_report in publisher_reports.iter() {
199199
let pair = match publisher_report {
200-
PublisherReport::ReportPublisherToCountry => format!(
200+
PublisherReport::Country => format!(
201201
"{}:{}:{}:{}",
202202
epoch().floor(),
203203
publisher_report,
@@ -213,9 +213,9 @@ pub async fn get_advanced_reports(
213213
let mut by_channel_stats = HashMap::new();
214214

215215
let channel_reports = [
216-
ChannelReport::ReportChannelToAdUnit,
217-
ChannelReport::ReportChannelToHostname,
218-
ChannelReport::ReportChannelToHostnamePay,
216+
ChannelReport::AdUnit,
217+
ChannelReport::Hostname,
218+
ChannelReport::HostnamePay,
219219
];
220220

221221
for channel_id in channel_ids {

sentry/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ pub fn success_response(response_body: String) -> Response<Body> {
417417
}
418418

419419
pub fn epoch() -> f64 {
420-
(Utc::now().timestamp() / 2_628_000_000) as f64
420+
Utc::now().timestamp() as f64 / 2_628_000_000.0
421421
}
422422

423423
// @TODO: Make pub(crate)

0 commit comments

Comments
 (0)