feat: add bounded Ticket and Objective read APIs
This commit is contained in:
@@ -633,6 +633,12 @@ pub trait ControlPlaneStore: Send + Sync {
|
||||
|
||||
fn upsert_objective(&self, record: &ObjectiveRecord) -> Result<()>;
|
||||
fn list_objectives(&self, workspace_id: &str, limit: usize) -> Result<Vec<ObjectiveRecord>>;
|
||||
fn list_objectives_for_ticket(
|
||||
&self,
|
||||
workspace_id: &str,
|
||||
ticket_id: &str,
|
||||
limit: usize,
|
||||
) -> Result<Vec<ObjectiveRecord>>;
|
||||
fn get_objective(
|
||||
&self,
|
||||
workspace_id: &str,
|
||||
@@ -1552,6 +1558,33 @@ impl ControlPlaneStore for SqliteWorkspaceStore {
|
||||
})
|
||||
}
|
||||
|
||||
fn list_objectives_for_ticket(
|
||||
&self,
|
||||
workspace_id: &str,
|
||||
ticket_id: &str,
|
||||
limit: usize,
|
||||
) -> Result<Vec<ObjectiveRecord>> {
|
||||
self.with_conn(|conn| {
|
||||
let mut stmt = conn.prepare(
|
||||
r#"SELECT o.workspace_id, o.objective_id, o.title, o.state, o.body_md,
|
||||
o.created_at, o.updated_at
|
||||
FROM objectives AS o
|
||||
INNER JOIN objective_ticket_links AS l
|
||||
ON l.workspace_id = o.workspace_id
|
||||
AND l.objective_id = o.objective_id
|
||||
WHERE o.workspace_id = ?1 AND l.ticket_id = ?2
|
||||
ORDER BY o.updated_at DESC, o.objective_id ASC
|
||||
LIMIT ?3"#,
|
||||
)?;
|
||||
let rows = stmt.query_map(
|
||||
params![workspace_id, ticket_id, limit as i64],
|
||||
read_objective_record,
|
||||
)?;
|
||||
rows.collect::<std::result::Result<Vec<_>, _>>()
|
||||
.map_err(Error::from)
|
||||
})
|
||||
}
|
||||
|
||||
fn get_objective(
|
||||
&self,
|
||||
workspace_id: &str,
|
||||
|
||||
Reference in New Issue
Block a user