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.

835 lines
22 KiB

3 years ago
3 years ago
  1. // Code generated by sqlc. DO NOT EDIT.
  2. // versions:
  3. // sqlc v1.13.0
  4. // source: item.sql
  5. package mysqlcore
  6. import (
  7. "context"
  8. "database/sql"
  9. "time"
  10. "git.aiterp.net/stufflog3/stufflog3-api/internal/sqltypes"
  11. )
  12. const cLearItemStatProgressByStat = `-- name: CLearItemStatProgressByStat :exec
  13. DELETE FROM item_stat_progress WHERE stat_id = ?
  14. `
  15. func (q *Queries) CLearItemStatProgressByStat(ctx context.Context, statID int) error {
  16. _, err := q.exec(ctx, q.cLearItemStatProgressByStatStmt, cLearItemStatProgressByStat, statID)
  17. return err
  18. }
  19. const clearItemProjectRequirement = `-- name: ClearItemProjectRequirement :exec
  20. UPDATE item SET project_requirement_id = NULL WHERE project_requirement_id = ?
  21. `
  22. func (q *Queries) ClearItemProjectRequirement(ctx context.Context, projectRequirementID sql.NullInt32) error {
  23. _, err := q.exec(ctx, q.clearItemProjectRequirementStmt, clearItemProjectRequirement, projectRequirementID)
  24. return err
  25. }
  26. const clearItemProjectRequirementByProjectID = `-- name: ClearItemProjectRequirementByProjectID :exec
  27. UPDATE item i
  28. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  29. SET i.project_requirement_id = NULL
  30. WHERE pr.project_id = ?
  31. `
  32. func (q *Queries) ClearItemProjectRequirementByProjectID(ctx context.Context, projectID int) error {
  33. _, err := q.exec(ctx, q.clearItemProjectRequirementByProjectIDStmt, clearItemProjectRequirementByProjectID, projectID)
  34. return err
  35. }
  36. const clearItemStatProgress = `-- name: ClearItemStatProgress :exec
  37. DELETE FROM item_stat_progress WHERE item_id = ?
  38. `
  39. func (q *Queries) ClearItemStatProgress(ctx context.Context, itemID int) error {
  40. _, err := q.exec(ctx, q.clearItemStatProgressStmt, clearItemStatProgress, itemID)
  41. return err
  42. }
  43. const deleteItem = `-- name: DeleteItem :exec
  44. DELETE FROM item WHERE id = ?
  45. `
  46. func (q *Queries) DeleteItem(ctx context.Context, id int) error {
  47. _, err := q.exec(ctx, q.deleteItemStmt, deleteItem, id)
  48. return err
  49. }
  50. const deleteItemForRequirement = `-- name: DeleteItemForRequirement :exec
  51. DELETE FROM item WHERE project_requirement_id = ?
  52. `
  53. func (q *Queries) DeleteItemForRequirement(ctx context.Context, projectRequirementID sql.NullInt32) error {
  54. _, err := q.exec(ctx, q.deleteItemForRequirementStmt, deleteItemForRequirement, projectRequirementID)
  55. return err
  56. }
  57. const deleteItemStatProgress = `-- name: DeleteItemStatProgress :exec
  58. DELETE FROM item_stat_progress WHERE item_id = ? AND stat_id = ?
  59. `
  60. type DeleteItemStatProgressParams struct {
  61. ItemID int
  62. StatID int
  63. }
  64. func (q *Queries) DeleteItemStatProgress(ctx context.Context, arg DeleteItemStatProgressParams) error {
  65. _, err := q.exec(ctx, q.deleteItemStatProgressStmt, deleteItemStatProgress, arg.ItemID, arg.StatID)
  66. return err
  67. }
  68. const getItem = `-- name: GetItem :one
  69. SELECT i.id, i.scope_id, i.project_requirement_id, i.name, i.description, i.created_time, i.created_user_id, i.acquired_time, i.scheduled_date, pr.project_id FROM item i
  70. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  71. WHERE i.id = ?
  72. `
  73. type GetItemRow struct {
  74. ID int
  75. ScopeID int
  76. ProjectRequirementID sql.NullInt32
  77. Name string
  78. Description string
  79. CreatedTime time.Time
  80. CreatedUserID string
  81. AcquiredTime sql.NullTime
  82. ScheduledDate sqltypes.NullDate
  83. ProjectID sql.NullInt32
  84. }
  85. func (q *Queries) GetItem(ctx context.Context, id int) (GetItemRow, error) {
  86. row := q.queryRow(ctx, q.getItemStmt, getItem, id)
  87. var i GetItemRow
  88. err := row.Scan(
  89. &i.ID,
  90. &i.ScopeID,
  91. &i.ProjectRequirementID,
  92. &i.Name,
  93. &i.Description,
  94. &i.CreatedTime,
  95. &i.CreatedUserID,
  96. &i.AcquiredTime,
  97. &i.ScheduledDate,
  98. &i.ProjectID,
  99. )
  100. return i, err
  101. }
  102. const getItemStatProgressBetween = `-- name: GetItemStatProgressBetween :one
  103. SELECT s.id, s.name, s.weight, SUM(isp.acquired), SUM(isp.required) FROM item i
  104. LEFT JOIN item_stat_progress isp on i.id = isp.item_id
  105. LEFT JOIN stat s on isp.stat_id = s.id
  106. WHERE i.acquired_time >= ?
  107. AND i.acquired_time < ?
  108. AND i.scope_id = ?
  109. GROUP BY stat_id
  110. `
  111. type GetItemStatProgressBetweenParams struct {
  112. AcquiredTime sql.NullTime
  113. AcquiredTime_2 sql.NullTime
  114. ScopeID int
  115. }
  116. type GetItemStatProgressBetweenRow struct {
  117. ID sql.NullInt32
  118. Name sql.NullString
  119. Weight float64
  120. Sum interface{}
  121. Sum_2 interface{}
  122. }
  123. func (q *Queries) GetItemStatProgressBetween(ctx context.Context, arg GetItemStatProgressBetweenParams) (GetItemStatProgressBetweenRow, error) {
  124. row := q.queryRow(ctx, q.getItemStatProgressBetweenStmt, getItemStatProgressBetween, arg.AcquiredTime, arg.AcquiredTime_2, arg.ScopeID)
  125. var i GetItemStatProgressBetweenRow
  126. err := row.Scan(
  127. &i.ID,
  128. &i.Name,
  129. &i.Weight,
  130. &i.Sum,
  131. &i.Sum_2,
  132. )
  133. return i, err
  134. }
  135. const insertItem = `-- name: InsertItem :execresult
  136. INSERT INTO item (scope_id, project_requirement_id, name, description, created_time, created_user_id, acquired_time, scheduled_date)
  137. VALUES (?, ?, ?, ?, ?, ?, ?, ?)
  138. `
  139. type InsertItemParams struct {
  140. ScopeID int
  141. ProjectRequirementID sql.NullInt32
  142. Name string
  143. Description string
  144. CreatedTime time.Time
  145. CreatedUserID string
  146. AcquiredTime sql.NullTime
  147. ScheduledDate sqltypes.NullDate
  148. }
  149. func (q *Queries) InsertItem(ctx context.Context, arg InsertItemParams) (sql.Result, error) {
  150. return q.exec(ctx, q.insertItemStmt, insertItem,
  151. arg.ScopeID,
  152. arg.ProjectRequirementID,
  153. arg.Name,
  154. arg.Description,
  155. arg.CreatedTime,
  156. arg.CreatedUserID,
  157. arg.AcquiredTime,
  158. arg.ScheduledDate,
  159. )
  160. }
  161. const listItemStatProgress = `-- name: ListItemStatProgress :many
  162. SELECT isp.required, isp.acquired, s.id, s.name, s.weight FROM item_stat_progress isp
  163. LEFT JOIN stat s ON s.id = isp.stat_id
  164. WHERE item_id = ?
  165. `
  166. type ListItemStatProgressRow struct {
  167. Required int
  168. Acquired int
  169. ID sql.NullInt32
  170. Name sql.NullString
  171. Weight float64
  172. }
  173. func (q *Queries) ListItemStatProgress(ctx context.Context, itemID int) ([]ListItemStatProgressRow, error) {
  174. rows, err := q.query(ctx, q.listItemStatProgressStmt, listItemStatProgress, itemID)
  175. if err != nil {
  176. return nil, err
  177. }
  178. defer rows.Close()
  179. items := []ListItemStatProgressRow{}
  180. for rows.Next() {
  181. var i ListItemStatProgressRow
  182. if err := rows.Scan(
  183. &i.Required,
  184. &i.Acquired,
  185. &i.ID,
  186. &i.Name,
  187. &i.Weight,
  188. ); err != nil {
  189. return nil, err
  190. }
  191. items = append(items, i)
  192. }
  193. if err := rows.Close(); err != nil {
  194. return nil, err
  195. }
  196. if err := rows.Err(); err != nil {
  197. return nil, err
  198. }
  199. return items, nil
  200. }
  201. const listItemStatProgressMulti = `-- name: ListItemStatProgressMulti :many
  202. SELECT isp.item_id, isp.required, isp.acquired, s.id, s.name, s.weight FROM item_stat_progress isp
  203. LEFT JOIN stat s ON s.id = isp.stat_id
  204. WHERE item_id IN (?, ?, ?, ?, ?, ?, ?, ?)
  205. `
  206. type ListItemStatProgressMultiParams struct {
  207. ItemID int
  208. ItemID_2 int
  209. ItemID_3 int
  210. ItemID_4 int
  211. ItemID_5 int
  212. ItemID_6 int
  213. ItemID_7 int
  214. ItemID_8 int
  215. }
  216. type ListItemStatProgressMultiRow struct {
  217. ItemID int
  218. Required int
  219. Acquired int
  220. ID sql.NullInt32
  221. Name sql.NullString
  222. Weight float64
  223. }
  224. func (q *Queries) ListItemStatProgressMulti(ctx context.Context, arg ListItemStatProgressMultiParams) ([]ListItemStatProgressMultiRow, error) {
  225. rows, err := q.query(ctx, q.listItemStatProgressMultiStmt, listItemStatProgressMulti,
  226. arg.ItemID,
  227. arg.ItemID_2,
  228. arg.ItemID_3,
  229. arg.ItemID_4,
  230. arg.ItemID_5,
  231. arg.ItemID_6,
  232. arg.ItemID_7,
  233. arg.ItemID_8,
  234. )
  235. if err != nil {
  236. return nil, err
  237. }
  238. defer rows.Close()
  239. items := []ListItemStatProgressMultiRow{}
  240. for rows.Next() {
  241. var i ListItemStatProgressMultiRow
  242. if err := rows.Scan(
  243. &i.ItemID,
  244. &i.Required,
  245. &i.Acquired,
  246. &i.ID,
  247. &i.Name,
  248. &i.Weight,
  249. ); err != nil {
  250. return nil, err
  251. }
  252. items = append(items, i)
  253. }
  254. if err := rows.Close(); err != nil {
  255. return nil, err
  256. }
  257. if err := rows.Err(); err != nil {
  258. return nil, err
  259. }
  260. return items, nil
  261. }
  262. const listItemsAcquiredBetween = `-- name: ListItemsAcquiredBetween :many
  263. SELECT i.id, i.scope_id, i.project_requirement_id, i.name, i.description, i.created_time, i.created_user_id, i.acquired_time, i.scheduled_date, pr.project_id FROM item i
  264. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  265. WHERE i.acquired_time >= ?
  266. AND i.acquired_time <= ?
  267. AND i.scope_id = ?
  268. ORDER BY acquired_time DESC, created_time DESC
  269. `
  270. type ListItemsAcquiredBetweenParams struct {
  271. AcquiredTime sql.NullTime
  272. AcquiredTime_2 sql.NullTime
  273. ScopeID int
  274. }
  275. type ListItemsAcquiredBetweenRow struct {
  276. ID int
  277. ScopeID int
  278. ProjectRequirementID sql.NullInt32
  279. Name string
  280. Description string
  281. CreatedTime time.Time
  282. CreatedUserID string
  283. AcquiredTime sql.NullTime
  284. ScheduledDate sqltypes.NullDate
  285. ProjectID sql.NullInt32
  286. }
  287. func (q *Queries) ListItemsAcquiredBetween(ctx context.Context, arg ListItemsAcquiredBetweenParams) ([]ListItemsAcquiredBetweenRow, error) {
  288. rows, err := q.query(ctx, q.listItemsAcquiredBetweenStmt, listItemsAcquiredBetween, arg.AcquiredTime, arg.AcquiredTime_2, arg.ScopeID)
  289. if err != nil {
  290. return nil, err
  291. }
  292. defer rows.Close()
  293. items := []ListItemsAcquiredBetweenRow{}
  294. for rows.Next() {
  295. var i ListItemsAcquiredBetweenRow
  296. if err := rows.Scan(
  297. &i.ID,
  298. &i.ScopeID,
  299. &i.ProjectRequirementID,
  300. &i.Name,
  301. &i.Description,
  302. &i.CreatedTime,
  303. &i.CreatedUserID,
  304. &i.AcquiredTime,
  305. &i.ScheduledDate,
  306. &i.ProjectID,
  307. ); err != nil {
  308. return nil, err
  309. }
  310. items = append(items, i)
  311. }
  312. if err := rows.Close(); err != nil {
  313. return nil, err
  314. }
  315. if err := rows.Err(); err != nil {
  316. return nil, err
  317. }
  318. return items, nil
  319. }
  320. const listItemsByProject = `-- name: ListItemsByProject :many
  321. SELECT i.id, i.scope_id, i.project_requirement_id, i.name, i.description, i.created_time, i.created_user_id, i.acquired_time, i.scheduled_date, pr.project_id FROM item i
  322. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  323. WHERE pr.project_id = ?
  324. `
  325. type ListItemsByProjectRow struct {
  326. ID int
  327. ScopeID int
  328. ProjectRequirementID sql.NullInt32
  329. Name string
  330. Description string
  331. CreatedTime time.Time
  332. CreatedUserID string
  333. AcquiredTime sql.NullTime
  334. ScheduledDate sqltypes.NullDate
  335. ProjectID sql.NullInt32
  336. }
  337. func (q *Queries) ListItemsByProject(ctx context.Context, projectID int) ([]ListItemsByProjectRow, error) {
  338. rows, err := q.query(ctx, q.listItemsByProjectStmt, listItemsByProject, projectID)
  339. if err != nil {
  340. return nil, err
  341. }
  342. defer rows.Close()
  343. items := []ListItemsByProjectRow{}
  344. for rows.Next() {
  345. var i ListItemsByProjectRow
  346. if err := rows.Scan(
  347. &i.ID,
  348. &i.ScopeID,
  349. &i.ProjectRequirementID,
  350. &i.Name,
  351. &i.Description,
  352. &i.CreatedTime,
  353. &i.CreatedUserID,
  354. &i.AcquiredTime,
  355. &i.ScheduledDate,
  356. &i.ProjectID,
  357. ); err != nil {
  358. return nil, err
  359. }
  360. items = append(items, i)
  361. }
  362. if err := rows.Close(); err != nil {
  363. return nil, err
  364. }
  365. if err := rows.Err(); err != nil {
  366. return nil, err
  367. }
  368. return items, nil
  369. }
  370. const listItemsCreatedBetween = `-- name: ListItemsCreatedBetween :many
  371. SELECT i.id, i.scope_id, i.project_requirement_id, i.name, i.description, i.created_time, i.created_user_id, i.acquired_time, i.scheduled_date, pr.project_id FROM item i
  372. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  373. WHERE i.created_time >= ?
  374. AND i.created_time <= ?
  375. AND i.scope_id = ?
  376. ORDER BY created_time DESC
  377. `
  378. type ListItemsCreatedBetweenParams struct {
  379. CreatedTime time.Time
  380. CreatedTime_2 time.Time
  381. ScopeID int
  382. }
  383. type ListItemsCreatedBetweenRow struct {
  384. ID int
  385. ScopeID int
  386. ProjectRequirementID sql.NullInt32
  387. Name string
  388. Description string
  389. CreatedTime time.Time
  390. CreatedUserID string
  391. AcquiredTime sql.NullTime
  392. ScheduledDate sqltypes.NullDate
  393. ProjectID sql.NullInt32
  394. }
  395. func (q *Queries) ListItemsCreatedBetween(ctx context.Context, arg ListItemsCreatedBetweenParams) ([]ListItemsCreatedBetweenRow, error) {
  396. rows, err := q.query(ctx, q.listItemsCreatedBetweenStmt, listItemsCreatedBetween, arg.CreatedTime, arg.CreatedTime_2, arg.ScopeID)
  397. if err != nil {
  398. return nil, err
  399. }
  400. defer rows.Close()
  401. items := []ListItemsCreatedBetweenRow{}
  402. for rows.Next() {
  403. var i ListItemsCreatedBetweenRow
  404. if err := rows.Scan(
  405. &i.ID,
  406. &i.ScopeID,
  407. &i.ProjectRequirementID,
  408. &i.Name,
  409. &i.Description,
  410. &i.CreatedTime,
  411. &i.CreatedUserID,
  412. &i.AcquiredTime,
  413. &i.ScheduledDate,
  414. &i.ProjectID,
  415. ); err != nil {
  416. return nil, err
  417. }
  418. items = append(items, i)
  419. }
  420. if err := rows.Close(); err != nil {
  421. return nil, err
  422. }
  423. if err := rows.Err(); err != nil {
  424. return nil, err
  425. }
  426. return items, nil
  427. }
  428. const listItemsCreatedBetweenNoScope = `-- name: ListItemsCreatedBetweenNoScope :many
  429. SELECT i.id, i.scope_id, i.project_requirement_id, i.name, i.description, i.created_time, i.created_user_id, i.acquired_time, i.scheduled_date, pr.project_id FROM item i
  430. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  431. WHERE i.created_time >= ?
  432. AND i.created_time < ?
  433. `
  434. type ListItemsCreatedBetweenNoScopeParams struct {
  435. CreatedTime time.Time
  436. CreatedTime_2 time.Time
  437. }
  438. type ListItemsCreatedBetweenNoScopeRow struct {
  439. ID int
  440. ScopeID int
  441. ProjectRequirementID sql.NullInt32
  442. Name string
  443. Description string
  444. CreatedTime time.Time
  445. CreatedUserID string
  446. AcquiredTime sql.NullTime
  447. ScheduledDate sqltypes.NullDate
  448. ProjectID sql.NullInt32
  449. }
  450. func (q *Queries) ListItemsCreatedBetweenNoScope(ctx context.Context, arg ListItemsCreatedBetweenNoScopeParams) ([]ListItemsCreatedBetweenNoScopeRow, error) {
  451. rows, err := q.query(ctx, q.listItemsCreatedBetweenNoScopeStmt, listItemsCreatedBetweenNoScope, arg.CreatedTime, arg.CreatedTime_2)
  452. if err != nil {
  453. return nil, err
  454. }
  455. defer rows.Close()
  456. items := []ListItemsCreatedBetweenNoScopeRow{}
  457. for rows.Next() {
  458. var i ListItemsCreatedBetweenNoScopeRow
  459. if err := rows.Scan(
  460. &i.ID,
  461. &i.ScopeID,
  462. &i.ProjectRequirementID,
  463. &i.Name,
  464. &i.Description,
  465. &i.CreatedTime,
  466. &i.CreatedUserID,
  467. &i.AcquiredTime,
  468. &i.ScheduledDate,
  469. &i.ProjectID,
  470. ); err != nil {
  471. return nil, err
  472. }
  473. items = append(items, i)
  474. }
  475. if err := rows.Close(); err != nil {
  476. return nil, err
  477. }
  478. if err := rows.Err(); err != nil {
  479. return nil, err
  480. }
  481. return items, nil
  482. }
  483. const listItemsLooseBetween = `-- name: ListItemsLooseBetween :many
  484. SELECT i.id, i.scope_id, i.project_requirement_id, i.name, i.description, i.created_time, i.created_user_id, i.acquired_time, i.scheduled_date, pr.project_id FROM item i
  485. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  486. WHERE i.created_time >= ?
  487. AND i.created_time <= ?
  488. AND i.scope_id = ?
  489. AND i.scheduled_date IS NULL
  490. AND i.acquired_time IS NULL
  491. AND i.project_requirement_id IS NULL
  492. ORDER BY created_time DESC
  493. `
  494. type ListItemsLooseBetweenParams struct {
  495. CreatedTime time.Time
  496. CreatedTime_2 time.Time
  497. ScopeID int
  498. }
  499. type ListItemsLooseBetweenRow struct {
  500. ID int
  501. ScopeID int
  502. ProjectRequirementID sql.NullInt32
  503. Name string
  504. Description string
  505. CreatedTime time.Time
  506. CreatedUserID string
  507. AcquiredTime sql.NullTime
  508. ScheduledDate sqltypes.NullDate
  509. ProjectID sql.NullInt32
  510. }
  511. func (q *Queries) ListItemsLooseBetween(ctx context.Context, arg ListItemsLooseBetweenParams) ([]ListItemsLooseBetweenRow, error) {
  512. rows, err := q.query(ctx, q.listItemsLooseBetweenStmt, listItemsLooseBetween, arg.CreatedTime, arg.CreatedTime_2, arg.ScopeID)
  513. if err != nil {
  514. return nil, err
  515. }
  516. defer rows.Close()
  517. items := []ListItemsLooseBetweenRow{}
  518. for rows.Next() {
  519. var i ListItemsLooseBetweenRow
  520. if err := rows.Scan(
  521. &i.ID,
  522. &i.ScopeID,
  523. &i.ProjectRequirementID,
  524. &i.Name,
  525. &i.Description,
  526. &i.CreatedTime,
  527. &i.CreatedUserID,
  528. &i.AcquiredTime,
  529. &i.ScheduledDate,
  530. &i.ProjectID,
  531. ); err != nil {
  532. return nil, err
  533. }
  534. items = append(items, i)
  535. }
  536. if err := rows.Close(); err != nil {
  537. return nil, err
  538. }
  539. if err := rows.Err(); err != nil {
  540. return nil, err
  541. }
  542. return items, nil
  543. }
  544. const listItemsLooseBetweenNoScope = `-- name: ListItemsLooseBetweenNoScope :many
  545. SELECT i.id, i.scope_id, i.project_requirement_id, i.name, i.description, i.created_time, i.created_user_id, i.acquired_time, i.scheduled_date, pr.project_id FROM item i
  546. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  547. WHERE i.created_time >= ?
  548. AND i.created_time < ?
  549. AND i.scheduled_date IS NULL
  550. AND i.acquired_time IS NULL
  551. `
  552. type ListItemsLooseBetweenNoScopeParams struct {
  553. CreatedTime time.Time
  554. CreatedTime_2 time.Time
  555. }
  556. type ListItemsLooseBetweenNoScopeRow struct {
  557. ID int
  558. ScopeID int
  559. ProjectRequirementID sql.NullInt32
  560. Name string
  561. Description string
  562. CreatedTime time.Time
  563. CreatedUserID string
  564. AcquiredTime sql.NullTime
  565. ScheduledDate sqltypes.NullDate
  566. ProjectID sql.NullInt32
  567. }
  568. func (q *Queries) ListItemsLooseBetweenNoScope(ctx context.Context, arg ListItemsLooseBetweenNoScopeParams) ([]ListItemsLooseBetweenNoScopeRow, error) {
  569. rows, err := q.query(ctx, q.listItemsLooseBetweenNoScopeStmt, listItemsLooseBetweenNoScope, arg.CreatedTime, arg.CreatedTime_2)
  570. if err != nil {
  571. return nil, err
  572. }
  573. defer rows.Close()
  574. items := []ListItemsLooseBetweenNoScopeRow{}
  575. for rows.Next() {
  576. var i ListItemsLooseBetweenNoScopeRow
  577. if err := rows.Scan(
  578. &i.ID,
  579. &i.ScopeID,
  580. &i.ProjectRequirementID,
  581. &i.Name,
  582. &i.Description,
  583. &i.CreatedTime,
  584. &i.CreatedUserID,
  585. &i.AcquiredTime,
  586. &i.ScheduledDate,
  587. &i.ProjectID,
  588. ); err != nil {
  589. return nil, err
  590. }
  591. items = append(items, i)
  592. }
  593. if err := rows.Close(); err != nil {
  594. return nil, err
  595. }
  596. if err := rows.Err(); err != nil {
  597. return nil, err
  598. }
  599. return items, nil
  600. }
  601. const listItemsScheduledBetween = `-- name: ListItemsScheduledBetween :many
  602. SELECT i.id, i.scope_id, i.project_requirement_id, i.name, i.description, i.created_time, i.created_user_id, i.acquired_time, i.scheduled_date, pr.project_id FROM item i
  603. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  604. WHERE i.scheduled_date >= ?
  605. AND i.scheduled_date <= ?
  606. AND i.scope_id = ?
  607. ORDER BY scheduled_date, created_time
  608. `
  609. type ListItemsScheduledBetweenParams struct {
  610. ScheduledDate sqltypes.NullDate
  611. ScheduledDate_2 sqltypes.NullDate
  612. ScopeID int
  613. }
  614. type ListItemsScheduledBetweenRow struct {
  615. ID int
  616. ScopeID int
  617. ProjectRequirementID sql.NullInt32
  618. Name string
  619. Description string
  620. CreatedTime time.Time
  621. CreatedUserID string
  622. AcquiredTime sql.NullTime
  623. ScheduledDate sqltypes.NullDate
  624. ProjectID sql.NullInt32
  625. }
  626. func (q *Queries) ListItemsScheduledBetween(ctx context.Context, arg ListItemsScheduledBetweenParams) ([]ListItemsScheduledBetweenRow, error) {
  627. rows, err := q.query(ctx, q.listItemsScheduledBetweenStmt, listItemsScheduledBetween, arg.ScheduledDate, arg.ScheduledDate_2, arg.ScopeID)
  628. if err != nil {
  629. return nil, err
  630. }
  631. defer rows.Close()
  632. items := []ListItemsScheduledBetweenRow{}
  633. for rows.Next() {
  634. var i ListItemsScheduledBetweenRow
  635. if err := rows.Scan(
  636. &i.ID,
  637. &i.ScopeID,
  638. &i.ProjectRequirementID,
  639. &i.Name,
  640. &i.Description,
  641. &i.CreatedTime,
  642. &i.CreatedUserID,
  643. &i.AcquiredTime,
  644. &i.ScheduledDate,
  645. &i.ProjectID,
  646. ); err != nil {
  647. return nil, err
  648. }
  649. items = append(items, i)
  650. }
  651. if err := rows.Close(); err != nil {
  652. return nil, err
  653. }
  654. if err := rows.Err(); err != nil {
  655. return nil, err
  656. }
  657. return items, nil
  658. }
  659. const listItemsScheduledBetweenNoScope = `-- name: ListItemsScheduledBetweenNoScope :many
  660. SELECT i.id, i.scope_id, i.project_requirement_id, i.name, i.description, i.created_time, i.created_user_id, i.acquired_time, i.scheduled_date, pr.project_id FROM item i
  661. LEFT JOIN project_requirement pr ON pr.id = i.project_requirement_id
  662. WHERE i.scheduled_date >= ?
  663. AND i.scheduled_date < ?
  664. `
  665. type ListItemsScheduledBetweenNoScopeParams struct {
  666. ScheduledDate sqltypes.NullDate
  667. ScheduledDate_2 sqltypes.NullDate
  668. }
  669. type ListItemsScheduledBetweenNoScopeRow struct {
  670. ID int
  671. ScopeID int
  672. ProjectRequirementID sql.NullInt32
  673. Name string
  674. Description string
  675. CreatedTime time.Time
  676. CreatedUserID string
  677. AcquiredTime sql.NullTime
  678. ScheduledDate sqltypes.NullDate
  679. ProjectID sql.NullInt32
  680. }
  681. func (q *Queries) ListItemsScheduledBetweenNoScope(ctx context.Context, arg ListItemsScheduledBetweenNoScopeParams) ([]ListItemsScheduledBetweenNoScopeRow, error) {
  682. rows, err := q.query(ctx, q.listItemsScheduledBetweenNoScopeStmt, listItemsScheduledBetweenNoScope, arg.ScheduledDate, arg.ScheduledDate_2)
  683. if err != nil {
  684. return nil, err
  685. }
  686. defer rows.Close()
  687. items := []ListItemsScheduledBetweenNoScopeRow{}
  688. for rows.Next() {
  689. var i ListItemsScheduledBetweenNoScopeRow
  690. if err := rows.Scan(
  691. &i.ID,
  692. &i.ScopeID,
  693. &i.ProjectRequirementID,
  694. &i.Name,
  695. &i.Description,
  696. &i.CreatedTime,
  697. &i.CreatedUserID,
  698. &i.AcquiredTime,
  699. &i.ScheduledDate,
  700. &i.ProjectID,
  701. ); err != nil {
  702. return nil, err
  703. }
  704. items = append(items, i)
  705. }
  706. if err := rows.Close(); err != nil {
  707. return nil, err
  708. }
  709. if err := rows.Err(); err != nil {
  710. return nil, err
  711. }
  712. return items, nil
  713. }
  714. const replaceItemStatProgress = `-- name: ReplaceItemStatProgress :exec
  715. REPLACE INTO item_stat_progress (item_id, stat_id, acquired, required)
  716. VALUES (?, ?, ?, ?)
  717. `
  718. type ReplaceItemStatProgressParams struct {
  719. ItemID int
  720. StatID int
  721. Acquired int
  722. Required int
  723. }
  724. func (q *Queries) ReplaceItemStatProgress(ctx context.Context, arg ReplaceItemStatProgressParams) error {
  725. _, err := q.exec(ctx, q.replaceItemStatProgressStmt, replaceItemStatProgress,
  726. arg.ItemID,
  727. arg.StatID,
  728. arg.Acquired,
  729. arg.Required,
  730. )
  731. return err
  732. }
  733. const updateItem = `-- name: UpdateItem :exec
  734. UPDATE item
  735. SET project_requirement_id = ?,
  736. name = ?,
  737. description = ?,
  738. acquired_time = ?,
  739. scheduled_date = ?,
  740. created_user_id = ?
  741. WHERE id = ?
  742. `
  743. type UpdateItemParams struct {
  744. ProjectRequirementID sql.NullInt32
  745. Name string
  746. Description string
  747. AcquiredTime sql.NullTime
  748. ScheduledDate sqltypes.NullDate
  749. CreatedUserID string
  750. ID int
  751. }
  752. func (q *Queries) UpdateItem(ctx context.Context, arg UpdateItemParams) error {
  753. _, err := q.exec(ctx, q.updateItemStmt, updateItem,
  754. arg.ProjectRequirementID,
  755. arg.Name,
  756. arg.Description,
  757. arg.AcquiredTime,
  758. arg.ScheduledDate,
  759. arg.CreatedUserID,
  760. arg.ID,
  761. )
  762. return err
  763. }