Skip to content

Commit 13d698f

Browse files
feat(apps): added submitted_at column for tracking
1 parent d85ae00 commit 13d698f

5 files changed

Lines changed: 29 additions & 5 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- +goose Up
2+
-- +goose StatementBegin
3+
ALTER TABLE applications
4+
ADD COLUMN submitted_at TIMESTAMPTZ;
5+
-- +goose StatementEnd
6+
7+
-- +goose Down
8+
-- +goose StatementBegin
9+
ALTER TABLE applications
10+
DROP COLUMN submitted_at;
11+
-- +goose StatementEnd

apps/api/internal/db/queries/applications.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ WHERE user_id = $1 AND event_id = $2;
1414
UPDATE applications
1515
SET
1616
status = CASE WHEN @status_do_update::boolean THEN @status::application_status ELSE status END,
17-
application = CASE WHEN @application_do_update::boolean THEN @application::JSONB ELSE application END
17+
application = CASE WHEN @application_do_update::boolean THEN @application::JSONB ELSE application END,
18+
submitted_at = CASE WHEN @submitted_at_do_update::boolean THEN @submitted_at::timestamptz ELSE submitted_at END
1819
WHERE
1920
user_id = @user_id AND event_id = @event_id;
2021

apps/api/internal/db/repository/application.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"errors"
7+
"time"
78

89
"github.com/google/uuid"
910
"github.com/jackc/pgx/v5"
@@ -77,6 +78,8 @@ func (r *ApplicationRepository) SubmitApplication(ctx context.Context, data any,
7778
Status: sqlc.ApplicationStatusSubmitted,
7879
ApplicationDoUpdate: true,
7980
Application: jsonBytes,
81+
SubmittedAtDoUpdate: true,
82+
SubmittedAt: time.Now(),
8083
UserID: userId,
8184
EventID: eventId,
8285
})

apps/api/internal/db/sqlc/applications.sql.go

Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/api/internal/db/sqlc/models.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)