diff --git a/db/query.sql b/db/query.sql index 28ae3b02..a6ac6683 100644 --- a/db/query.sql +++ b/db/query.sql @@ -12,7 +12,7 @@ RETURNING id; -- name: GetCandidateRecords :many SELECT *, count(*) OVER () AS total FROM candidate_records -WHERE (status = 'new' OR EXTRACT(DAY FROM (current_timestamp - status_date)) <= 90) +WHERE (status = 'new' OR (status_date IS NOT NULL AND EXTRACT(DAY FROM (current_timestamp - status_date)) <= 90)) ORDER BY date_created ASC LIMIT sqlc.arg('limit') OFFSET sqlc.arg('offset'); @@ -20,7 +20,7 @@ OFFSET sqlc.arg('offset'); -- name: GetCandidateRecordsByPersonID :many SELECT *, count(*) OVER () AS total FROM candidate_records -WHERE (status = 'new' OR (sqlc.arg('new_only')::bool = 0::bool AND EXTRACT(DAY FROM (current_timestamp - status_date)) <= 90)) +WHERE (status = 'new' OR (status_date IS NOT NULL AND sqlc.arg('new_only')::bool = 0::bool AND EXTRACT(DAY FROM (current_timestamp - status_date)) <= 90)) AND (metadata->'author' @> sqlc.arg(query)::jsonb OR metadata->'supervisor' @> sqlc.arg(query)::jsonb) ORDER BY date_created ASC LIMIT sqlc.arg('limit') diff --git a/db/query.sql.go b/db/query.sql.go index f9618185..208b69e3 100644 --- a/db/query.sql.go +++ b/db/query.sql.go @@ -100,7 +100,7 @@ func (q *Queries) GetCandidateRecordBySource(ctx context.Context, arg GetCandida const getCandidateRecords = `-- name: GetCandidateRecords :many SELECT id, source_name, source_id, source_metadata, type, status, metadata, date_created, status_date, status_person_id, imported_id, count(*) OVER () AS total FROM candidate_records -WHERE (status = 'new' OR EXTRACT(DAY FROM (current_timestamp - status_date)) <= 90) +WHERE (status = 'new' OR (status_date IS NOT NULL AND EXTRACT(DAY FROM (current_timestamp - status_date)) <= 90)) ORDER BY date_created ASC LIMIT $2 OFFSET $1 @@ -162,7 +162,7 @@ func (q *Queries) GetCandidateRecords(ctx context.Context, arg GetCandidateRecor const getCandidateRecordsByPersonID = `-- name: GetCandidateRecordsByPersonID :many SELECT id, source_name, source_id, source_metadata, type, status, metadata, date_created, status_date, status_person_id, imported_id, count(*) OVER () AS total FROM candidate_records -WHERE (status = 'new' OR ($1::bool = 0::bool AND EXTRACT(DAY FROM (current_timestamp - status_date)) <= 90)) +WHERE (status = 'new' OR (status_date IS NOT NULL AND $1::bool = 0::bool AND EXTRACT(DAY FROM (current_timestamp - status_date)) <= 90)) AND (metadata->'author' @> $2::jsonb OR metadata->'supervisor' @> $2::jsonb) ORDER BY date_created ASC LIMIT $4 diff --git a/views/candidaterecord/summary.templ b/views/candidaterecord/summary.templ index 06b00574..34f580ae 100644 --- a/views/candidaterecord/summary.templ +++ b/views/candidaterecord/summary.templ @@ -210,7 +210,9 @@ templ importedInfo(c *ctx.Ctx, rec *models.CandidateRecord) { } else { [missing]. } - View + if rec.ImportedID != nil && *rec.ImportedID != "" { + View + }
if rec.StatusDate != nil { diff --git a/views/candidaterecord/summary_templ.go b/views/candidaterecord/summary_templ.go index 8b00b382..1cc98cb9 100644 --- a/views/candidaterecord/summary_templ.go +++ b/views/candidaterecord/summary_templ.go @@ -636,16 +636,22 @@ func importedInfo(c *ctx.Ctx, rec *models.CandidateRecord) templ.Component { return templ_7745c5c3_Err } } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("View") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">View
") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -657,7 +663,7 @@ func importedInfo(c *ctx.Ctx, rec *models.CandidateRecord) templ.Component { var templ_7745c5c3_Var29 string templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(rec.StatusDate.Format("2006-01-02")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `candidaterecord/summary.templ`, Line: 217, Col: 89} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `candidaterecord/summary.templ`, Line: 219, Col: 89} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29)) if templ_7745c5c3_Err != nil { @@ -670,7 +676,7 @@ func importedInfo(c *ctx.Ctx, rec *models.CandidateRecord) templ.Component { var templ_7745c5c3_Var30 string templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(daysUntilDisappearanceDate(*rec.StatusDate)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `candidaterecord/summary.templ`, Line: 217, Col: 161} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `candidaterecord/summary.templ`, Line: 219, Col: 161} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30)) if templ_7745c5c3_Err != nil { @@ -715,7 +721,7 @@ func rejectedInfo(c *ctx.Ctx, rec *models.CandidateRecord) templ.Component { var templ_7745c5c3_Var32 string templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(rec.StatusPerson.FullName) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `candidaterecord/summary.templ`, Line: 227, Col: 31} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `candidaterecord/summary.templ`, Line: 229, Col: 31} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32)) if templ_7745c5c3_Err != nil { @@ -738,7 +744,7 @@ func rejectedInfo(c *ctx.Ctx, rec *models.CandidateRecord) templ.Component { var templ_7745c5c3_Var33 string templ_7745c5c3_Var33, templ_7745c5c3_Err = templ.JoinStringErrs(c.PathTo("restore_rejected_candidate_record", "id", rec.ID).String()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `candidaterecord/summary.templ`, Line: 234, Col: 81} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `candidaterecord/summary.templ`, Line: 236, Col: 81} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33)) if templ_7745c5c3_Err != nil { @@ -751,7 +757,7 @@ func rejectedInfo(c *ctx.Ctx, rec *models.CandidateRecord) templ.Component { var templ_7745c5c3_Var34 string templ_7745c5c3_Var34, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("#candidate-record-%s", rec.ID)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `candidaterecord/summary.templ`, Line: 235, Col: 59} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `candidaterecord/summary.templ`, Line: 237, Col: 59} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var34)) if templ_7745c5c3_Err != nil { @@ -764,7 +770,7 @@ func rejectedInfo(c *ctx.Ctx, rec *models.CandidateRecord) templ.Component { var templ_7745c5c3_Var35 string templ_7745c5c3_Var35, templ_7745c5c3_Err = templ.JoinStringErrs(rec.StatusDate.Format("2006-01-02")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `candidaterecord/summary.templ`, Line: 240, Col: 88} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `candidaterecord/summary.templ`, Line: 242, Col: 88} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var35)) if templ_7745c5c3_Err != nil { @@ -777,7 +783,7 @@ func rejectedInfo(c *ctx.Ctx, rec *models.CandidateRecord) templ.Component { var templ_7745c5c3_Var36 string templ_7745c5c3_Var36, templ_7745c5c3_Err = templ.JoinStringErrs(daysUntilDisappearanceDate(*rec.StatusDate)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `candidaterecord/summary.templ`, Line: 240, Col: 160} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `candidaterecord/summary.templ`, Line: 242, Col: 160} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var36)) if templ_7745c5c3_Err != nil {