Bug 2041810 - populate conflict_slug on mobile#7367
Conversation
freshstrangemusic
left a comment
There was a problem hiding this comment.
All changes to types that are serialized to the database require tests and (in this case) a migration
|
Your PR title should be of the form whiteboard: There is a typo in your PR title: config_slug vs conflict_slug |
41723b8 to
e61b9e3
Compare
The pull request has been modified, dismissing previous reviews.
e61b9e3 to
4da4526
Compare
The pull request has been modified, dismissing previous reviews.
freshstrangemusic
left a comment
There was a problem hiding this comment.
Minor stylistic changes and a few extra asserts, then LGTM.
I'm holding approval until we can land the pending changes for labs as this will likely cause merge conflicts with that stack.
| reason_value = Some(reason.to_string()); | ||
| conflict_slug_value = match reason { | ||
| crate::enrollment::NotEnrolledReason::FeatureConflict { conflict_slug } => { | ||
| conflict_slug.to_owned() |
There was a problem hiding this comment.
| conflict_slug.to_owned() | |
| conflict_slug.into() |
I prefer into() for &str -> String. (Technically conflict_slug is &String, but calling methods on a type will automatically deref-coerce into &str which then impls Into)
There was a problem hiding this comment.
conflict_slug is actually Option<String> which doesnt have into() implemented
There was a problem hiding this comment.
It actually is an &Option<String> becuase it is being derived from the borrowed EnrollmentStatus.
In this case, we can just .clone() which will get us an Option<String>
There was a problem hiding this comment.
Additionally, you can write this as:
conflict_slug_value = if let NotEnrolledReason { conflict_slug} = reason { conflict_slug.clone() } else { None } ;
or
if let NotEnrolledReason { conflict_slug } = reason {
conflict_slug_value = conflict_slug.clone();
}
I think the latter is better because we aren't re-assigning to None -- not for performance reasons (it should get optimized out anyway) -- but for simplicity. Less branches to follow etc.
Added a proper value for
conflict_slugwhen constructing theEnrollmentStatusExtraDeftaken by pulling out the actual feature slug which caused the conflictPull Request checklist
[ci full]to the PR title.