Skip to main content

vissue_core/
views.rs

1//! Typed issue views shared by JSON output and later control clients.
2
3use serde::{Deserialize, Serialize};
4use std::collections::BTreeMap;
5use std::path::PathBuf;
6
7use crate::model::IssueHeading;
8
9/// One parsed heading plus the `issues.org` it came from.
10#[derive(Debug, Clone)]
11pub struct IssueRec {
12    pub project: String,
13    pub heading: IssueHeading,
14    pub path: PathBuf,
15}
16
17/// Filters for [`crate::catalog::CatalogService::issues_rows`].
18#[derive(Debug, Clone, Default, PartialEq, Eq)]
19pub struct ListQuery {
20    pub project: Option<String>,
21    pub state: Option<String>,
22    pub ready: bool,
23    /// Case-insensitive substring over id, title, tags, and properties.
24    pub query: Option<String>,
25    pub limit: Option<usize>,
26    pub offset: Option<usize>,
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
30pub struct IssueRow {
31    pub id: String,
32    pub state: String,
33    pub priority: String,
34    pub title: String,
35    pub project: String,
36    pub blocked_by: Vec<String>,
37    pub claimed_by: Option<String>,
38    pub claimed_at: Option<String>,
39    #[serde(default)]
40    pub parent: Option<String>,
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
44pub struct IssueDetail {
45    pub id: String,
46    pub project: String,
47    pub title: String,
48    pub state: String,
49    pub priority: String,
50    pub properties: BTreeMap<String, String>,
51    pub org_tags: Vec<String>,
52    pub tags: Vec<String>,
53    pub blocked_by: Vec<String>,
54    pub parent: Option<String>,
55    pub claimed_by: Option<String>,
56    pub claimed_at: Option<String>,
57    pub file: String,
58    pub line_start: usize,
59    pub line_end: usize,
60    /// Prose under the heading, without the property drawer or logbook.
61    ///
62    /// Carried here so a caller that fetched the detail has what the issue
63    /// asks for, rather than a file path and a line range to go read.
64    #[serde(default)]
65    pub body: String,
66    #[serde(default)]
67    pub logbook: Vec<LogbookLine>,
68}
69
70/// One logbook line on a detail card: note, state flip, or raw CLOCK.
71#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
72pub struct LogbookLine {
73    #[serde(default)]
74    pub timestamp: String,
75    #[serde(default, skip_serializing_if = "Option::is_none")]
76    pub from_state: Option<String>,
77    #[serde(default, skip_serializing_if = "Option::is_none")]
78    pub to_state: Option<String>,
79    #[serde(default, skip_serializing_if = "Option::is_none")]
80    pub note: Option<String>,
81    #[serde(default, skip_serializing_if = "Option::is_none")]
82    pub raw: Option<String>,
83}
84
85#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
86pub struct ClaimRow {
87    pub id: String,
88    pub project: String,
89    pub state: String,
90    pub priority: String,
91    pub holder: Option<String>,
92    pub claimed_at: Option<String>,
93    pub age_days: i64,
94    pub title: String,
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
98pub struct Excerpt {
99    pub id: String,
100    pub file: String,
101    pub line_start: usize,
102    pub line_end: usize,
103    pub text: String,
104    pub suppressed: bool,
105}
106
107#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
108pub struct SearchHit {
109    pub id: String,
110    pub project: String,
111    pub state: String,
112    pub priority: String,
113    pub title: String,
114    pub snippet: String,
115}
116
117#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
118pub struct AgendaRow {
119    pub date: String,
120    pub kind: String,
121    pub overdue_days: i64,
122    pub id: String,
123    pub project: String,
124    pub state: String,
125    pub priority: String,
126    pub title: String,
127}
128
129#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
130pub struct TreeNode {
131    pub id: String,
132    pub state: String,
133    pub title: String,
134    pub children: Vec<TreeNode>,
135    pub blocked_by: Vec<String>,
136}
137
138#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
139pub struct RelatedHit {
140    pub id: String,
141    pub project: String,
142    pub state: String,
143    pub title: String,
144    pub score: f64,
145    pub evidence: Vec<String>,
146}
147
148#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
149pub struct WalkHit {
150    pub id: String,
151    pub project: String,
152    pub state: String,
153    pub title: String,
154    pub relation: String,
155}