First working rescheduling

This commit is contained in:
Rahix 2026-03-01 18:18:49 +01:00
parent adc6b7866a
commit b25857f3af
7 changed files with 85 additions and 20 deletions

View file

@ -1,4 +1,5 @@
use crate::task;
use crate::util;
use anyhow::Context as _;
use forgejo_api::structs::Issue;
@ -33,12 +34,12 @@ fn task_from_issue(issue: &Issue) -> anyhow::Result<task::Task> {
fn task_state_from_issue(issue: &Issue) -> anyhow::Result<task::State> {
match issue.get_state()? {
forgejo_api::structs::StateType::Open => Ok(task::State::Open {
due: issue.due_date,
due: issue.due_date.map(util::time_to_jiff),
}),
forgejo_api::structs::StateType::Closed => Ok(task::State::Completed {
date: issue
date: util::time_to_jiff(issue
.closed_at
.context("Closed issue without a closed_at date")?,
.context("Closed issue without a closed_at date")?),
}),
}
}
@ -124,19 +125,19 @@ async fn list_all_issues(ctx: &crate::Context) -> anyhow::Result<Vec<Issue>> {
}
trait IssueExt {
fn get_number(&self) -> anyhow::Result<u64>;
fn get_number(&self) -> anyhow::Result<u32>;
fn get_title(&self) -> anyhow::Result<String>;
fn get_state(&self) -> anyhow::Result<forgejo_api::structs::StateType>;
fn get_label_names(&self) -> anyhow::Result<Vec<String>>;
}
impl IssueExt for Issue {
fn get_number(&self) -> anyhow::Result<u64> {
fn get_number(&self) -> anyhow::Result<u32> {
Ok(self
.number
.context("Missing issue number")?
.try_into()
.context("Failed converting issue number to u64")?)
.context("Failed converting issue number to u32")?)
}
fn get_title(&self) -> anyhow::Result<String> {