agregar sprint, has_impairment, tabla impairments + sync pendings KAPPA
This commit is contained in:
+104
-47
@@ -147,12 +147,28 @@ pub struct UserStory {
|
||||
pub estimated_hours: Option<f64>,
|
||||
pub actual_hours: Option<f64>,
|
||||
pub assigned_to: Option<i64>,
|
||||
pub sprint: Option<String>,
|
||||
pub has_impairment: bool,
|
||||
pub created_at: Option<String>,
|
||||
pub item_type: Option<String>,
|
||||
pub hierarchy_path: Option<String>,
|
||||
pub parent_code: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Impairment {
|
||||
pub id: i64,
|
||||
pub hu_id: i64,
|
||||
pub responsible: Option<String>,
|
||||
pub pending_activity: Option<String>,
|
||||
pub pending_type: Option<String>,
|
||||
pub type_impediment: bool,
|
||||
pub delivery_date: Option<String>,
|
||||
pub status: bool,
|
||||
pub created_at: Option<String>,
|
||||
pub updated_at: Option<String>,
|
||||
}
|
||||
|
||||
async fn get_conn(db_path: &str) -> Result<libsql::Connection, String> {
|
||||
let db = libsql::Builder::new_local(db_path)
|
||||
.build()
|
||||
@@ -271,45 +287,18 @@ async fn get_conn(db_path: &str) -> Result<libsql::Connection, String> {
|
||||
FOREIGN KEY (user_id) REFERENCES alpha_users(id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS epics (
|
||||
id INTEGER PRIMARY KEY,
|
||||
initiative_id INTEGER NOT NULL,
|
||||
code TEXT,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
status TEXT DEFAULT 'active',
|
||||
client_taker INTEGER,
|
||||
stimated_start_date TEXT,
|
||||
stimated_end_date TEXT,
|
||||
start_date TEXT,
|
||||
end_date TEXT,
|
||||
item_type TEXT DEFAULT 'E',
|
||||
hierarchy_path TEXT,
|
||||
created_at TEXT DEFAULT (datetime('now')),
|
||||
updated_at TEXT DEFAULT (datetime('now')),
|
||||
FOREIGN KEY (initiative_id) REFERENCES projects(id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user_stories (
|
||||
id INTEGER PRIMARY KEY,
|
||||
initiative_id INTEGER NOT NULL,
|
||||
epic_id INTEGER,
|
||||
code TEXT,
|
||||
title TEXT NOT NULL,
|
||||
description TEXT,
|
||||
acceptance_criteria TEXT,
|
||||
status TEXT DEFAULT 'backlog',
|
||||
priority TEXT DEFAULT 'medium',
|
||||
story_points REAL,
|
||||
estimated_hours REAL,
|
||||
actual_hours REAL,
|
||||
assigned_to INTEGER,
|
||||
item_type TEXT DEFAULT 'U',
|
||||
hierarchy_path TEXT,
|
||||
parent_code TEXT,
|
||||
created_at TEXT DEFAULT (datetime('now')),
|
||||
FOREIGN KEY (initiative_id) REFERENCES projects(id),
|
||||
FOREIGN KEY (epic_id) REFERENCES epics(id)
|
||||
CREATE TABLE IF NOT EXISTS impairments (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
hu_id INTEGER NOT NULL,
|
||||
responsible TEXT,
|
||||
pending_activity TEXT,
|
||||
pending_type TEXT,
|
||||
type_impediment INTEGER DEFAULT 0,
|
||||
delivery_date TEXT,
|
||||
status INTEGER DEFAULT 0,
|
||||
created_at TEXT,
|
||||
updated_at TEXT,
|
||||
FOREIGN KEY (hu_id) REFERENCES user_stories(id)
|
||||
);"
|
||||
)
|
||||
.await
|
||||
@@ -331,6 +320,8 @@ async fn get_conn(db_path: &str) -> Result<libsql::Connection, String> {
|
||||
"ALTER TABLE work_items ADD COLUMN estimated_hours REAL",
|
||||
"ALTER TABLE work_items ADD COLUMN actual_hours REAL",
|
||||
"ALTER TABLE work_items ADD COLUMN assigned_to INTEGER",
|
||||
"ALTER TABLE user_stories ADD COLUMN sprint TEXT",
|
||||
"ALTER TABLE user_stories ADD COLUMN has_impairment INTEGER DEFAULT 0",
|
||||
] {
|
||||
let _ = conn.execute(alter, ()).await;
|
||||
}
|
||||
@@ -962,9 +953,9 @@ pub mod commands {
|
||||
let conn = get_conn(&db_path).await?;
|
||||
|
||||
let query = if epic_id.is_some() {
|
||||
"SELECT id, initiative_id, epic_id, code, title, description, acceptance_criteria, status, priority, story_points, estimated_hours, actual_hours, assigned_to, created_at FROM user_stories WHERE initiative_id = ?1 AND epic_id = ?2 ORDER BY created_at DESC"
|
||||
"SELECT id, initiative_id, epic_id, code, title, description, acceptance_criteria, status, priority, story_points, estimated_hours, actual_hours, assigned_to, sprint, has_impairment, item_type, hierarchy_path, parent_code, created_at FROM user_stories WHERE initiative_id = ?1 AND epic_id = ?2 ORDER BY created_at DESC"
|
||||
} else {
|
||||
"SELECT id, initiative_id, epic_id, code, title, description, acceptance_criteria, status, priority, story_points, estimated_hours, actual_hours, assigned_to, created_at FROM user_stories WHERE initiative_id = ?1 ORDER BY created_at DESC"
|
||||
"SELECT id, initiative_id, epic_id, code, title, description, acceptance_criteria, status, priority, story_points, estimated_hours, actual_hours, assigned_to, sprint, has_impairment, item_type, hierarchy_path, parent_code, created_at FROM user_stories WHERE initiative_id = ?1 ORDER BY created_at DESC"
|
||||
};
|
||||
|
||||
let mut rows = if let Some(eid) = epic_id {
|
||||
@@ -989,10 +980,12 @@ pub mod commands {
|
||||
estimated_hours: row.get::<f64>(10).ok(),
|
||||
actual_hours: row.get::<f64>(11).ok(),
|
||||
assigned_to: row.get::<i64>(12).ok(),
|
||||
created_at: row.get::<String>(13).ok(),
|
||||
item_type: None,
|
||||
hierarchy_path: None,
|
||||
parent_code: None,
|
||||
sprint: row.get::<String>(13).ok(),
|
||||
has_impairment: row.get::<i64>(14).unwrap_or(0) != 0,
|
||||
item_type: row.get::<String>(15).ok(),
|
||||
hierarchy_path: row.get::<String>(16).ok(),
|
||||
parent_code: row.get::<String>(17).ok(),
|
||||
created_at: row.get::<String>(18).ok(),
|
||||
});
|
||||
}
|
||||
Ok(stories)
|
||||
@@ -1004,14 +997,15 @@ pub mod commands {
|
||||
let conn = get_conn(&db_path).await?;
|
||||
|
||||
conn.execute(
|
||||
"INSERT OR REPLACE INTO user_stories (id, initiative_id, epic_id, code, title, description, acceptance_criteria, status, priority, story_points, estimated_hours, actual_hours, assigned_to, item_type, hierarchy_path, parent_code)
|
||||
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16)",
|
||||
"INSERT OR REPLACE INTO user_stories (id, initiative_id, epic_id, code, title, description, acceptance_criteria, status, priority, story_points, estimated_hours, actual_hours, assigned_to, sprint, has_impairment, item_type, hierarchy_path, parent_code)
|
||||
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18)",
|
||||
libsql::params![
|
||||
story.id, story.initiative_id, story.epic_id,
|
||||
story.code, story.title, story.description,
|
||||
story.acceptance_criteria, story.status, story.priority,
|
||||
story.story_points, story.estimated_hours,
|
||||
story.actual_hours, story.assigned_to,
|
||||
story.sprint, story.has_impairment,
|
||||
story.item_type, story.hierarchy_path, story.parent_code,
|
||||
],
|
||||
)
|
||||
@@ -1032,4 +1026,67 @@ pub mod commands {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ────────────────────────────────────────────
|
||||
// Impairments
|
||||
// ────────────────────────────────────────────
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_impairments(state: State<'_, Mutex<String>>, hu_id: i64) -> Result<Vec<Impairment>, String> {
|
||||
let db_path = state.lock().map_err(|e| e.to_string())?.clone();
|
||||
let conn = get_conn(&db_path).await?;
|
||||
|
||||
let mut rows = conn
|
||||
.query("SELECT id, hu_id, responsible, pending_activity, pending_type, type_impediment, delivery_date, status, created_at, updated_at FROM impairments WHERE hu_id = ?1 ORDER BY created_at DESC", libsql::params![hu_id])
|
||||
.await
|
||||
.map_err(|e| format!("Query: {e}"))?;
|
||||
|
||||
let mut items = Vec::new();
|
||||
while let Some(row) = rows.next().await.map_err(|e| format!("Row: {e}"))? {
|
||||
items.push(Impairment {
|
||||
id: row.get::<i64>(0).unwrap_or(0),
|
||||
hu_id: row.get::<i64>(1).unwrap_or(0),
|
||||
responsible: row.get::<String>(2).ok(),
|
||||
pending_activity: row.get::<String>(3).ok(),
|
||||
pending_type: row.get::<String>(4).ok(),
|
||||
type_impediment: row.get::<i64>(5).unwrap_or(0) != 0,
|
||||
delivery_date: row.get::<String>(6).ok(),
|
||||
status: row.get::<i64>(7).unwrap_or(0) != 0,
|
||||
created_at: row.get::<String>(8).ok(),
|
||||
updated_at: row.get::<String>(9).ok(),
|
||||
});
|
||||
}
|
||||
Ok(items)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn save_impairment(state: State<'_, Mutex<String>>, imp: Impairment) -> Result<i64, String> {
|
||||
let db_path = state.lock().map_err(|e| e.to_string())?.clone();
|
||||
let conn = get_conn(&db_path).await?;
|
||||
|
||||
conn.execute(
|
||||
"INSERT OR REPLACE INTO impairments (id, hu_id, responsible, pending_activity, pending_type, type_impediment, delivery_date, status)
|
||||
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)",
|
||||
libsql::params![
|
||||
imp.id, imp.hu_id, imp.responsible, imp.pending_activity,
|
||||
imp.pending_type, imp.type_impediment, imp.delivery_date, imp.status,
|
||||
],
|
||||
)
|
||||
.await
|
||||
.map_err(|e| format!("Insert: {e}"))?;
|
||||
|
||||
Ok(conn.last_insert_rowid())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn delete_impairment(state: State<'_, Mutex<String>>, id: i64) -> Result<(), String> {
|
||||
let db_path = state.lock().map_err(|e| e.to_string())?.clone();
|
||||
let conn = get_conn(&db_path).await?;
|
||||
|
||||
conn.execute("DELETE FROM impairments WHERE id = ?1", libsql::params![id])
|
||||
.await
|
||||
.map_err(|e| format!("Delete: {e}"))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,9 @@ fn main() {
|
||||
commands::get_user_stories,
|
||||
commands::save_user_story,
|
||||
commands::delete_user_story,
|
||||
commands::get_impairments,
|
||||
commands::save_impairment,
|
||||
commands::delete_impairment,
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
||||
Reference in New Issue
Block a user