Loggest thy stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.3 KiB

  1. -- name: GetItem :one
  2. SELECT i.*, pr.project_id FROM item i
  3. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  4. WHERE i.id = ?;
  5. -- name: ListItemsByProject :many
  6. SELECT i.*, pr.project_id FROM item i
  7. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  8. WHERE pr.project_id = ?;
  9. -- name: ListItemsAcquiredBetween :many
  10. SELECT i.*, pr.project_id FROM item i
  11. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  12. WHERE i.acquired_time >= ?
  13. AND i.acquired_time < ?
  14. AND i.scope_id = ?;
  15. -- name: ListItemsScheduledBetween :many
  16. SELECT i.*, pr.project_id FROM item i
  17. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  18. WHERE i.scheduled_date >= ?
  19. AND i.scheduled_date < ?
  20. AND i.scope_id = ?;
  21. -- name: ListItemsCreatedBetween :many
  22. SELECT i.*, pr.project_id FROM item i
  23. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  24. WHERE i.created_time >= ?
  25. AND i.created_time < ?
  26. AND i.scope_id = ?;
  27. -- name: ListItemsLooseBetween :many
  28. SELECT i.*, pr.project_id FROM item i
  29. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  30. WHERE i.created_time >= ?
  31. AND i.created_time < ?
  32. AND i.scope_id = ?
  33. AND i.scheduled_date IS NULL
  34. AND i.acquired_time IS NULL;
  35. -- name: ListItemsScheduledBetweenNoScope :many
  36. SELECT i.*, pr.project_id FROM item i
  37. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  38. WHERE i.scheduled_date >= ?
  39. AND i.scheduled_date < ?;
  40. -- name: ListItemsCreatedBetweenNoScope :many
  41. SELECT i.*, pr.project_id FROM item i
  42. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  43. WHERE i.created_time >= ?
  44. AND i.created_time < ?;
  45. -- name: ListItemsLooseBetweenNoScope :many
  46. SELECT i.*, pr.project_id FROM item i
  47. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  48. WHERE i.created_time >= ?
  49. AND i.created_time < ?
  50. AND i.scheduled_date IS NULL
  51. AND i.acquired_time IS NULL;
  52. -- name: GetItemStatProgressBetween :one
  53. SELECT s.id, s.name, s.weight, SUM(isp.acquired), SUM(isp.required) FROM item i
  54. LEFT JOIN item_stat_progress isp on i.id = isp.item_id
  55. LEFT JOIN stat s on isp.stat_id = s.id
  56. WHERE i.acquired_time >= ?
  57. AND i.acquired_time < ?
  58. AND i.scope_id = ?
  59. GROUP BY stat_id;
  60. -- name: ListItemStatProgress :many
  61. SELECT isp.required, isp.acquired, s.id, s.name, s.weight FROM item_stat_progress isp
  62. LEFT JOIN stat s ON s.id = isp.stat_id
  63. WHERE item_id = ?;
  64. -- name: ListItemStatProgressMulti :many
  65. SELECT isp.item_id, isp.required, isp.acquired, s.id, s.name, s.weight FROM item_stat_progress isp
  66. LEFT JOIN stat s ON s.id = isp.stat_id
  67. WHERE item_id IN (?, ?, ?, ?, ?, ?, ?, ?);
  68. -- name: InsertItem :execresult
  69. INSERT INTO item (scope_id, project_requirement_id, name, description, created_time, created_user_id, acquired_time, scheduled_date)
  70. VALUES (?, ?, ?, ?, ?, ?, ?, ?);
  71. -- name: UpdateItem :exec
  72. UPDATE item
  73. SET project_requirement_id = ?,
  74. name = ?,
  75. description = ?,
  76. acquired_time = ?,
  77. scheduled_date = ?,
  78. created_user_id = ?
  79. WHERE id = ?;
  80. -- name: DeleteItem :exec
  81. DELETE FROM item WHERE id = ?;
  82. -- name: ReplaceItemStatProgress :exec
  83. REPLACE INTO item_stat_progress (item_id, stat_id, acquired, required)
  84. VALUES (?, ?, ?, ?);
  85. -- name: DeleteItemStatProgress :exec
  86. DELETE FROM item_stat_progress WHERE item_id = ? AND stat_id = ?;
  87. -- name: ClearItemStatProgress :exec
  88. DELETE FROM item_stat_progress WHERE item_id = ?;