From 9ce5058e85d62da427329264fda72de90ce0a819 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Sat, 9 May 2026 14:52:12 +0000 Subject: [PATCH] lint: remove unused code from sync/ package Deleted 15 entirely-unused files: admin, cell, communication, dash, download, intelligence, messages, mock, notification, operations, parcel, planning, pool, radar, review. Removed unused contentOauthPrompt and getOAuthRefresh from oauth.go. --- sync/admin.go | 17 ------- sync/cell.go | 72 --------------------------- sync/communication.go | 16 ------ sync/dash.go | 112 ------------------------------------------ sync/download.go | 17 ------- sync/intelligence.go | 16 ------ sync/messages.go | 17 ------- sync/mock.go | 105 --------------------------------------- sync/notification.go | 34 ------------- sync/oauth.go | 10 +--- sync/operations.go | 16 ------ sync/parcel.go | 16 ------ sync/planning.go | 24 --------- sync/pool.go | 22 --------- sync/radar.go | 21 -------- sync/review.go | 31 ------------ 16 files changed, 1 insertion(+), 545 deletions(-) delete mode 100644 sync/admin.go delete mode 100644 sync/cell.go delete mode 100644 sync/communication.go delete mode 100644 sync/dash.go delete mode 100644 sync/download.go delete mode 100644 sync/intelligence.go delete mode 100644 sync/messages.go delete mode 100644 sync/mock.go delete mode 100644 sync/notification.go delete mode 100644 sync/operations.go delete mode 100644 sync/parcel.go delete mode 100644 sync/planning.go delete mode 100644 sync/pool.go delete mode 100644 sync/radar.go delete mode 100644 sync/review.go diff --git a/sync/admin.go b/sync/admin.go deleted file mode 100644 index c34033c2..00000000 --- a/sync/admin.go +++ /dev/null @@ -1,17 +0,0 @@ -package sync - -import ( - "context" - "net/http" - - "github.com/Gleipnir-Technology/nidus-sync/html" - nhttp "github.com/Gleipnir-Technology/nidus-sync/http" - "github.com/Gleipnir-Technology/nidus-sync/platform" -) - -type contentAdminDash struct{} - -func getAdminDash(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentAdminDash], *nhttp.ErrorWithStatus) { - content := contentAdminDash{} - return html.NewResponse("sync/admin-dash.html", content), nil -} diff --git a/sync/cell.go b/sync/cell.go deleted file mode 100644 index 06afbe2c..00000000 --- a/sync/cell.go +++ /dev/null @@ -1,72 +0,0 @@ -package sync - -import ( - "context" - "net/http" - - //"github.com/Gleipnir-Technology/nidus-sync/h3utils" - "github.com/Gleipnir-Technology/nidus-sync/html" - nhttp "github.com/Gleipnir-Technology/nidus-sync/http" - "github.com/Gleipnir-Technology/nidus-sync/platform" - "github.com/gorilla/mux" - "github.com/uber/h3-go/v4" -) - -type contentCell struct { - BreedingSources []platform.BreedingSourceSummary - CellBoundary h3.CellBoundary - Inspections []platform.Inspection - Traps []platform.TrapSummary - Treatments []platform.Treatment -} - -func getCellDetails(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentCell], *nhttp.ErrorWithStatus) { - vars := mux.Vars(r) - cell_str := vars["cell"] - if cell_str == "" { - return nil, nhttp.NewErrorStatus(http.StatusBadRequest, "There should always be a cell") - } - c, err := HexToInt64(cell_str) - if err != nil { - return nil, nhttp.NewErrorStatus(http.StatusBadRequest, "Cannot convert provided cell to uint64") - } - boundary, err := h3.Cell(c).Boundary() - if err != nil { - return nil, nhttp.NewError("Failed to get boundary: %w", err) - } - inspections, err := platform.InspectionsByCell(ctx, user.Organization, h3.Cell(c)) - if err != nil { - return nil, nhttp.NewError("Failed to get inspections by cell: %w", err) - } - /* - center, err := h3.Cell(c).LatLng() - if err != nil { - return nil, nhttp.NewError("Failed to get center: %w", err) - } - geojson, err := h3utils.H3ToGeoJSON([]h3.Cell{h3.Cell(c)}) - if err != nil { - return nil, nhttp.NewError("Failed to get boundaries: %w", err) - } - resolution := h3.Cell(c).Resolution() - */ - sources, err := platform.BreedingSourcesByCell(ctx, user.Organization, h3.Cell(c)) - if err != nil { - return nil, nhttp.NewError("Failed to get sources: %w", err) - } - traps, err := platform.TrapsByCell(ctx, user.Organization, h3.Cell(c)) - if err != nil { - return nil, nhttp.NewError("Failed to get traps: %w", err) - } - - treatments, err := platform.TreatmentsByCell(ctx, user.Organization, h3.Cell(c)) - if err != nil { - return nil, nhttp.NewError("Failed to get treatments: %w", err) - } - return html.NewResponse("sync/cell.html", contentCell{ - BreedingSources: sources, - CellBoundary: boundary, - Inspections: inspections, - Traps: traps, - Treatments: treatments, - }), nil -} diff --git a/sync/communication.go b/sync/communication.go deleted file mode 100644 index 98b2ab3e..00000000 --- a/sync/communication.go +++ /dev/null @@ -1,16 +0,0 @@ -package sync - -import ( - "context" - "net/http" - - "github.com/Gleipnir-Technology/nidus-sync/html" - nhttp "github.com/Gleipnir-Technology/nidus-sync/http" - "github.com/Gleipnir-Technology/nidus-sync/platform" -) - -type contentCommunicationRoot struct{} - -func getCommunicationRoot(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentCommunicationRoot], *nhttp.ErrorWithStatus) { - return html.NewResponse("sync/communication-root.html", contentCommunicationRoot{}), nil -} diff --git a/sync/dash.go b/sync/dash.go deleted file mode 100644 index bf1c835a..00000000 --- a/sync/dash.go +++ /dev/null @@ -1,112 +0,0 @@ -package sync - -import ( - "context" - "net/http" - - "github.com/Gleipnir-Technology/nidus-sync/html" - nhttp "github.com/Gleipnir-Technology/nidus-sync/http" - "github.com/Gleipnir-Technology/nidus-sync/platform" - "github.com/google/uuid" - "github.com/gorilla/mux" -) - -type contentSource struct { - Inspections []platform.Inspection - Source *platform.BreedingSourceDetail - Traps []platform.TrapNearby - Treatments []platform.Treatment - //TreatmentCadence TreatmentCadence - TreatmentModels []platform.TreatmentModel - User platform.User -} -type contentTrap struct { - Trap platform.Trap - User platform.User -} -type contentLayoutTest struct { - User platform.User -} -type ContentDistrict struct { -} - -func getLayoutTest(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentLayoutTest], *nhttp.ErrorWithStatus) { - return html.NewResponse("sync/layout-test.html", contentLayoutTest{}), nil -} - -func getRoot(w http.ResponseWriter, r *http.Request) { - html.RenderOrError(w, "static/gen/main.html", struct{}{}) -} - -func getSource(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentSource], *nhttp.ErrorWithStatus) { - vars := mux.Vars(r) - globalid_s := vars["globalid"] - if globalid_s == "" { - return nil, nhttp.NewError("No globalid provided: %w", nil) - } - globalid, err := uuid.Parse(globalid_s) - if err != nil { - return nil, nhttp.NewError("globalid is not a UUID: %w", nil) - } - s, err := platform.SourceByGlobalID(ctx, user.Organization, globalid) - if err != nil { - return nil, nhttp.NewError("Failed to get source: %w", err) - } - inspections, err := platform.InspectionsBySource(ctx, user.Organization, globalid) - if err != nil { - return nil, nhttp.NewError("Failed to get inspections: %w", err) - } - traps, err := platform.TrapsBySource(ctx, user.Organization, globalid) - if err != nil { - return nil, nhttp.NewError("Failed to get traps: %w", err) - } - - treatments, err := platform.TreatmentsBySource(ctx, user.Organization, globalid) - if err != nil { - return nil, nhttp.NewError("Failed to get treatments: %w", err) - } - treatment_models := platform.ModelTreatment(treatments) - data := contentSource{ - Inspections: inspections, - Source: s, - Traps: traps, - Treatments: treatments, - TreatmentModels: treatment_models, - User: user, - } - - return html.NewResponse("sync/source.html", data), nil -} - -func getTrap(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentTrap], *nhttp.ErrorWithStatus) { - vars := mux.Vars(r) - globalid_s := vars["globalid"] - if globalid_s == "" { - return nil, nhttp.NewError("No globalid provided: %w", nil) - } - globalid, err := uuid.Parse(globalid_s) - if err != nil { - return nil, nhttp.NewError("globalid is not a UUID: %w", nil) - } - t, err := platform.TrapByGlobalId(ctx, user.Organization, globalid) - if err != nil { - return nil, nhttp.NewError("Failed to get trap: %w", err) - } - /* - latlng, err := t.H3Cell.LatLng() - if err != nil { - return nil, nhttp.NewError("Failed to get latlng: %w", err) - } - */ - data := contentTrap{ - Trap: *t, - User: user, - } - return html.NewResponse("sync/trap.html", data), nil -} - -func source(w http.ResponseWriter, r *http.Request, user platform.User, id uuid.UUID) { -} - -func trap(w http.ResponseWriter, r *http.Request, user platform.User, id uuid.UUID) { -} diff --git a/sync/download.go b/sync/download.go deleted file mode 100644 index 7030d235..00000000 --- a/sync/download.go +++ /dev/null @@ -1,17 +0,0 @@ -package sync - -import ( - "context" - "net/http" - - "github.com/Gleipnir-Technology/nidus-sync/html" - nhttp "github.com/Gleipnir-Technology/nidus-sync/http" - "github.com/Gleipnir-Technology/nidus-sync/platform" -) - -type contentDownloadPlaceholder struct{} - -func getDownloadList(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentDownloadPlaceholder], *nhttp.ErrorWithStatus) { - content := contentDownloadPlaceholder{} - return html.NewResponse("sync/download-list.html", content), nil -} diff --git a/sync/intelligence.go b/sync/intelligence.go deleted file mode 100644 index e20d9100..00000000 --- a/sync/intelligence.go +++ /dev/null @@ -1,16 +0,0 @@ -package sync - -import ( - "context" - "net/http" - - "github.com/Gleipnir-Technology/nidus-sync/html" - nhttp "github.com/Gleipnir-Technology/nidus-sync/http" - "github.com/Gleipnir-Technology/nidus-sync/platform" -) - -type contentIntelligenceRoot struct{} - -func getIntelligenceRoot(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentIntelligenceRoot], *nhttp.ErrorWithStatus) { - return html.NewResponse("sync/intelligence-root.html", contentIntelligenceRoot{}), nil -} diff --git a/sync/messages.go b/sync/messages.go deleted file mode 100644 index ce3dd36b..00000000 --- a/sync/messages.go +++ /dev/null @@ -1,17 +0,0 @@ -package sync - -import ( - "context" - "net/http" - - "github.com/Gleipnir-Technology/nidus-sync/html" - nhttp "github.com/Gleipnir-Technology/nidus-sync/http" - "github.com/Gleipnir-Technology/nidus-sync/platform" -) - -type contentMessageList struct{} - -func getMessageList(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentMessageList], *nhttp.ErrorWithStatus) { - content := contentMessageList{} - return html.NewResponse("sync/message-list.html", content), nil -} diff --git a/sync/mock.go b/sync/mock.go deleted file mode 100644 index 3ab8406e..00000000 --- a/sync/mock.go +++ /dev/null @@ -1,105 +0,0 @@ -package sync - -import ( - "fmt" - "github.com/Gleipnir-Technology/nidus-sync/html" - "github.com/gorilla/mux" - "net/http" - //"github.com/rs/zerolog/log" -) - -// Unauthenticated pages -/* - admin = buildTemplate("admin", "base") - dataEntry = buildTemplate("data-entry", "base") - dataEntryBad = buildTemplate("data-entry-bad", "base") - dispatch = buildTemplate("dispatch", "base") - dispatchResults = buildTemplate("dispatch-results", "base") - mockRoot = buildTemplate("mock-root", "base") - reportPage = buildTemplate("report", "base") - reportConfirmation = buildTemplate("report-confirmation", "base") - reportContribute = buildTemplate("report-contribute", "base") - reportDetail = buildTemplate("report-detail", "base") - reportEvidence = buildTemplate("report-evidence", "base") - reportSchedule = buildTemplate("report-schedule", "base") - reportUpdate = buildTemplate("report-update", "base") - serviceRequest = buildTemplate("service-request", "base") - serviceRequestDetail = buildTemplate("service-request-detail", "base") - serviceRequestLocation = buildTemplate("service-request-location", "base") - serviceRequestMosquito = buildTemplate("service-request-mosquito", "base") - serviceRequestPool = buildTemplate("service-request-pool", "base") - serviceRequestQuick = buildTemplate("service-request-quick", "base") - serviceRequestQuickConfirmation = buildTemplate("service-request-quick-confirmation", "base") - serviceRequestUpdates = buildTemplate("service-request-updates", "base") - settingRoot = buildTemplate("setting-mock", "base") - settingPesticide = buildTemplate("setting-pesticide", "base") - settingPesticideAdd = buildTemplate("setting-pesticide-add", "base") - settingUsers = buildTemplate("setting-user", "base") - settingUsersAdd = buildTemplate("setting-user-add", "base") -*/ - -type mock struct { - Path string - template string -} - -var mocks = []mock{} - -func addMock(r *mux.Router, path string, template string) { - mocks = append(mocks, mock{ - Path: path, - template: template, - }) - r.HandleFunc(path, renderMock(template)) -} - -type contentMock struct { - Config html.ContentConfig - DistrictName string - URLs ContentMockURLs -} - -func renderMock(template_name string) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - code := vars["code"] - if code == "" { - code = "abc-123" - } - data := contentMock{ - Config: html.NewContentConfig(), - DistrictName: "Delta MVCD", - URLs: ContentMockURLs{ - Dispatch: "/mock/dispatch", - DispatchResults: "/mock/dispatch-results", - ReportConfirmation: fmt.Sprintf("/mock/report/%s/confirm", code), - ReportDetail: fmt.Sprintf("/mock/report/%s", code), - ReportContribute: fmt.Sprintf("/mock/report/%s/contribute", code), - ReportEvidence: fmt.Sprintf("/mock/report/%s/evidence", code), - ReportSchedule: fmt.Sprintf("/mock/report/%s/schedule", code), - ReportUpdate: fmt.Sprintf("/mock/report/%s/update", code), - Root: "/mock", - Setting: "/mock/setting", - SettingIntegration: "/mock/setting/integration", - SettingPesticide: "/mock/setting/pesticide", - SettingPesticideAdd: "/mock/setting/pesticide/add", - SettingUser: "/mock/setting/user", - SettingUserAdd: "/mock/setting/user/add", - }, - } - html.RenderOrError(w, template_name, data) - } -} - -type contentMockList struct { - Config html.ContentConfig - Mocks []mock -} - -func renderMockList(w http.ResponseWriter, r *http.Request) { - data := contentMockList{ - Config: html.NewContentConfig(), - Mocks: mocks, - } - html.RenderOrError(w, "sync/mock/root.html", data) -} diff --git a/sync/notification.go b/sync/notification.go deleted file mode 100644 index 06a4218d..00000000 --- a/sync/notification.go +++ /dev/null @@ -1,34 +0,0 @@ -package sync - -import ( - "context" - //"fmt" - "net/http" - //"strings" - //"time" - - "github.com/Gleipnir-Technology/nidus-sync/html" - nhttp "github.com/Gleipnir-Technology/nidus-sync/http" - "github.com/Gleipnir-Technology/nidus-sync/platform" - //"github.com/Gleipnir-Technology/bob" - //"github.com/Gleipnir-Technology/bob/dialect/psql" - //"github.com/Gleipnir-Technology/bob/dialect/psql/sm" - //"github.com/Gleipnir-Technology/nidus-sync/db" - //"github.com/Gleipnir-Technology/nidus-sync/db/sql" - //"github.com/google/uuid" - //"github.com/uber/h3-go/v4" -) - -type contentNotificationList struct { - Notifications []platform.Notification -} - -func getNotificationList(ctx context.Context, r *http.Request, u platform.User) (*html.Response[contentNotificationList], *nhttp.ErrorWithStatus) { - notifications, err := platform.NotificationsForUser(ctx, u) - if err != nil { - return nil, nhttp.NewError("Failed to get notifications: %w", err) - } - return html.NewResponse("sync/notification-list.html", contentNotificationList{ - Notifications: notifications, - }), nil -} diff --git a/sync/oauth.go b/sync/oauth.go index b33fa004..92e76f03 100644 --- a/sync/oauth.go +++ b/sync/oauth.go @@ -1,21 +1,16 @@ package sync import ( - "context" "net/http" "net/url" "strconv" "github.com/Gleipnir-Technology/nidus-sync/auth" "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" "github.com/rs/zerolog/log" ) -type contentOauthPrompt struct{} - // Build the ArcGIS authorization URL with PKCE func buildArcGISAuthURL(clientID string) string { baseURL := "https://www.arcgis.com/sharing/rest/oauth2/authorize/" @@ -66,7 +61,4 @@ func getArcgisOauthCallback(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, config.MakeURLNidus("/"), http.StatusFound) } -func getOAuthRefresh(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentOauthPrompt], *nhttp.ErrorWithStatus) { - data := contentOauthPrompt{} - return html.NewResponse("sync/oauth-prompt.html", data), nil -} + diff --git a/sync/operations.go b/sync/operations.go deleted file mode 100644 index 304c62e3..00000000 --- a/sync/operations.go +++ /dev/null @@ -1,16 +0,0 @@ -package sync - -import ( - "context" - "net/http" - - "github.com/Gleipnir-Technology/nidus-sync/html" - nhttp "github.com/Gleipnir-Technology/nidus-sync/http" - "github.com/Gleipnir-Technology/nidus-sync/platform" -) - -type contentOperationsRoot struct{} - -func getOperationsRoot(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentOperationsRoot], *nhttp.ErrorWithStatus) { - return html.NewResponse("sync/operations-root.html", contentOperationsRoot{}), nil -} diff --git a/sync/parcel.go b/sync/parcel.go deleted file mode 100644 index 2c579b2a..00000000 --- a/sync/parcel.go +++ /dev/null @@ -1,16 +0,0 @@ -package sync - -import ( - "context" - "net/http" - - "github.com/Gleipnir-Technology/nidus-sync/html" - nhttp "github.com/Gleipnir-Technology/nidus-sync/http" - "github.com/Gleipnir-Technology/nidus-sync/platform" -) - -type contentParcel struct{} - -func getParcel(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentParcel], *nhttp.ErrorWithStatus) { - return html.NewResponse("sync/parcel.html", contentParcel{}), nil -} diff --git a/sync/planning.go b/sync/planning.go deleted file mode 100644 index 995cf35f..00000000 --- a/sync/planning.go +++ /dev/null @@ -1,24 +0,0 @@ -package sync - -import ( - "context" - "fmt" - "html/template" - "net/http" - - "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" - //"github.com/rs/zerolog/log" -) - -type contentPlanningRoot struct { - URLTiles template.HTMLAttr -} - -func getPlanningRoot(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentPlanningRoot], *nhttp.ErrorWithStatus) { - return html.NewResponse("sync/planning-root.html", contentPlanningRoot{ - URLTiles: template.HTMLAttr(fmt.Sprintf(`url-tiles="%s"`, config.MakeURLNidus("/api/tile/{z}/{y}/{x}"))), - }), nil -} diff --git a/sync/pool.go b/sync/pool.go deleted file mode 100644 index 0b7a1c78..00000000 --- a/sync/pool.go +++ /dev/null @@ -1,22 +0,0 @@ -package sync - -import ( - "context" - "net/http" - - "github.com/Gleipnir-Technology/nidus-sync/html" - nhttp "github.com/Gleipnir-Technology/nidus-sync/http" - "github.com/Gleipnir-Technology/nidus-sync/platform" -) - -type contentPoolList struct{} - -func getPoolList(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentPoolList], *nhttp.ErrorWithStatus) { - return html.NewResponse("sync/pool-list.html", contentPoolList{}), nil -} -func getPoolCreate(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentPoolList], *nhttp.ErrorWithStatus) { - return html.NewResponse("sync/pool-upload.html", contentPoolList{}), nil -} -func getPoolByID(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentPoolList], *nhttp.ErrorWithStatus) { - return html.NewResponse("sync/pool-by-id.html", contentPoolList{}), nil -} diff --git a/sync/radar.go b/sync/radar.go deleted file mode 100644 index 7c388009..00000000 --- a/sync/radar.go +++ /dev/null @@ -1,21 +0,0 @@ -package sync - -import ( - "context" - "net/http" - - "github.com/Gleipnir-Technology/nidus-sync/html" - nhttp "github.com/Gleipnir-Technology/nidus-sync/http" - "github.com/Gleipnir-Technology/nidus-sync/platform" -) - -type contentRadar struct { - Organization platform.Organization -} - -func getRadar(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentRadar], *nhttp.ErrorWithStatus) { - data := contentRadar{ - Organization: user.Organization, - } - return html.NewResponse("sync/radar.html", data), nil -} diff --git a/sync/review.go b/sync/review.go deleted file mode 100644 index 22251299..00000000 --- a/sync/review.go +++ /dev/null @@ -1,31 +0,0 @@ -package sync - -import ( - "context" - "fmt" - "html/template" - "net/http" - - "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" - //"github.com/rs/zerolog/log" -) - -type contentReviewPool struct { - URLTiles template.HTMLAttr -} -type contentReviewRoot struct{} - -func getReviewPool(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentReviewPool], *nhttp.ErrorWithStatus) { - return html.NewResponse("sync/review/pool.html", contentReviewPool{ - URLTiles: template.HTMLAttr(fmt.Sprintf(`url-tiles="%s"`, config.MakeURLNidus("/api/tile/{z}/{y}/{x}"))), - }), nil -} -func getReviewRoot(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentReviewRoot], *nhttp.ErrorWithStatus) { - return html.NewResponse("sync/review/root.html", contentReviewRoot{}), nil -} -func getReviewSite(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentReviewRoot], *nhttp.ErrorWithStatus) { - return html.NewResponse("sync/review/site.html", contentReviewRoot{}), nil -}