✨ feat(retention): add message age enum creation
- implement `new` function for MessageAge enum - allow creating MessageAge from string period and count
This commit is contained in:
committed by
Jeremiah Russell
parent
b729ee6a10
commit
7b08bfe13a
@@ -25,6 +25,17 @@ impl Display for MessageAge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl MessageAge {
|
impl MessageAge {
|
||||||
|
/// Create a new MessageAge enum
|
||||||
|
pub fn new(period: &str, count: usize) -> Self {
|
||||||
|
match period.to_lowercase().as_str() {
|
||||||
|
"days" => MessageAge::Days(count),
|
||||||
|
"weeks" => MessageAge::Weeks(count),
|
||||||
|
"months" => MessageAge::Months(count),
|
||||||
|
"years" => MessageAge::Years(count),
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn label(&self) -> String {
|
pub(crate) fn label(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
MessageAge::Days(v) => format!("retention/{v}-days"),
|
MessageAge::Days(v) => format!("retention/{v}-days"),
|
||||||
|
|||||||
Reference in New Issue
Block a user