chore: improve querying

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb
2025-09-13 09:18:55 +00:00
parent c3be6248b5
commit f73245f9c3
4 changed files with 39 additions and 43 deletions

View File

@@ -72,9 +72,19 @@ pub enum IssueStatus {
}
impl IssueStatus {
/// Returns all issue statuses as kinds
#[inline]
pub const fn all_kinds() -> [Kind; 3] {
[
Self::Open.kind(),
Self::Resolved.kind(),
Self::Closed.kind(),
]
}
/// Maps the issue status to its corresponding Nostr kind.
#[inline]
pub fn kind(&self) -> Kind {
pub const fn kind(&self) -> Kind {
match self {
Self::Open => Kind::GitStatusOpen,
Self::Resolved => Kind::GitStatusApplied,

View File

@@ -310,7 +310,6 @@ pub async fn list_pr_patches_and_issues<const ENTITY_TYPE: u8>(
arc_client
.fetch_events(filter)
.await?
.into_iter()
.take(limit)
.map(|event| {
let c = arc_client.clone();
@@ -527,15 +526,13 @@ pub async fn view_pr_issue<const IS_PR: bool>(
let pr_data = if IS_PR {
// Check if there is an update
let pr_update = client
.fetch_events(
.fetch_event(
Filter::new()
.kind(crate::cli::pr::PR_UPDATE_KIND)
.custom_tag(SingleLetterTag::uppercase(Alphabet::E), event.id)
.author(event.pubkey),
)
.await?
.into_iter()
.max_by_key(|e| e.created_at.as_u64());
.await?;
let commit = pr_update
.as_ref()

View File

@@ -276,16 +276,16 @@ impl PatchPrStatus {
#[inline]
pub const fn all_kinds() -> [Kind; 4] {
[
Kind::GitStatusOpen,
Kind::GitStatusApplied,
Kind::GitStatusClosed,
Kind::GitStatusDraft,
Self::Open.kind(),
Self::MergedApplied.kind(),
Self::Closed.kind(),
Self::Draft.kind(),
]
}
/// Maps the patch/pr status to its corresponding Nostr kind.
#[inline]
pub fn kind(&self) -> Kind {
pub const fn kind(&self) -> Kind {
match self {
Self::Open => Kind::GitStatusOpen,
Self::MergedApplied => Kind::GitStatusApplied,