| 1 | |
|
| 2 | |
|
| 3 | | use super::{now_ms, Pool}; |
| 4 | | use sqlx::FromRow; |
| 5 | |
|
| 6 | | #[derive(Clone, Debug, FromRow)] |
| 7 | | pub struct Project { |
| 8 | | pub id: i64, |
| 9 | | pub owner: String, |
| 10 | | pub number: i64, |
| 11 | | pub title: String, |
| 12 | | pub description: String, |
| 13 | | pub public: bool, |
| 14 | | pub closed: bool, |
| 15 | | pub created_ms: i64, |
| 16 | | pub updated_ms: i64, |
| 17 | | } |
| 18 | |
|
| 19 | | #[derive(Clone, Debug, FromRow)] |
| 20 | | pub struct Column { |
| 21 | | pub id: i64, |
| 22 | | pub project_id: i64, |
| 23 | | pub name: String, |
| 24 | | pub position: i64, |
| 25 | | |
| 26 | | pub archive_after_days: Option<i64>, |
| 27 | | |
| 28 | | |
| 29 | | pub takes_finished: bool, |
| 30 | | |
| 31 | | #[sqlx(default)] |
| 32 | | pub wip_limit: Option<i64>, |
| 33 | | } |
| 34 | |
|
| 35 | | #[derive(Clone, Debug, FromRow)] |
| 36 | | pub struct Card { |
| 37 | | pub id: i64, |
| 38 | | pub project_id: i64, |
| 39 | | pub column_id: i64, |
| 40 | | pub position: i64, |
| 41 | | pub kind: String, |
| 42 | | pub repo_id: Option<i64>, |
| 43 | | pub number: Option<i64>, |
| 44 | | pub note: String, |
| 45 | | pub added_by: String, |
| 46 | | pub created_ms: i64, |
| 47 | | |
| 48 | | pub archived_ms: Option<i64>, |
| 49 | | |
| 50 | | pub moved_ms: i64, |
| 51 | | |
| 52 | | pub iteration_id: Option<i64>, |
| 53 | | } |
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | | #[derive(Clone, Debug, FromRow)] |
| 58 | | pub struct Iteration { |
| 59 | | pub id: i64, |
| 60 | | pub project_id: i64, |
| 61 | | pub name: String, |
| 62 | | pub start_ms: i64, |
| 63 | | |
| 64 | | pub end_ms: i64, |
| 65 | | pub closed_ms: Option<i64>, |
| 66 | | } |
| 67 | |
|
| 68 | |
|
| 69 | | const DAY_MS: i64 = 86_400_000; |
| 70 | |
|
| 71 | | pub const DEFAULT_COLUMNS: [&str; 3] = ["Backlog", "Doing", "Done"]; |
| 72 | |
|
| 73 | 13× | pub async fn create(pool: &Pool, owner: &str, title: &str, description: &str, public: bool) -> sqlx::Result<Project> { |
| 74 | 13× | let mut tx = super::begin_write(pool).await?; |
| 75 | 13× | let number: i64 = |
| 76 | 13× | sqlx::query_scalar("SELECT COALESCE(MAX(number), 0) + 1 FROM projects WHERE owner = $1").bind(owner).fetch_one(&mut *tx).await?; |
| 77 | 13× | let now = now_ms(); |
| 78 | 13× | let p: Project = sqlx::query_as( |
| 79 | 13× | "INSERT INTO projects (owner, number, title, description, public, created_ms, updated_ms) VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING *", |
| 80 | 13× | ) |
| 81 | 13× | .bind(owner) |
| 82 | 13× | .bind(number) |
| 83 | 13× | .bind(title) |
| 84 | 13× | .bind(description) |
| 85 | 13× | .bind(public) |
| 86 | 13× | .bind(now) |
| 87 | 13× | .bind(now) |
| 88 | 13× | .fetch_one(&mut *tx) |
| 89 | 13× | .await?; |
| 90 | | |
| 91 | 13× | sqlx::query("DELETE FROM project_redirects WHERE owner = $1 AND number = $2").bind(owner).bind(number).execute(&mut *tx).await?; |
| 92 | 39× | for (i, name) in DEFAULT_COLUMNS.iter().enumerate() { |
| 93 | 39× | sqlx::query("INSERT INTO project_columns (project_id, name, position, takes_finished) VALUES ($1, $2, $3, $4)") |
| 94 | 39× | .bind(p.id) |
| 95 | 39× | .bind(name) |
| 96 | 39× | .bind(i as i64) |
| 97 | 39× | .bind(*name == "Done") |
| 98 | 39× | .execute(&mut *tx) |
| 99 | 39× | .await?; |
| 100 | | } |
| 101 | 13× | tx.commit().await?; |
| 102 | 13× | Ok(p) |
| 103 | 13× | } |
| 104 | |
|
| 105 | 141× | pub async fn of_owner(pool: &Pool, owner: &str) -> sqlx::Result<Vec<Project>> { |
| 106 | 141× | sqlx::query_as("SELECT * FROM projects WHERE owner = $1 ORDER BY closed, updated_ms DESC").bind(owner).fetch_all(pool).await |
| 107 | 141× | } |
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | 1× | pub async fn transfer(pool: &Pool, id: i64, to: &str) -> sqlx::Result<Project> { |
| 112 | 1× | let mut tx = super::begin_write(pool).await?; |
| 113 | 1× | let old: Project = sqlx::query_as("SELECT * FROM projects WHERE id = $1").bind(id).fetch_one(&mut *tx).await?; |
| 114 | 1× | let number: i64 = |
| 115 | 1× | sqlx::query_scalar("SELECT COALESCE(MAX(number), 0) + 1 FROM projects WHERE owner = $1").bind(to).fetch_one(&mut *tx).await?; |
| 116 | 1× | sqlx::query("INSERT INTO project_redirects (owner, number, project_id) VALUES ($1, $2, $3) ON CONFLICT (owner, number) DO UPDATE SET project_id = excluded.project_id") |
| 117 | 1× | .bind(&old.owner) |
| 118 | 1× | .bind(old.number) |
| 119 | 1× | .bind(id) |
| 120 | 1× | .execute(&mut *tx) |
| 121 | 1× | .await?; |
| 122 | 1× | sqlx::query("DELETE FROM project_redirects WHERE owner = $1 AND number = $2").bind(to).bind(number).execute(&mut *tx).await?; |
| 123 | 1× | let moved: Project = sqlx::query_as("UPDATE projects SET owner = $1, number = $2, updated_ms = $3 WHERE id = $4 RETURNING *") |
| 124 | 1× | .bind(to) |
| 125 | 1× | .bind(number) |
| 126 | 1× | .bind(now_ms()) |
| 127 | 1× | .bind(id) |
| 128 | 1× | .fetch_one(&mut *tx) |
| 129 | 1× | .await?; |
| 130 | 1× | tx.commit().await?; |
| 131 | 1× | Ok(moved) |
| 132 | 1× | } |
| 133 | |
|
| 134 | |
|
| 135 | |
|
| 136 | 2× | pub async fn redirected(pool: &Pool, owner: &str, number: i64) -> sqlx::Result<Option<Project>> { |
| 137 | 2× | sqlx::query_as("SELECT p.* FROM project_redirects r JOIN projects p ON p.id = r.project_id WHERE r.owner = $1 AND r.number = $2") |
| 138 | 2× | .bind(owner) |
| 139 | 2× | .bind(number) |
| 140 | 2× | .fetch_optional(pool) |
| 141 | 2× | .await |
| 142 | 2× | } |
| 143 | |
|
| 144 | 228× | pub async fn get(pool: &Pool, owner: &str, number: i64) -> sqlx::Result<Option<Project>> { |
| 145 | 228× | sqlx::query_as("SELECT * FROM projects WHERE owner = $1 AND number = $2").bind(owner).bind(number).fetch_optional(pool).await |
| 146 | 228× | } |
| 147 | |
|
| 148 | 6× | pub async fn set(pool: &Pool, id: i64, title: &str, description: &str, public: bool, closed: bool) -> sqlx::Result<()> { |
| 149 | 6× | sqlx::query("UPDATE projects SET title = $1, description = $2, public = $3, closed = $4, updated_ms = $5 WHERE id = $6") |
| 150 | 6× | .bind(title) |
| 151 | 6× | .bind(description) |
| 152 | 6× | .bind(public) |
| 153 | 6× | .bind(closed) |
| 154 | 6× | .bind(now_ms()) |
| 155 | 6× | .bind(id) |
| 156 | 6× | .execute(pool) |
| 157 | 6× | .await?; |
| 158 | 6× | Ok(()) |
| 159 | 6× | } |
| 160 | |
|
| 161 | 1× | pub async fn delete(pool: &Pool, id: i64) -> sqlx::Result<()> { |
| 162 | 1× | sqlx::query("DELETE FROM projects WHERE id = $1").bind(id).execute(pool).await?; |
| 163 | 1× | Ok(()) |
| 164 | 1× | } |
| 165 | |
|
| 166 | 45× | async fn touch(pool: &Pool, id: i64) -> sqlx::Result<()> { |
| 167 | 45× | sqlx::query("UPDATE projects SET updated_ms = $1 WHERE id = $2").bind(now_ms()).bind(id).execute(pool).await?; |
| 168 | 45× | Ok(()) |
| 169 | 45× | } |
| 170 | |
|
| 171 | 175× | pub async fn columns(pool: &Pool, project_id: i64) -> sqlx::Result<Vec<Column>> { |
| 172 | 175× | sqlx::query_as("SELECT * FROM project_columns WHERE project_id = $1 ORDER BY position, id").bind(project_id).fetch_all(pool).await |
| 173 | 175× | } |
| 174 | |
|
| 175 | 101× | pub async fn cards(pool: &Pool, project_id: i64) -> sqlx::Result<Vec<Card>> { |
| 176 | 101× | sqlx::query_as("SELECT * FROM project_cards WHERE project_id = $1 ORDER BY position, id").bind(project_id).fetch_all(pool).await |
| 177 | 101× | } |
| 178 | |
|
| 179 | 1× | pub async fn add_column(pool: &Pool, project_id: i64, name: &str) -> sqlx::Result<()> { |
| 180 | 1× | let pos: i64 = sqlx::query_scalar("SELECT COALESCE(MAX(position), -1) + 1 FROM project_columns WHERE project_id = $1") |
| 181 | 1× | .bind(project_id) |
| 182 | 1× | .fetch_one(pool) |
| 183 | 1× | .await?; |
| 184 | 1× | sqlx::query("INSERT INTO project_columns (project_id, name, position) VALUES ($1, $2, $3)") |
| 185 | 1× | .bind(project_id) |
| 186 | 1× | .bind(name) |
| 187 | 1× | .bind(pos) |
| 188 | 1× | .execute(pool) |
| 189 | 1× | .await?; |
| 190 | 1× | touch(pool, project_id).await |
| 191 | 1× | } |
| 192 | |
|
| 193 | 1× | pub async fn rename_column(pool: &Pool, project_id: i64, column_id: i64, name: &str) -> sqlx::Result<()> { |
| 194 | 1× | sqlx::query("UPDATE project_columns SET name = $1 WHERE id = $2 AND project_id = $3") |
| 195 | 1× | .bind(name) |
| 196 | 1× | .bind(column_id) |
| 197 | 1× | .bind(project_id) |
| 198 | 1× | .execute(pool) |
| 199 | 1× | .await?; |
| 200 | 1× | touch(pool, project_id).await |
| 201 | 1× | } |
| 202 | |
|
| 203 | |
|
| 204 | 0× | pub async fn shift_column(pool: &Pool, project_id: i64, column_id: i64, by: i64) -> sqlx::Result<()> { |
| 205 | 0× | let cols = columns(pool, project_id).await?; |
| 206 | 0× | let Some(i) = cols.iter().position(|c| c.id == column_id) else { return Ok(()) }; |
| 207 | 0× | let j = i as i64 + by; |
| 208 | 0× | if j < 0 || j as usize >= cols.len() { |
| 209 | 0× | return Ok(()); |
| 210 | 0× | } |
| 211 | 0× | let mut ids: Vec<i64> = cols.iter().map(|c| c.id).collect(); |
| 212 | 0× | ids.swap(i, j as usize); |
| 213 | 0× | for (pos, id) in ids.iter().enumerate() { |
| 214 | 0× | sqlx::query("UPDATE project_columns SET position = $1 WHERE id = $2").bind(pos as i64).bind(id).execute(pool).await?; |
| 215 | | } |
| 216 | 0× | touch(pool, project_id).await |
| 217 | 0× | } |
| 218 | |
|
| 219 | |
|
| 220 | 2× | pub async fn place_column(pool: &Pool, project_id: i64, column_id: i64, position: i64) -> sqlx::Result<()> { |
| 221 | 2× | let cols = columns(pool, project_id).await?; |
| 222 | 5× | let Some(i) = cols.iter().position(|c| c.id == column_id) else { return Ok(()) }; |
| 223 | 2× | let mut ids: Vec<i64> = cols.iter().map(|c| c.id).collect(); |
| 224 | 2× | let id = ids.remove(i); |
| 225 | 2× | ids.insert((position.max(0) as usize).min(ids.len()), id); |
| 226 | 8× | for (pos, id) in ids.iter().enumerate() { |
| 227 | 8× | sqlx::query("UPDATE project_columns SET position = $1 WHERE id = $2").bind(pos as i64).bind(id).execute(pool).await?; |
| 228 | | } |
| 229 | 2× | touch(pool, project_id).await |
| 230 | 2× | } |
| 231 | |
|
| 232 | |
|
| 233 | 4× | pub async fn remove_column(pool: &Pool, project_id: i64, column_id: i64) -> sqlx::Result<bool> { |
| 234 | 4× | let cols = columns(pool, project_id).await?; |
| 235 | 4× | let Some(to) = cols.iter().find(|c| c.id != column_id) else { return Ok(false) }; |
| 236 | 8× | if !cols.iter().any(|c| c.id == column_id) { |
| 237 | 0× | return Ok(false); |
| 238 | 3× | } |
| 239 | 3× | let mut tx = super::begin_write(pool).await?; |
| 240 | 3× | let base: i64 = sqlx::query_scalar("SELECT COALESCE(MAX(position), -1) + 1 FROM project_cards WHERE column_id = $1") |
| 241 | 3× | .bind(to.id) |
| 242 | 3× | .fetch_one(&mut *tx) |
| 243 | 3× | .await?; |
| 244 | 3× | log_moves(&mut *tx, Some(to.id), now_ms(), "column_id = $1 AND archived_ms IS NULL", &[column_id]).await?; |
| 245 | 3× | sqlx::query("UPDATE project_cards SET column_id = $1, position = position + $2 WHERE column_id = $3") |
| 246 | 3× | .bind(to.id) |
| 247 | 3× | .bind(base) |
| 248 | 3× | .bind(column_id) |
| 249 | 3× | .execute(&mut *tx) |
| 250 | 3× | .await?; |
| 251 | 3× | sqlx::query("DELETE FROM project_columns WHERE id = $1").bind(column_id).execute(&mut *tx).await?; |
| 252 | 3× | tx.commit().await?; |
| 253 | 3× | touch(pool, project_id).await?; |
| 254 | 3× | Ok(true) |
| 255 | 4× | } |
| 256 | |
|
| 257 | |
|
| 258 | |
|
| 259 | |
|
| 260 | |
|
| 261 | 451× | async fn log_moves<'e, E: sqlx::Executor<'e, Database = super::Db>>( |
| 262 | 451× | ex: E, |
| 263 | 451× | column: Option<i64>, |
| 264 | 451× | at: i64, |
| 265 | 451× | select: &str, |
| 266 | 451× | binds: &[i64], |
| 267 | 451× | ) -> sqlx::Result<()> { |
| 268 | 451× | let sql = format!( |
| 269 | | "INSERT INTO project_card_moves (project_id, card_id, column_id, at_ms) SELECT project_id, id, {}, {at} FROM project_cards WHERE {select}", |
| 270 | 451× | match column { |
| 271 | 26× | Some(c) => c.to_string(), |
| 272 | 425× | None => "NULL".to_string(), |
| 273 | | } |
| 274 | | ); |
| 275 | 451× | let mut q = sqlx::query(&sql); |
| 276 | 679× | for b in binds { |
| 277 | 679× | q = q.bind(*b); |
| 278 | 679× | } |
| 279 | 451× | q.execute(ex).await?; |
| 280 | 451× | Ok(()) |
| 281 | 451× | } |
| 282 | |
|
| 283 | |
|
| 284 | |
|
| 285 | 4× | pub async fn moves(pool: &Pool, project_id: i64, since: i64) -> sqlx::Result<Vec<(i64, Option<i64>, i64)>> { |
| 286 | 4× | sqlx::query_as("SELECT card_id, column_id, at_ms FROM project_card_moves WHERE project_id = $1 AND at_ms >= $2 ORDER BY at_ms, id") |
| 287 | 4× | .bind(project_id) |
| 288 | 4× | .bind(since) |
| 289 | 4× | .fetch_all(pool) |
| 290 | 4× | .await |
| 291 | 4× | } |
| 292 | |
|
| 293 | | pub struct NewCard<'a> { |
| 294 | | pub column_id: i64, |
| 295 | | pub kind: &'a str, |
| 296 | | pub repo_id: Option<i64>, |
| 297 | | pub number: Option<i64>, |
| 298 | | pub note: &'a str, |
| 299 | | pub added_by: &'a str, |
| 300 | | } |
| 301 | |
|
| 302 | |
|
| 303 | |
|
| 304 | 21× | pub async fn add_card(pool: &Pool, project_id: i64, c: NewCard<'_>) -> sqlx::Result<bool> { |
| 305 | 21× | let pos: i64 = sqlx::query_scalar("SELECT COALESCE(MAX(position), -1) + 1 FROM project_cards WHERE column_id = $1") |
| 306 | 21× | .bind(c.column_id) |
| 307 | 21× | .fetch_one(pool) |
| 308 | 21× | .await?; |
| 309 | 21× | let now = now_ms(); |
| 310 | 21× | let id: Option<i64> = sqlx::query_scalar( |
| 311 | 21× | "INSERT INTO project_cards (project_id, column_id, position, kind, repo_id, number, note, added_by, created_ms, moved_ms) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $9) ON CONFLICT DO NOTHING RETURNING id", |
| 312 | 21× | ) |
| 313 | 21× | .bind(project_id) |
| 314 | 21× | .bind(c.column_id) |
| 315 | 21× | .bind(pos) |
| 316 | 21× | .bind(c.kind) |
| 317 | 21× | .bind(c.repo_id) |
| 318 | 21× | .bind(c.number) |
| 319 | 21× | .bind(c.note) |
| 320 | 21× | .bind(c.added_by) |
| 321 | 21× | .bind(now) |
| 322 | 21× | .fetch_optional(pool) |
| 323 | 21× | .await?; |
| 324 | 21× | if let Some(id) = id { |
| 325 | 17× | log_moves(pool, Some(c.column_id), now, "id = $1", &[id]).await?; |
| 326 | 4× | } |
| 327 | 21× | touch(pool, project_id).await?; |
| 328 | 21× | Ok(id.is_some()) |
| 329 | 21× | } |
| 330 | |
|
| 331 | |
|
| 332 | 5× | pub async fn move_card(pool: &Pool, project_id: i64, card_id: i64, column_id: i64) -> sqlx::Result<()> { |
| 333 | 5× | let ok: i64 = sqlx::query_scalar("SELECT COUNT(*) FROM project_columns WHERE id = $1 AND project_id = $2") |
| 334 | 5× | .bind(column_id) |
| 335 | 5× | .bind(project_id) |
| 336 | 5× | .fetch_one(pool) |
| 337 | 5× | .await?; |
| 338 | 5× | if ok == 0 { |
| 339 | 0× | return Ok(()); |
| 340 | 5× | } |
| 341 | 5× | let pos: i64 = sqlx::query_scalar("SELECT COALESCE(MAX(position), -1) + 1 FROM project_cards WHERE column_id = $1") |
| 342 | 5× | .bind(column_id) |
| 343 | 5× | .fetch_one(pool) |
| 344 | 5× | .await?; |
| 345 | 5× | let now = now_ms(); |
| 346 | 5× | log_moves( |
| 347 | 5× | pool, |
| 348 | 5× | Some(column_id), |
| 349 | 5× | now, |
| 350 | 5× | "id = $1 AND project_id = $2 AND column_id <> $3 AND archived_ms IS NULL", |
| 351 | 5× | &[card_id, project_id, column_id], |
| 352 | 5× | ) |
| 353 | 5× | .await?; |
| 354 | 5× | sqlx::query("UPDATE project_cards SET moved_ms = CASE WHEN column_id = $1 THEN moved_ms ELSE $3 END, column_id = $1, position = $2 WHERE id = $4 AND project_id = $5") |
| 355 | 5× | .bind(column_id) |
| 356 | 5× | .bind(pos) |
| 357 | 5× | .bind(now) |
| 358 | 5× | .bind(card_id) |
| 359 | 5× | .bind(project_id) |
| 360 | 5× | .execute(pool) |
| 361 | 5× | .await?; |
| 362 | 5× | touch(pool, project_id).await |
| 363 | 5× | } |
| 364 | |
|
| 365 | |
|
| 366 | |
|
| 367 | 1× | pub async fn move_cards(pool: &Pool, project_id: i64, card_ids: &[i64], column_id: i64) -> sqlx::Result<()> { |
| 368 | 1× | let mut tx = pool.begin().await?; |
| 369 | 1× | let pos: i64 = sqlx::query_scalar("SELECT COALESCE(MAX(position), -1) + 1 FROM project_cards WHERE column_id = $1") |
| 370 | 1× | .bind(column_id) |
| 371 | 1× | .fetch_one(&mut *tx) |
| 372 | 1× | .await?; |
| 373 | 1× | let now = now_ms(); |
| 374 | 1× | for (i, id) in card_ids.iter().enumerate() { |
| 375 | 1× | log_moves( |
| 376 | 1× | &mut *tx, |
| 377 | 1× | Some(column_id), |
| 378 | 1× | now, |
| 379 | 1× | "id = $1 AND project_id = $2 AND column_id <> $3 AND archived_ms IS NULL", |
| 380 | 1× | &[*id, project_id, column_id], |
| 381 | 1× | ) |
| 382 | 1× | .await?; |
| 383 | 1× | sqlx::query("UPDATE project_cards SET column_id = $1, position = $2, moved_ms = $3 WHERE id = $4 AND project_id = $5") |
| 384 | 1× | .bind(column_id) |
| 385 | 1× | .bind(pos + i as i64) |
| 386 | 1× | .bind(now) |
| 387 | 1× | .bind(id) |
| 388 | 1× | .bind(project_id) |
| 389 | 1× | .execute(&mut *tx) |
| 390 | 1× | .await?; |
| 391 | | } |
| 392 | 1× | sqlx::query("UPDATE projects SET updated_ms = $1 WHERE id = $2").bind(now).bind(project_id).execute(&mut *tx).await?; |
| 393 | 1× | tx.commit().await |
| 394 | 1× | } |
| 395 | |
|
| 396 | |
|
| 397 | 3× | pub async fn archive_cards(pool: &Pool, project_id: i64, card_ids: &[i64]) -> sqlx::Result<u64> { |
| 398 | 3× | let mut tx = pool.begin().await?; |
| 399 | 3× | let now = now_ms(); |
| 400 | 3× | let mut n = 0; |
| 401 | 3× | for id in card_ids { |
| 402 | 3× | log_moves(&mut *tx, None, now, "id = $1 AND project_id = $2 AND archived_ms IS NULL", &[*id, project_id]).await?; |
| 403 | 3× | n += sqlx::query("UPDATE project_cards SET archived_ms = $1 WHERE id = $2 AND project_id = $3 AND archived_ms IS NULL") |
| 404 | 3× | .bind(now) |
| 405 | 3× | .bind(id) |
| 406 | 3× | .bind(project_id) |
| 407 | 3× | .execute(&mut *tx) |
| 408 | 3× | .await? |
| 409 | 3× | .rows_affected(); |
| 410 | | } |
| 411 | 3× | sqlx::query("UPDATE projects SET updated_ms = $1 WHERE id = $2").bind(now).bind(project_id).execute(&mut *tx).await?; |
| 412 | 3× | tx.commit().await?; |
| 413 | 3× | Ok(n) |
| 414 | 3× | } |
| 415 | |
|
| 416 | |
|
| 417 | |
|
| 418 | |
|
| 419 | 3× | pub async fn restore_card(pool: &Pool, project_id: i64, card_id: i64) -> sqlx::Result<bool> { |
| 420 | 3× | let mut tx = pool.begin().await?; |
| 421 | 3× | let pos: i64 = sqlx::query_scalar( |
| 422 | 3× | "SELECT COALESCE(MAX(position), -1) + 1 FROM project_cards WHERE column_id = (SELECT column_id FROM project_cards WHERE id = $1)", |
| 423 | 3× | ) |
| 424 | 3× | .bind(card_id) |
| 425 | 3× | .fetch_one(&mut *tx) |
| 426 | 3× | .await?; |
| 427 | 3× | let now = now_ms(); |
| 428 | 3× | sqlx::query(&format!( |
| 429 | 3× | "INSERT INTO project_card_moves (project_id, card_id, column_id, at_ms) SELECT project_id, id, column_id, {now} FROM project_cards \ |
| 430 | 3× | WHERE id = $1 AND project_id = $2 AND archived_ms IS NOT NULL" |
| 431 | 3× | )) |
| 432 | 3× | .bind(card_id) |
| 433 | 3× | .bind(project_id) |
| 434 | 3× | .execute(&mut *tx) |
| 435 | 3× | .await?; |
| 436 | | |
| 437 | 3× | let r = sqlx::query( |
| 438 | 3× | "UPDATE project_cards SET archived_ms = NULL, iteration_id = NULL, moved_ms = $1, position = $2 \ |
| 439 | 3× | WHERE id = $3 AND project_id = $4 AND archived_ms IS NOT NULL", |
| 440 | 3× | ) |
| 441 | 3× | .bind(now) |
| 442 | 3× | .bind(pos) |
| 443 | 3× | .bind(card_id) |
| 444 | 3× | .bind(project_id) |
| 445 | 3× | .execute(&mut *tx) |
| 446 | 3× | .await?; |
| 447 | 3× | sqlx::query("UPDATE projects SET updated_ms = $1 WHERE id = $2").bind(now).bind(project_id).execute(&mut *tx).await?; |
| 448 | 3× | tx.commit().await?; |
| 449 | 3× | Ok(r.rows_affected() == 1) |
| 450 | 3× | } |
| 451 | |
|
| 452 | |
|
| 453 | 8× | pub fn older_than(card: &Card, days: i64, now: i64) -> bool { |
| 454 | 8× | card.moved_ms < now - days * DAY_MS |
| 455 | 8× | } |
| 456 | |
|
| 457 | |
|
| 458 | 61× | pub async fn iterations(pool: &Pool, project_id: i64) -> sqlx::Result<Vec<Iteration>> { |
| 459 | 61× | sqlx::query_as("SELECT * FROM project_iterations WHERE project_id = $1 ORDER BY start_ms DESC, id DESC") |
| 460 | 61× | .bind(project_id) |
| 461 | 61× | .fetch_all(pool) |
| 462 | 61× | .await |
| 463 | 61× | } |
| 464 | |
|
| 465 | |
|
| 466 | 2× | pub async fn start_iteration(pool: &Pool, project_id: i64, name: &str, start_ms: i64, end_ms: i64) -> sqlx::Result<Option<Iteration>> { |
| 467 | 2× | let mut tx = super::begin_write(pool).await?; |
| 468 | 2× | let open: i64 = sqlx::query_scalar("SELECT COUNT(*) FROM project_iterations WHERE project_id = $1 AND closed_ms IS NULL") |
| 469 | 2× | .bind(project_id) |
| 470 | 2× | .fetch_one(&mut *tx) |
| 471 | 2× | .await?; |
| 472 | 2× | if open > 0 { |
| 473 | 1× | return Ok(None); |
| 474 | 1× | } |
| 475 | 1× | let it: Iteration = |
| 476 | 1× | sqlx::query_as("INSERT INTO project_iterations (project_id, name, start_ms, end_ms) VALUES ($1, $2, $3, $4) RETURNING *") |
| 477 | 1× | .bind(project_id) |
| 478 | 1× | .bind(name) |
| 479 | 1× | .bind(start_ms) |
| 480 | 1× | .bind(end_ms) |
| 481 | 1× | .fetch_one(&mut *tx) |
| 482 | 1× | .await?; |
| 483 | 1× | sqlx::query("UPDATE projects SET updated_ms = $1 WHERE id = $2").bind(now_ms()).bind(project_id).execute(&mut *tx).await?; |
| 484 | 1× | tx.commit().await?; |
| 485 | 1× | Ok(Some(it)) |
| 486 | 2× | } |
| 487 | |
|
| 488 | |
|
| 489 | |
|
| 490 | 63× | pub fn done_column(columns: &[Column]) -> Option<i64> { |
| 491 | 63× | columns.iter().find(|c| c.takes_finished).or(columns.last()).map(|c| c.id) |
| 492 | 63× | } |
| 493 | |
|
| 494 | |
|
| 495 | |
|
| 496 | 2× | pub async fn close_iteration(pool: &Pool, project_id: i64, iteration_id: i64, done: Option<i64>) -> sqlx::Result<Option<u64>> { |
| 497 | 2× | let mut tx = super::begin_write(pool).await?; |
| 498 | 2× | let now = now_ms(); |
| 499 | 2× | let closed = sqlx::query("UPDATE project_iterations SET closed_ms = $1 WHERE id = $2 AND project_id = $3 AND closed_ms IS NULL") |
| 500 | 2× | .bind(now) |
| 501 | 2× | .bind(iteration_id) |
| 502 | 2× | .bind(project_id) |
| 503 | 2× | .execute(&mut *tx) |
| 504 | 2× | .await?; |
| 505 | 2× | if closed.rows_affected() == 0 { |
| 506 | 1× | return Ok(None); |
| 507 | 1× | } |
| 508 | 1× | let mut n = 0; |
| 509 | 1× | if let Some(done) = done { |
| 510 | 1× | log_moves(&mut *tx, None, now, "project_id = $1 AND column_id = $2 AND archived_ms IS NULL", &[project_id, done]).await?; |
| 511 | 1× | n = sqlx::query( |
| 512 | 1× | "UPDATE project_cards SET archived_ms = $1, iteration_id = $2 WHERE project_id = $3 AND column_id = $4 AND archived_ms IS NULL", |
| 513 | 1× | ) |
| 514 | 1× | .bind(now) |
| 515 | 1× | .bind(iteration_id) |
| 516 | 1× | .bind(project_id) |
| 517 | 1× | .bind(done) |
| 518 | 1× | .execute(&mut *tx) |
| 519 | 1× | .await? |
| 520 | 1× | .rows_affected(); |
| 521 | 0× | } |
| 522 | 1× | sqlx::query("UPDATE projects SET updated_ms = $1 WHERE id = $2").bind(now).bind(project_id).execute(&mut *tx).await?; |
| 523 | 1× | tx.commit().await?; |
| 524 | 1× | Ok(Some(n)) |
| 525 | 2× | } |
| 526 | |
|
| 527 | |
|
| 528 | |
|
| 529 | |
|
| 530 | 11× | pub async fn done_times(pool: &Pool, it: &Iteration, done: Option<i64>) -> sqlx::Result<Vec<i64>> { |
| 531 | 11× | sqlx::query_scalar( |
| 532 | 11× | "SELECT moved_ms FROM project_cards WHERE project_id = $1 AND (iteration_id = $2 \ |
| 533 | 11× | OR ($3 AND iteration_id IS NULL AND column_id = $4 AND (archived_ms IS NULL OR archived_ms >= $5))) ORDER BY moved_ms", |
| 534 | 11× | ) |
| 535 | 11× | .bind(it.project_id) |
| 536 | 11× | .bind(it.id) |
| 537 | 11× | .bind(it.closed_ms.is_none()) |
| 538 | 11× | .bind(done.unwrap_or(-1)) |
| 539 | 11× | .bind(it.start_ms) |
| 540 | 11× | .fetch_all(pool) |
| 541 | 11× | .await |
| 542 | 11× | } |
| 543 | |
|
| 544 | |
|
| 545 | |
|
| 546 | |
|
| 547 | 14× | pub fn burn_up(times: &[i64], start_ms: i64, end_ms: i64, now: i64) -> Vec<usize> { |
| 548 | 14× | let days = ((end_ms - start_ms + DAY_MS - 1) / DAY_MS).max(1); |
| 549 | 14× | let upto = ((now.min(end_ms - 1) - start_ms) / DAY_MS + 1).clamp(0, days); |
| 550 | 112× | (0..upto).map(|d| times.iter().filter(|&&t| t < start_ms + (d + 1) * DAY_MS).count()).collect() |
| 551 | 14× | } |
| 552 | |
|
| 553 | |
|
| 554 | 11× | pub fn iteration_days(it: &Iteration) -> i64 { |
| 555 | 11× | ((it.end_ms - it.start_ms + DAY_MS - 1) / DAY_MS).max(1) |
| 556 | 11× | } |
| 557 | |
|
| 558 | |
|
| 559 | |
|
| 560 | |
|
| 561 | 3× | pub async fn set_archive_after(pool: &Pool, project_id: i64, column_id: i64, days: Option<i64>) -> sqlx::Result<()> { |
| 562 | 3× | sqlx::query("UPDATE project_columns SET archive_after_days = $1 WHERE id = $2 AND project_id = $3") |
| 563 | 3× | .bind(days) |
| 564 | 3× | .bind(column_id) |
| 565 | 3× | .bind(project_id) |
| 566 | 3× | .execute(pool) |
| 567 | 3× | .await?; |
| 568 | 3× | touch(pool, project_id).await |
| 569 | 3× | } |
| 570 | |
|
| 571 | |
|
| 572 | |
|
| 573 | | pub const FINISHED_KEPT_DAYS: i64 = 14; |
| 574 | |
|
| 575 | |
|
| 576 | |
|
| 577 | |
|
| 578 | | const FINISHED_DUE: &str = "archived_ms IS NULL AND moved_ms < $1 \ |
| 579 | | AND EXISTS (SELECT 1 FROM project_columns c WHERE c.id = project_cards.column_id AND c.archive_after_days IS NULL) \ |
| 580 | | AND ((kind = 'issue' AND EXISTS (SELECT 1 FROM issues i WHERE i.repo_id = project_cards.repo_id \ |
| 581 | | AND i.number = project_cards.number AND i.state = 'closed')) \ |
| 582 | | OR (kind = 'proposal' AND EXISTS (SELECT 1 FROM proposals p WHERE p.repo_id = project_cards.repo_id \ |
| 583 | | AND p.number = project_cards.number AND p.state IN ('closed', 'landed'))))"; |
| 584 | |
|
| 585 | |
|
| 586 | | pub const NEVER: i64 = -1; |
| 587 | |
|
| 588 | |
|
| 589 | |
|
| 590 | |
|
| 591 | |
|
| 592 | |
|
| 593 | 209× | pub async fn archive_due(pool: &Pool, now: i64) -> sqlx::Result<u64> { |
| 594 | 209× | log_moves( |
| 595 | 209× | pool, |
| 596 | 209× | None, |
| 597 | 209× | now, |
| 598 | 209× | "archived_ms IS NULL AND EXISTS (SELECT 1 FROM project_columns c WHERE c.id = project_cards.column_id \ |
| 599 | 209× | AND c.archive_after_days >= 0 AND project_cards.moved_ms < $1 - c.archive_after_days * $2)", |
| 600 | 209× | &[now, DAY_MS], |
| 601 | 209× | ) |
| 602 | 209× | .await?; |
| 603 | 209× | let set = sqlx::query( |
| 604 | 209× | "UPDATE project_cards SET archived_ms = $1 WHERE archived_ms IS NULL AND EXISTS \ |
| 605 | 209× | (SELECT 1 FROM project_columns c WHERE c.id = project_cards.column_id AND c.archive_after_days >= 0 \ |
| 606 | 209× | AND project_cards.moved_ms < $1 - c.archive_after_days * $2)", |
| 607 | 209× | ) |
| 608 | 209× | .bind(now) |
| 609 | 209× | .bind(DAY_MS) |
| 610 | 209× | .execute(pool) |
| 611 | 209× | .await?; |
| 612 | 209× | log_moves(pool, None, now, FINISHED_DUE, &[now - FINISHED_KEPT_DAYS * DAY_MS]).await?; |
| 613 | 209× | let finished = sqlx::query(&format!("UPDATE project_cards SET archived_ms = $2 WHERE {FINISHED_DUE}")) |
| 614 | 209× | .bind(now - FINISHED_KEPT_DAYS * DAY_MS) |
| 615 | 209× | .bind(now) |
| 616 | 209× | .execute(pool) |
| 617 | 209× | .await?; |
| 618 | 209× | Ok(set.rows_affected() + finished.rows_affected()) |
| 619 | 209× | } |
| 620 | |
|
| 621 | |
|
| 622 | 0× | pub async fn shift_card(pool: &Pool, project_id: i64, card_id: i64, by: i64) -> sqlx::Result<()> { |
| 623 | 0× | let Some(card): Option<Card> = sqlx::query_as("SELECT * FROM project_cards WHERE id = $1 AND project_id = $2") |
| 624 | 0× | .bind(card_id) |
| 625 | 0× | .bind(project_id) |
| 626 | 0× | .fetch_optional(pool) |
| 627 | 0× | .await? |
| 628 | | else { |
| 629 | 0× | return Ok(()); |
| 630 | | }; |
| 631 | 0× | let col: Vec<Card> = sqlx::query_as("SELECT * FROM project_cards WHERE column_id = $1 ORDER BY position, id") |
| 632 | 0× | .bind(card.column_id) |
| 633 | 0× | .fetch_all(pool) |
| 634 | 0× | .await?; |
| 635 | 0× | let Some(i) = col.iter().position(|c| c.id == card_id) else { return Ok(()) }; |
| 636 | 0× | let j = i as i64 + by; |
| 637 | 0× | if j < 0 || j as usize >= col.len() { |
| 638 | 0× | return Ok(()); |
| 639 | 0× | } |
| 640 | 0× | let mut ids: Vec<i64> = col.iter().map(|c| c.id).collect(); |
| 641 | 0× | ids.swap(i, j as usize); |
| 642 | 0× | for (pos, id) in ids.iter().enumerate() { |
| 643 | 0× | sqlx::query("UPDATE project_cards SET position = $1 WHERE id = $2").bind(pos as i64).bind(id).execute(pool).await?; |
| 644 | | } |
| 645 | 0× | touch(pool, project_id).await |
| 646 | 0× | } |
| 647 | |
|
| 648 | 3× | pub async fn remove_card(pool: &Pool, project_id: i64, card_id: i64) -> sqlx::Result<()> { |
| 649 | 3× | log_moves(pool, None, now_ms(), "id = $1 AND project_id = $2 AND archived_ms IS NULL", &[card_id, project_id]).await?; |
| 650 | 3× | sqlx::query("DELETE FROM project_cards WHERE id = $1 AND project_id = $2").bind(card_id).bind(project_id).execute(pool).await?; |
| 651 | 3× | touch(pool, project_id).await |
| 652 | 3× | } |
| 653 | |
|
| 654 | |
|
| 655 | |
|
| 656 | 2× | pub async fn set_takes_finished(pool: &Pool, project_id: i64, column_id: Option<i64>) -> sqlx::Result<()> { |
| 657 | 2× | let mut tx = super::begin_write(pool).await?; |
| 658 | 2× | sqlx::query("UPDATE project_columns SET takes_finished = FALSE WHERE project_id = $1").bind(project_id).execute(&mut *tx).await?; |
| 659 | 2× | if let Some(c) = column_id { |
| 660 | 1× | sqlx::query("UPDATE project_columns SET takes_finished = TRUE WHERE id = $1 AND project_id = $2") |
| 661 | 1× | .bind(c) |
| 662 | 1× | .bind(project_id) |
| 663 | 1× | .execute(&mut *tx) |
| 664 | 1× | .await?; |
| 665 | 1× | } |
| 666 | 2× | tx.commit().await?; |
| 667 | 2× | touch(pool, project_id).await |
| 668 | 2× | } |
| 669 | |
|
| 670 | |
|
| 671 | |
|
| 672 | |
|
| 673 | 37× | pub async fn finished(pool: &Pool, repo_id: i64, number: i64) -> sqlx::Result<()> { |
| 674 | 37× | let cards: Vec<(i64, i64, i64)> = sqlx::query_as( |
| 675 | 37× | "SELECT c.id, c.project_id, c.column_id FROM project_cards c |
| 676 | 37× | WHERE c.repo_id = $1 AND c.number = $2 AND c.kind <> 'note' AND c.archived_ms IS NULL", |
| 677 | 37× | ) |
| 678 | 37× | .bind(repo_id) |
| 679 | 37× | .bind(number) |
| 680 | 37× | .fetch_all(pool) |
| 681 | 37× | .await?; |
| 682 | 37× | for (card, project, column) in cards { |
| 683 | 3× | let to: Option<i64> = |
| 684 | 3× | sqlx::query_scalar("SELECT id FROM project_columns WHERE project_id = $1 AND takes_finished ORDER BY position LIMIT 1") |
| 685 | 3× | .bind(project) |
| 686 | 3× | .fetch_optional(pool) |
| 687 | 3× | .await?; |
| 688 | 3× | if let Some(to) = to.filter(|to| *to != column) { |
| 689 | 2× | move_card(pool, project, card, to).await?; |
| 690 | 1× | } |
| 691 | | } |
| 692 | 37× | Ok(()) |
| 693 | 37× | } |
| 694 | |
|
| 695 | 106× | pub async fn placements(pool: &Pool, repo_id: i64, number: i64) -> sqlx::Result<Vec<(Project, String)>> { |
| 696 | 106× | let rows: Vec<(i64, String, Option<i64>)> = sqlx::query_as( |
| 697 | 106× | "SELECT c.project_id, col.name, c.archived_ms FROM project_cards c JOIN project_columns col ON col.id = c.column_id WHERE c.repo_id = $1 AND c.number = $2 AND c.kind <> 'note'", |
| 698 | 106× | ) |
| 699 | 106× | .bind(repo_id) |
| 700 | 106× | .bind(number) |
| 701 | 106× | .fetch_all(pool) |
| 702 | 106× | .await?; |
| 703 | 106× | let mut out = Vec::new(); |
| 704 | 106× | for (pid, col, archived) in rows { |
| 705 | 5× | let col = if archived.is_some() { format!("{col}, archived") } else { col }; |
| 706 | 5× | if let Some(p) = sqlx::query_as::<_, Project>("SELECT * FROM projects WHERE id = $1").bind(pid).fetch_optional(pool).await? { |
| 707 | 5× | out.push((p, col)); |
| 708 | 5× | } |
| 709 | | } |
| 710 | 106× | Ok(out) |
| 711 | 106× | } |
| 712 | |
|
| 713 | |
|
| 714 | | #[derive(Clone, Debug, FromRow)] |
| 715 | | pub struct View { |
| 716 | | pub id: i64, |
| 717 | | pub project_id: i64, |
| 718 | | pub name: String, |
| 719 | | |
| 720 | | pub layout: String, |
| 721 | | pub q: String, |
| 722 | | |
| 723 | | |
| 724 | | pub lane: String, |
| 725 | | |
| 726 | | |
| 727 | | pub sort: String, |
| 728 | | pub position: i64, |
| 729 | | pub created_ms: i64, |
| 730 | | } |
| 731 | |
|
| 732 | 74× | pub async fn views(pool: &Pool, project_id: i64) -> sqlx::Result<Vec<View>> { |
| 733 | 74× | sqlx::query_as("SELECT * FROM project_views WHERE project_id = $1 ORDER BY position, id").bind(project_id).fetch_all(pool).await |
| 734 | 74× | } |
| 735 | |
|
| 736 | |
|
| 737 | 1× | pub async fn save_view(pool: &Pool, project_id: i64, name: &str, layout: &str, q: &str, lane: &str, sort: &str) -> sqlx::Result<View> { |
| 738 | 1× | let mut tx = super::begin_write(pool).await?; |
| 739 | 1× | let existing: Option<i64> = sqlx::query_scalar("SELECT id FROM project_views WHERE project_id = $1 AND name = $2") |
| 740 | 1× | .bind(project_id) |
| 741 | 1× | .bind(name) |
| 742 | 1× | .fetch_optional(&mut *tx) |
| 743 | 1× | .await?; |
| 744 | 1× | let v: View = match existing { |
| 745 | 0× | Some(id) => { |
| 746 | 0× | sqlx::query_as("UPDATE project_views SET layout = $1, q = $2, lane = $3, sort = $4 WHERE id = $5 RETURNING *") |
| 747 | 0× | .bind(layout) |
| 748 | 0× | .bind(q) |
| 749 | 0× | .bind(lane) |
| 750 | 0× | .bind(sort) |
| 751 | 0× | .bind(id) |
| 752 | 0× | .fetch_one(&mut *tx) |
| 753 | 0× | .await? |
| 754 | | } |
| 755 | | None => { |
| 756 | 1× | let pos: i64 = sqlx::query_scalar("SELECT COALESCE(MAX(position), -1) + 1 FROM project_views WHERE project_id = $1") |
| 757 | 1× | .bind(project_id) |
| 758 | 1× | .fetch_one(&mut *tx) |
| 759 | 1× | .await?; |
| 760 | 1× | sqlx::query_as( |
| 761 | 1× | "INSERT INTO project_views (project_id, name, layout, q, lane, sort, position, created_ms) \ |
| 762 | 1× | VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING *", |
| 763 | 1× | ) |
| 764 | 1× | .bind(project_id) |
| 765 | 1× | .bind(name) |
| 766 | 1× | .bind(layout) |
| 767 | 1× | .bind(q) |
| 768 | 1× | .bind(lane) |
| 769 | 1× | .bind(sort) |
| 770 | 1× | .bind(pos) |
| 771 | 1× | .bind(now_ms()) |
| 772 | 1× | .fetch_one(&mut *tx) |
| 773 | 1× | .await? |
| 774 | | } |
| 775 | | }; |
| 776 | 1× | tx.commit().await?; |
| 777 | 1× | touch(pool, project_id).await?; |
| 778 | 1× | Ok(v) |
| 779 | 1× | } |
| 780 | |
|
| 781 | 1× | pub async fn delete_view(pool: &Pool, project_id: i64, view_id: i64) -> sqlx::Result<bool> { |
| 782 | 1× | let r = sqlx::query("DELETE FROM project_views WHERE id = $1 AND project_id = $2").bind(view_id).bind(project_id).execute(pool).await?; |
| 783 | 1× | touch(pool, project_id).await?; |
| 784 | 1× | Ok(r.rows_affected() == 1) |
| 785 | 1× | } |
| 786 | |
|
| 787 | |
|
| 788 | 2× | pub async fn set_wip_limit(pool: &Pool, project_id: i64, column_id: i64, limit: Option<i64>) -> sqlx::Result<()> { |
| 789 | 2× | sqlx::query("UPDATE project_columns SET wip_limit = $1 WHERE id = $2 AND project_id = $3") |
| 790 | 2× | .bind(limit) |
| 791 | 2× | .bind(column_id) |
| 792 | 2× | .bind(project_id) |
| 793 | 2× | .execute(pool) |
| 794 | 2× | .await?; |
| 795 | 2× | touch(pool, project_id).await |
| 796 | 2× | } |
| 797 | |
|
| 798 | |
|
| 799 | |
|
| 800 | 3× | pub async fn link_repo(pool: &Pool, project_id: i64, repo_id: i64) -> sqlx::Result<()> { |
| 801 | 3× | sqlx::query("INSERT INTO project_repos (project_id, repo_id) VALUES ($1, $2) ON CONFLICT DO NOTHING") |
| 802 | 3× | .bind(project_id) |
| 803 | 3× | .bind(repo_id) |
| 804 | 3× | .execute(pool) |
| 805 | 3× | .await?; |
| 806 | 3× | Ok(()) |
| 807 | 3× | } |
| 808 | |
|
| 809 | |
|
| 810 | 119× | pub async fn boards_of_repo(pool: &Pool, repo_id: i64) -> sqlx::Result<Vec<i64>> { |
| 811 | 119× | sqlx::query_scalar("SELECT project_id FROM project_repos WHERE repo_id = $1 ORDER BY project_id").bind(repo_id).fetch_all(pool).await |
| 812 | 119× | } |
| 813 | |
|
| 814 | |
|
| 815 | |
|
| 816 | |
|
| 817 | 119× | pub async fn opened(pool: &Pool, repo_id: i64, kind: &str, number: i64, by: &str) -> sqlx::Result<()> { |
| 818 | 119× | for project_id in boards_of_repo(pool, repo_id).await? { |
| 819 | 2× | let closed: Option<bool> = |
| 820 | 2× | sqlx::query_scalar("SELECT closed FROM projects WHERE id = $1").bind(project_id).fetch_optional(pool).await?; |
| 821 | 2× | if closed != Some(false) { |
| 822 | 0× | continue; |
| 823 | 2× | } |
| 824 | 2× | if let Some(first) = columns(pool, project_id).await?.first() { |
| 825 | 2× | add_card( |
| 826 | 2× | pool, |
| 827 | 2× | project_id, |
| 828 | 2× | NewCard { column_id: first.id, kind, repo_id: Some(repo_id), number: Some(number), note: "", added_by: by }, |
| 829 | 2× | ) |
| 830 | 2× | .await?; |
| 831 | 0× | } |
| 832 | | } |
| 833 | 119× | Ok(()) |
| 834 | 119× | } |