Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Added a check for last withdrawal to stop panic in production #1896

Merged
merged 2 commits into from
Oct 21, 2024
Merged
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
16 changes: 12 additions & 4 deletions handlers/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"strings"
"time"
Expand Down Expand Up @@ -1032,11 +1033,18 @@ func (oh *workspaceHandler) GetLastWithdrawal(w http.ResponseWriter, r *http.Req
workspace_uuid := chi.URLParam(r, "workspace_uuid")
lastWithdrawal := oh.db.GetLastWithdrawal(workspace_uuid)

now := time.Now()
withdrawCreated := lastWithdrawal.Created
withdrawTime := utils.ConvertTimeToTimestamp(withdrawCreated.String())
log.Panicln("This workspaces last withdrawal is", workspace_uuid, lastWithdrawal)

hoursDiff := int64(1)

hoursDiff := utils.GetHoursDifference(int64(withdrawTime), &now)
if lastWithdrawal.ID > 0 {
now := time.Now()
withdrawCreated := lastWithdrawal.Created
withdrawTime := utils.ConvertTimeToTimestamp(withdrawCreated.String())

hoursDiff = utils.GetHoursDifference(int64(withdrawTime), &now)
log.Panicln("This workspaces last withdrawal hours difference is", hoursDiff)
}

w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(hoursDiff)
Expand Down
Loading