Skip to content

Commit

Permalink
Allow longer drafts to be sync and saved, optimize gpx map handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jlelse committed Aug 25, 2024
1 parent b8e3ec8 commit 9d472bf
Show file tree
Hide file tree
Showing 11 changed files with 221 additions and 199 deletions.
3 changes: 2 additions & 1 deletion editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/carlmjohnson/requests"
ws "github.com/coder/websocket"
"go.goblog.app/app/pkgs/bodylimit"
"go.goblog.app/app/pkgs/bufferpool"
"go.goblog.app/app/pkgs/contenttype"
"go.goblog.app/app/pkgs/gpxhelper"
Expand All @@ -38,7 +39,7 @@ func (a *goBlog) serveEditorPreview(w http.ResponseWriter, r *http.Request) {
if err != nil {
return
}
c.SetReadLimit(1 << 20) // 1MB
c.SetReadLimit(10 * bodylimit.MB)
defer c.Close(ws.StatusNormalClosure, "")
ctx, cancel := context.WithTimeout(r.Context(), time.Hour*6)
defer cancel()
Expand Down
30 changes: 9 additions & 21 deletions editorState.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

ws "github.com/coder/websocket"
"github.com/google/uuid"
"go.goblog.app/app/pkgs/bodylimit"
)

func (a *goBlog) serveEditorStateSync(w http.ResponseWriter, r *http.Request) {
Expand All @@ -18,7 +19,7 @@ func (a *goBlog) serveEditorStateSync(w http.ResponseWriter, r *http.Request) {
if err != nil {
return
}
c.SetReadLimit(1 << 20) // 1MB
c.SetReadLimit(10 * bodylimit.MB)
defer c.Close(ws.StatusNormalClosure, "")
// Store connection to be able to send updates
connectionId := uuid.NewString()
Expand All @@ -28,22 +29,15 @@ func (a *goBlog) serveEditorStateSync(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithTimeout(r.Context(), time.Hour*6)
defer cancel()
// Send initial content
if r.URL.Query().Get("initial") == "1" {
initialState, err := a.getEditorStateFromDatabase(ctx, blog)
initialState, err := a.getEditorStateFromDatabase(ctx, blog)
if err != nil {
return
}
if initialState != nil {
err := c.Write(ctx, ws.MessageText, initialState)
if err != nil {
return
}
if initialState != nil {
w, err := c.Writer(ctx, ws.MessageText)
if err != nil {
return
}
_, err = w.Write(initialState)
if err != nil {
return
}
_ = w.Close()
}
}
// Listen for new messages
for {
Expand Down Expand Up @@ -77,13 +71,7 @@ func (*goBlog) sendNewEditorStateToAllConnections(ctx context.Context, bc *confi
if !ok {
return true
}
w, err := c.Writer(ctx, ws.MessageText)
if err != nil {
bc.esws.Delete(key)
return true
}
defer w.Close()
_, err = w.Write(state)
err := c.Write(ctx, ws.MessageText, state)
if err != nil {
bc.esws.Delete(key)
return true
Expand Down
16 changes: 8 additions & 8 deletions geoMap.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,23 @@ func (a *goBlog) serveGeoMapTracks(w http.ResponseWriter, r *http.Request) {
}

type templateTrack struct {
Paths [][]*trackPoint
Points []*trackPoint
Paths [][]trackPoint
Points []trackPoint
Post string
}

var tracks []*templateTrack
var tracks []templateTrack
for _, p := range allPostsWithTracks {
if t, err := a.getTrack(p); err == nil && t != nil {
tracks = append(tracks, &templateTrack{
tracks = append(tracks, templateTrack{
Paths: t.Paths,
Points: t.Points,
Post: p.Path,
})
}
}

a.respondWithMinifiedJson(w, tracks)
a.respondWithMinifiedJson(w, &tracks)
}

const geoMapLocationsSubpath = "/locations.json"
Expand All @@ -123,16 +123,16 @@ func (a *goBlog) serveGeoMapLocations(w http.ResponseWriter, r *http.Request) {
Post string
}

var locations []*templateLocation
var locations []templateLocation
for _, p := range allPostsWithLocations {
for _, g := range a.geoURIs(p) {
locations = append(locations, &templateLocation{
locations = append(locations, templateLocation{
Lat: g.Latitude,
Lon: g.Longitude,
Post: p.Path,
})
}
}

a.respondWithMinifiedJson(w, locations)
a.respondWithMinifiedJson(w, &locations)
}
46 changes: 28 additions & 18 deletions geoTrack.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func (p *post) showTrackRoute() bool {
}

type trackResult struct {
Paths [][]*trackPoint
Points []*trackPoint
Paths [][]trackPoint
Points []trackPoint
Kilometers string
Hours string
Uphill string
Expand Down Expand Up @@ -84,59 +84,69 @@ func (a *goBlog) getTrack(p *post) (result *trackResult, err error) {
return result, nil
}

type trackPoint struct {
Lat, Lon float64
type trackPoint [2]float64 // Lat, Lon

func (p *trackPoint) Lat() float64 {
return p[0]
}

func (p *trackPoint) Lon() float64 {
return p[1]
}

type trackParseResult struct {
paths [][]*trackPoint
points []*trackPoint
paths [][]trackPoint
points []trackPoint
gpxData *gpx.GPX
md *gpx.MovingData
ud *gpx.UphillDownhill
}

func trackParseGPX(gpxString string) (result *trackParseResult, err error) {
trunc := func(num float64) float64 {
return float64(int64(num*100000)) / 100000
}

result = &trackParseResult{}

type trackPath struct {
gpxMovingData *gpx.MovingData
gpxUphillDownhill *gpx.UphillDownhill
points []*trackPoint
points []trackPoint
}

result.gpxData, err = gpx.ParseString(gpxString)
if err != nil {
return nil, err
}

paths := make([]*trackPath, 0)
paths := make([]trackPath, 0)
for _, track := range result.gpxData.Tracks {
for _, segment := range track.Segments {
md := segment.MovingData()
ud := segment.UphillDownhill()
path := &trackPath{
path := trackPath{
gpxMovingData: &md,
gpxUphillDownhill: &ud,
}
for _, point := range segment.Points {
path.points = append(path.points, &trackPoint{
Lat: point.Latitude, Lon: point.Longitude,
path.points = append(path.points, trackPoint{
trunc(point.Latitude), trunc(point.Longitude),
})
}
paths = append(paths, path)
}
}
for _, route := range result.gpxData.Routes {
path := &trackPath{}
path := trackPath{}
for _, point := range route.Points {
path.points = append(path.points, &trackPoint{
Lat: point.Latitude, Lon: point.Longitude,
path.points = append(path.points, trackPoint{
trunc(point.Latitude), trunc(point.Longitude),
})
}
paths = append(paths, path)
}
result.paths = make([][]*trackPoint, len(paths))
result.paths = make([][]trackPoint, len(paths))
for i, path := range paths {
// Add points
result.paths[i] = path.points
Expand All @@ -161,10 +171,10 @@ func trackParseGPX(gpxString string) (result *trackParseResult, err error) {
}
}

result.points = []*trackPoint{}
result.points = []trackPoint{}
for _, point := range result.gpxData.Waypoints {
result.points = append(result.points, &trackPoint{
Lat: point.Latitude, Lon: point.Longitude,
result.points = append(result.points, trackPoint{
trunc(point.Latitude), trunc(point.Longitude),
})
}

Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ require (
github.com/emersion/go-sasl v0.0.0-20231106173351-e73c9f7bad43
github.com/emersion/go-smtp v0.21.3
github.com/go-ap/activitypub v0.0.0-20240408091739-ba76b44c2594
github.com/go-ap/client v0.0.0-20240803164250-72674fd63382
github.com/go-ap/client v0.0.0-20240824180752-75601bb12b9e
github.com/go-ap/jsonld v0.0.0-20221030091449-f2a191312c73
github.com/go-chi/chi/v5 v5.1.0
github.com/go-fed/httpsig v1.1.0
github.com/google/uuid v1.6.0
github.com/gorilla/handlers v1.5.2
github.com/gorilla/sessions v1.3.0
github.com/gorilla/sessions v1.4.0
github.com/gorilla/websocket v1.5.3
github.com/jlaffaye/ftp v0.2.0
github.com/jlelse/feeds v1.3.0
Expand Down Expand Up @@ -70,7 +70,7 @@ require (
)

require (
git.sr.ht/~mariusor/cache v0.0.0-20240803161421-766939937a58 // indirect
git.sr.ht/~mariusor/cache v0.0.0-20240824201748-e72ac2562944 // indirect
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 // indirect
git.sr.ht/~mariusor/lw v0.0.0-20240323171419-d538df4af052 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
Expand All @@ -96,10 +96,10 @@ require (
github.com/mmcdole/goxpp v1.1.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/rs/zerolog v1.33.0 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
Expand All @@ -116,7 +116,7 @@ require (
github.com/valyala/fastjson v1.6.4 // indirect
go.mau.fi/util v0.7.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 // indirect
golang.org/x/image v0.19.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sys v0.24.0 // indirect
Expand Down
28 changes: 12 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ git.jlel.se/jlelse/goldmark-mark v0.0.0-20210522162520-9788c89266a4 h1:p3c/vCY6M
git.jlel.se/jlelse/goldmark-mark v0.0.0-20210522162520-9788c89266a4/go.mod h1:ZFhxwbX+afhgbzh5rpkSJUp6vIduNPtIGDrsWpIcHTE=
git.jlel.se/jlelse/template-strings v0.0.0-20220211095702-c012e3b5045b h1:zrGLEeWzv7bzGRUKsS42akQpszXwEU+8nXV2Z2iDSJM=
git.jlel.se/jlelse/template-strings v0.0.0-20220211095702-c012e3b5045b/go.mod h1:UNLE8cup2GTHbsE89xezRwq3GhKspPI9NyckPbgJEmw=
git.sr.ht/~mariusor/cache v0.0.0-20240803161421-766939937a58 h1:icZQDQ+4oKbVz2KH4U1f4O6eq60+4QhMJpAqCiF2z4I=
git.sr.ht/~mariusor/cache v0.0.0-20240803161421-766939937a58/go.mod h1:Yv1mSKccec0/7Jn75Zx03n7nt2SGccoX9E9jLOA62Hw=
git.sr.ht/~mariusor/cache v0.0.0-20240824201748-e72ac2562944 h1:W8B6JqBEMb0ASYFFZEL2VjuO0y1g3aowOal3w2M2uAA=
git.sr.ht/~mariusor/cache v0.0.0-20240824201748-e72ac2562944/go.mod h1:Yv1mSKccec0/7Jn75Zx03n7nt2SGccoX9E9jLOA62Hw=
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:cliQ4HHsCo6xi2oWZYKWW4bly/Ory9FuTpFPRxj/mAg=
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs=
git.sr.ht/~mariusor/lw v0.0.0-20240323171419-d538df4af052 h1:MKtevO63p4vyFsjjJq6ejop64JQr6OxkpkYK6XmdQZE=
Expand Down Expand Up @@ -67,8 +67,8 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/go-ap/activitypub v0.0.0-20240408091739-ba76b44c2594 h1:er3GvGCm7bJwHostjZlsRy7uiUuCquUVF9Fe0TrwiPI=
github.com/go-ap/activitypub v0.0.0-20240408091739-ba76b44c2594/go.mod h1:yRUfFCoZY6C1CWalauqEQ5xYgSckzEBEO/2MBC6BOME=
github.com/go-ap/client v0.0.0-20240803164250-72674fd63382 h1:cJ/LrXV24lX3Vee/YYUjoZTueuc3EQDfxmyM2/hgozk=
github.com/go-ap/client v0.0.0-20240803164250-72674fd63382/go.mod h1:621EmoV6QApDLiSNkvSoRW3/CWg0YYhb0rav1AdgjdQ=
github.com/go-ap/client v0.0.0-20240824180752-75601bb12b9e h1:Knkn3nDcKWJtDxJYl/NJkrh67gXoKEm7bwxHN/iHwNc=
github.com/go-ap/client v0.0.0-20240824180752-75601bb12b9e/go.mod h1:ChSnshME44nArX+gVCGYezXunHCtGOTaumhqsThxPWs=
github.com/go-ap/errors v0.0.0-20240304112515-6077fa9c17b0 h1:H9MGShwybHLSln6K8RxHPMHiLcD86Lru+5TVW2TcXHY=
github.com/go-ap/errors v0.0.0-20240304112515-6077fa9c17b0/go.mod h1:5x8a6P/dhmMGFxWLcyYlyOuJ2lRNaHGhRv+yu8BaTSI=
github.com/go-ap/jsonld v0.0.0-20221030091449-f2a191312c73 h1:GMKIYXyXPGIp+hYiWOhfqK4A023HdgisDT4YGgf99mw=
Expand Down Expand Up @@ -96,8 +96,8 @@ github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyE
github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w=
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
github.com/gorilla/sessions v1.3.0 h1:XYlkq7KcpOB2ZhHBPv5WpjMIxrQosiZanfoy1HLZFzg=
github.com/gorilla/sessions v1.3.0/go.mod h1:ePLdVu+jbEgHH+KWw8I1z2wqd0BAdAQh/8LRvBeoNcQ=
github.com/gorilla/sessions v1.4.0 h1:kpIYOp/oi6MG/p5PgxApU8srsSw9tuFbt46Lt7auzqQ=
github.com/gorilla/sessions v1.4.0/go.mod h1:FLWm50oby91+hl7p/wRxDth9bWSuk0qVL2emc7lT5ik=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
Expand Down Expand Up @@ -184,8 +184,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/paulmach/go.geojson v1.5.0 h1:7mhpMK89SQdHFcEGomT7/LuJhwhEgfmpWYVlVmLEdQw=
github.com/paulmach/go.geojson v1.5.0/go.mod h1:DgdUy2rRVDDVgKqrjMe2vZAHMfhDTrjVKt3LmHIXGbU=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand All @@ -199,8 +199,9 @@ github.com/pquerna/otp v1.4.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3N51bwOk=
Expand Down Expand Up @@ -229,17 +230,12 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
Expand Down Expand Up @@ -297,8 +293,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa h1:ELnwvuAXPNtPk1TJRuGkI9fDTwym6AYBu0qzT8AcHdI=
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 h1:kx6Ds3MlpiUHKj7syVnbp57++8WpuKPcR5yjLBjvLEA=
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.19.0 h1:D9FX4QWkLfkeqaC62SonffIIuYdOk/UE2XKUBgRIBIQ=
golang.org/x/image v0.19.0/go.mod h1:y0zrRqlQRWQ5PXaYCOMLTW2fpsxZ8Qh9I/ohnInJEys=
Expand Down
4 changes: 2 additions & 2 deletions postsDb.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ func buildPostsQuery(c *postsRequestConfig, selection string) (query string, arg
queryBuilder.WriteString(" and path = @path")
args = append(args, sql.Named("path", c.path))
}
if c.status != nil && len(c.status) > 0 {
if len(c.status) > 0 {
queryBuilder.WriteString(" and status in (")
for i, status := range c.status {
if i > 0 {
Expand All @@ -423,7 +423,7 @@ func buildPostsQuery(c *postsRequestConfig, selection string) (query string, arg
}
queryBuilder.WriteString(")")
}
if c.visibility != nil && len(c.visibility) > 0 {
if len(c.visibility) > 0 {
queryBuilder.WriteString(" and visibility in (")
for i, visibility := range c.visibility {
if i > 0 {
Expand Down
Loading

0 comments on commit 9d472bf

Please sign in to comment.