From 10046f1edbeb49a7ecce5dfe12ba427e4d04748e Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Sat, 9 May 2026 17:19:38 +0000 Subject: [PATCH] lint: remove unused items from resource, sync, platform, db - Remove contentUploadList/Placeholder/Detail from resource/upload.go - Remove toImageURLs, userURI from resource/communication.go - Remove responseListUser from resource/user.go - Remove contentSignin/getSignin from sync/signin.go (re-add contentSignin used elsewhere) - Delete sync/service-request.go (entirely unused) - Remove _rowWithID from platform/signal.go - Remove unused tag field from db/tx.go Rows struct --- db/tx.go | 1 - platform/signal.go | 4 -- resource/communication.go | 20 +------ resource/upload.go | 10 ---- resource/user.go | 4 -- sync/service-request.go | 118 -------------------------------------- sync/signin.go | 6 -- 7 files changed, 1 insertion(+), 162 deletions(-) delete mode 100644 sync/service-request.go diff --git a/db/tx.go b/db/tx.go index c3ce2257..1f69c697 100644 --- a/db/tx.go +++ b/db/tx.go @@ -52,7 +52,6 @@ func (r Result) RowsAffected() (int64, error) { } type Rows struct { - tag pgconn.CommandTag } func (r Rows) Close() error { diff --git a/platform/signal.go b/platform/signal.go index e8ba5db1..cfc5fe10 100644 --- a/platform/signal.go +++ b/platform/signal.go @@ -39,10 +39,6 @@ type Signal struct { Type string `db:"type" json:"type"` } -type _rowWithID struct { - ID int32 `db:"id"` -} - func SignalCreateFromPool(ctx context.Context, txn db.Ex, user User, site_id int32, feature_id int32, location types.Location) (modelpublic.Signal, error) { g := location.ToGeom() signal := modelpublic.Signal{ diff --git a/resource/communication.go b/resource/communication.go index 38bb6253..87806566 100644 --- a/resource/communication.go +++ b/resource/communication.go @@ -6,12 +6,10 @@ import ( "strconv" "time" - "github.com/Gleipnir-Technology/nidus-sync/config" modelpublic "github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/public/model" modelpublicreport "github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/publicreport/model" nhttp "github.com/Gleipnir-Technology/nidus-sync/http" "github.com/Gleipnir-Technology/nidus-sync/platform" - "github.com/google/uuid" "github.com/gorilla/mux" "github.com/rs/zerolog/log" ) @@ -57,17 +55,6 @@ type resourceStub struct { URI string `json:"uri"` } -func toImageURLs(m map[string][]uuid.UUID, id string) []string { - uuids, ok := m[id] - if !ok { - return []string{} - } - urls := make([]string, len(uuids)) - for i, u := range uuids { - urls[i] = config.MakeURLNidus("/api/image/%s/content", u.String()) - } - return urls -} func (res *communicationR) Get(ctx context.Context, r *http.Request, user platform.User, query QueryParams) (*communication, *nhttp.ErrorWithStatus) { return nil, nil } @@ -230,9 +217,4 @@ func emailURI(r router, id int32) (string, error) { func textURI(r router, id int32) (string, error) { return "fake text uri", nil } -func userURI(r *router, id *int32) (string, error) { - if id == nil { - return "", nil - } - return r.IDToURI("user.ByIDGet", int(*id)) -} + diff --git a/resource/upload.go b/resource/upload.go index 53b4e28d..34fbfa76 100644 --- a/resource/upload.go +++ b/resource/upload.go @@ -39,11 +39,6 @@ func (res *uploadR) ByIDGet(ctx context.Context, r *http.Request, u platform.Use return detail, nil } -type contentUploadList struct { - RecentUploads []platform.Upload -} -type contentUploadPlaceholder struct{} - func (res *uploadR) List(ctx context.Context, r *http.Request, user platform.User, req QueryParams) (*contentUploadPoolList, *nhttp.ErrorWithStatus) { rows, err := platform.UploadList(ctx, user.Organization) if err != nil { @@ -54,11 +49,6 @@ func (res *uploadR) List(ctx context.Context, r *http.Request, user platform.Use }, nil } -type contentUploadDetail struct { - CSVFileID int32 - Organization platform.Organization - Upload platform.Upload -} type contentUploadPoolList struct { Uploads []platform.Upload `json:"uploads"` } diff --git a/resource/user.go b/resource/user.go index 75952aa6..45a6be2f 100644 --- a/resource/user.go +++ b/resource/user.go @@ -71,10 +71,6 @@ func (res *userR) response(u *platform.User) (*user, error) { type userR struct { router *router } -type responseListUser struct { - Users []*platform.User `json:"users"` -} - func (res *userR) ByIDGet(ctx context.Context, r *http.Request, user platform.User, query QueryParams) (*platform.User, *nhttp.ErrorWithStatus) { vars := mux.Vars(r) user_id_str := vars["id"] diff --git a/sync/service-request.go b/sync/service-request.go deleted file mode 100644 index 716cd5a3..00000000 --- a/sync/service-request.go +++ /dev/null @@ -1,118 +0,0 @@ -package sync - -import ( - "context" - "net/http" - "time" - - "github.com/Gleipnir-Technology/nidus-sync/config" - "github.com/Gleipnir-Technology/nidus-sync/html" - nhttp "github.com/Gleipnir-Technology/nidus-sync/http" - "github.com/Gleipnir-Technology/nidus-sync/platform" -) - -type contentActiveServiceRequest struct { - Created time.Time - LastAction time.Time - NextStep string - Address string - PhotoCount uint - Type string - URLDetail string -} -type contentClosedServiceRequest struct { - Employee string - Type string - Closed time.Time - Address string - TimeToResolution time.Duration - URLDetail string -} -type contentServiceRequestDetail struct{} -type contentServiceRequestList struct { - ActiveRequests []contentActiveServiceRequest - ClosedRequests []contentClosedServiceRequest -} - -func getServiceRequestDetail(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentServiceRequestDetail], *nhttp.ErrorWithStatus) { - content := contentServiceRequestDetail{} - return html.NewResponse("sync/service-request-detail.html", content), nil -} -func getServiceRequestList(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentServiceRequestList], *nhttp.ErrorWithStatus) { - now := time.Now() - content := contentServiceRequestList{ - ActiveRequests: []contentActiveServiceRequest{ - contentActiveServiceRequest{ - Created: now.Add(-2 * time.Hour), - LastAction: now.Add(-2 * time.Hour), - NextStep: "schedule-appointment", - Address: "123 Main St, Anytown", - PhotoCount: 3, - Type: "biting-nuisance", - URLDetail: config.MakeURLNidus("/service-request/1"), - }, - contentActiveServiceRequest{ - Created: now.Add(-5 * time.Hour), - LastAction: now.Add(-1 * time.Hour), - NextStep: "answer-question", - Address: "456 Elm St, Anytown", - PhotoCount: 1, - Type: "standing-water", - URLDetail: config.MakeURLNidus("/service-request/1"), - }, - contentActiveServiceRequest{ - Created: now.Add(-1 * 24 * time.Hour), - LastAction: now.Add(-3 * time.Hour), - NextStep: "add-to-route", - Address: "789 Oak St, Anytown", - PhotoCount: 4, - Type: "active-breeding", - URLDetail: config.MakeURLNidus("/service-request/1"), - }, - contentActiveServiceRequest{ - Created: now.Add(-2 * 24 * time.Hour), - LastAction: now.Add(-6 * time.Hour), - NextStep: "review", - Address: "101 Pine Ln, Anytown", - PhotoCount: 0, - Type: "standing-water", - URLDetail: config.MakeURLNidus("/service-request/1"), - }, - }, - ClosedRequests: []contentClosedServiceRequest{ - contentClosedServiceRequest{ - Employee: "John Smith", - Type: "standing-water", - Closed: now.Add(-1 * 24 * time.Hour), - Address: "303 Ceder St, Anytown", - TimeToResolution: 3 * 24 * time.Hour, - URLDetail: config.MakeURLNidus("/service-request/2"), - }, - contentClosedServiceRequest{ - Employee: "Maria Garcia", - Type: "biting-nuisance", - Closed: now.Add(-2 * 24 * time.Hour), - Address: "404 Birch St, Anytown", - TimeToResolution: 1 * 24 * time.Hour, - URLDetail: config.MakeURLNidus("/service-request/2"), - }, - contentClosedServiceRequest{ - Employee: "Robert Johnson", - Type: "active-breeding", - Closed: now.Add(-4 * 24 * time.Hour), - Address: "404 Birch St, Anytown", - TimeToResolution: 5 * 24 * time.Hour, - URLDetail: config.MakeURLNidus("/service-request/2"), - }, - contentClosedServiceRequest{ - Employee: "Sarah Lee", - Type: "standing-water", - Closed: now.Add(-7 * 24 * time.Hour), - Address: "606 Willow Way, Anytown", - TimeToResolution: 2 * 24 * time.Hour, - URLDetail: config.MakeURLNidus("/service-request/2"), - }, - }, - } - return html.NewResponse("sync/service-request-list.html", content), nil -} diff --git a/sync/signin.go b/sync/signin.go index 358def6a..d5103e1e 100644 --- a/sync/signin.go +++ b/sync/signin.go @@ -16,12 +16,6 @@ type contentSignin struct { Next string } -func getSignin(w http.ResponseWriter, r *http.Request) { - errorCode := r.URL.Query().Get("error") - next := r.URL.Query().Get("next") - signin(w, errorCode, next) -} - func getSignout(w http.ResponseWriter, r *http.Request, user platform.User) { auth.SignoutUser(r, user) http.Redirect(w, r, "/signin", http.StatusFound)