Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 5059eeb

Browse files
committed
Add check to make sure value is not None type.
1 parent 8ec666c commit 5059eeb

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/main.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,18 @@ pub fn process_tally(event: &FeedbackEvent) -> Vec<FeedbackEventNormalised> {
138138
pub fn process_nested_tally(event: &FeedbackEvent) -> Vec<FeedbackEventNormalised> {
139139
let mut normalised_events = vec![];
140140
for (key, value) in event.json["data"].as_object().unwrap() {
141-
for (nested_key, nested_value) in value.as_object().unwrap() {
142-
normalised_events.push(FeedbackEventNormalised {
143-
datetime: event.datetime,
144-
round_id: event.round_id,
145-
category_primary: event.key_name.clone(),
146-
category_secondary: key.to_string(),
147-
category_tertiary: nested_key.to_string(),
148-
version: event.version,
149-
value: nested_value.to_string(),
150-
});
141+
if value.is_object() {
142+
for (nested_key, nested_value) in value.as_object().unwrap() {
143+
normalised_events.push(FeedbackEventNormalised {
144+
datetime: event.datetime,
145+
round_id: event.round_id,
146+
category_primary: event.key_name.clone(),
147+
category_secondary: key.to_string(),
148+
category_tertiary: nested_key.to_string(),
149+
version: event.version,
150+
value: nested_value.to_string(),
151+
});
152+
}
151153
}
152154
}
153155

0 commit comments

Comments
 (0)