mirror of
https://github.com/Noratrieb/does-it-build.git
synced 2026-01-17 03:35:01 +01:00
Compare commits
No commits in common. "3a1695c554d8f07aac47a11f516ff65db7420ca6" and "d15a7465584b5e90dc19126cc3d097683d055a63" have entirely different histories.
3a1695c554
...
d15a746558
1 changed files with 3 additions and 33 deletions
|
|
@ -86,19 +86,6 @@ pub async fn notify_build(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn should_notify_since_last_notification(
|
|
||||||
last_notification: jiff::Timestamp,
|
|
||||||
now: jiff::Timestamp,
|
|
||||||
) -> bool {
|
|
||||||
now.since(last_notification).is_ok_and(|diff| {
|
|
||||||
diff.total((
|
|
||||||
jiff::Unit::Month,
|
|
||||||
&last_notification.to_zoned(jiff::tz::TimeZone::UTC),
|
|
||||||
))
|
|
||||||
.is_ok_and(|diff_months| diff_months >= 1.0)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn notify_build_failure(
|
pub async fn notify_build_failure(
|
||||||
github_client: &GitHubClient,
|
github_client: &GitHubClient,
|
||||||
db: &Db,
|
db: &Db,
|
||||||
|
|
@ -126,7 +113,9 @@ pub async fn notify_build_failure(
|
||||||
|
|
||||||
if issue.last_update_date.is_none_or(|last_update_date| {
|
if issue.last_update_date.is_none_or(|last_update_date| {
|
||||||
jiff::Timestamp::from_millisecond(last_update_date).is_ok_and(|last_update_date| {
|
jiff::Timestamp::from_millisecond(last_update_date).is_ok_and(|last_update_date| {
|
||||||
should_notify_since_last_notification(last_update_date, jiff::Timestamp::now())
|
jiff::Timestamp::now()
|
||||||
|
.since(last_update_date)
|
||||||
|
.is_ok_and(|diff| diff.get_months() > 0)
|
||||||
})
|
})
|
||||||
}) {
|
}) {
|
||||||
info!(
|
info!(
|
||||||
|
|
@ -285,22 +274,3 @@ pub async fn notify_build_pass(
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
#[test]
|
|
||||||
fn should_notify_since_last_notification() {
|
|
||||||
assert!(super::should_notify_since_last_notification(
|
|
||||||
"2025-11-01T00:00:00Z".parse().unwrap(),
|
|
||||||
"2025-12-02T00:00:00Z".parse().unwrap()
|
|
||||||
));
|
|
||||||
assert!(super::should_notify_since_last_notification(
|
|
||||||
"2025-09-01T00:00:00Z".parse().unwrap(),
|
|
||||||
"2025-12-02T00:00:00Z".parse().unwrap()
|
|
||||||
));
|
|
||||||
assert!(!super::should_notify_since_last_notification(
|
|
||||||
"2025-11-02T00:00:00Z".parse().unwrap(),
|
|
||||||
"2025-12-01T00:00:00Z".parse().unwrap()
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue