Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion internal/database/counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"github.com/ComputerScienceHouse/counters/internal/models"
"github.com/ComputerScienceHouse/counters/internal/util"
"github.com/jackc/pgx/v5"
)

Expand All @@ -29,7 +30,9 @@ func CreateCounterWithReset(ctx context.Context, userId string, username string,
return "", err
}

resetID, err := CreateResetWithTransaction(ctx, tx, userId, username, rReq)
patchedResetTime := util.TranslateTime(rReq.ResetTime)

resetID, err := CreateResetWithTransaction(ctx, tx, userId, username, patchedResetTime, rReq)
if err != nil {
return "", err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/database/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func CreateReset(ctx context.Context, userID string, username string, resetTime
return resetID, err
}

func CreateResetWithTransaction(ctx context.Context, tx pgx.Tx, userID string, username string, req *models.CreateResetInput) (string, error) {
func CreateResetWithTransaction(ctx context.Context, tx pgx.Tx, userID string, username string, resetTime int64, req *models.CreateResetInput) (string, error) {
resetID, err := GenerateUUID()
if err != nil {
return "", err
Expand All @@ -31,7 +31,7 @@ func CreateResetWithTransaction(ctx context.Context, tx pgx.Tx, userID string, u
_, err = tx.Exec(ctx, `
INSERT INTO resets (reset_id, counter_id, user_id, username, description, occured_at)
VALUES ($1, $2, $3, $4, $5, $6)
`, resetID, req.CounterID, userID, username, req.Description, req.ResetTime)
`, resetID, req.CounterID, userID, username, req.Description, time.Unix(resetTime, 0))

return resetID, err
}
Expand Down
6 changes: 3 additions & 3 deletions templates/counter.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@
<div class="row border-bottom mb-2 pb-2">
<div class="col d-flex flex-column justify-content-center">
<div class="text-center my-auto">
<span class="fs-5">{{ $reset.Description }}</span>
<span class="fs-5">{{ $reset.ResetDescription }}</span>
<br/>
<span class="description"><i>reported by: {{ $reset.Reporter }}</i></span>
<span class="description"><i>reported by: {{ $reset.ResetUsername }}</i></span>
</div>
</div>
<div class="col">
<div class="text-center my-auto">
<span class="days-since fw-bold display-3" data-timestamp="{{ $reset.Timestamp }}"> </span>
<span class="days-since fw-bold display-3" data-timestamp="{{ $reset.ResetOccuredAt }}"> </span>
<span class="description d-block">Day(s) Ago</span>
</div>
</div>
Expand Down
Loading