Merged in feature/jobsynced (pull request #72)

Job Status Get and DB tidy up

* initalquery

* tests

* shorttests

* testing queries

* job

* solvedthequery

* updatingdb

* fixingtests

* repotests

* shorttests

* docker

* testspassed
This commit is contained in:
Michael McGuinness
2025-02-20 19:02:44 +00:00
parent 0ea544926b
commit 3d434eedb8
74 changed files with 2395 additions and 1335 deletions
+6 -18
View File
@@ -43,15 +43,9 @@ func (q *Queries) CreateClient(ctx context.Context, name string) (pgtype.UUID, e
}
const getClient = `-- name: GetClient :one
SELECT c.id, c.name, coalesce(cs.canSync, false) as canSync
SELECT c.id, c.name, cs.canSync
FROM clients as c
LEFT JOIN (
SELECT clientId, canSync
FROM clientCanSync
WHERE clientId = $1
ORDER BY id DESC
LIMIT 1
) as cs on cs.clientId = c.id
JOIN currentClientCanSync as cs on cs.clientId = c.id
WHERE c.id = $1
`
@@ -63,18 +57,12 @@ type GetClientRow struct {
// GetClient
//
// SELECT c.id, c.name, coalesce(cs.canSync, false) as canSync
// SELECT c.id, c.name, cs.canSync
// FROM clients as c
// LEFT JOIN (
// SELECT clientId, canSync
// FROM clientCanSync
// WHERE clientId = $1
// ORDER BY id DESC
// LIMIT 1
// ) as cs on cs.clientId = c.id
// JOIN currentClientCanSync as cs on cs.clientId = c.id
// WHERE c.id = $1
func (q *Queries) GetClient(ctx context.Context, clientid pgtype.UUID) (*GetClientRow, error) {
row := q.db.QueryRow(ctx, getClient, clientid)
func (q *Queries) GetClient(ctx context.Context, id pgtype.UUID) (*GetClientRow, error) {
row := q.db.QueryRow(ctx, getClient, id)
var i GetClientRow
err := row.Scan(&i.ID, &i.Name, &i.Cansync)
return &i, err