Compare commits

...

2 Commits

Author SHA1 Message Date
eba40a4eee
Problem: before pagination shows first items
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing
Solution: use greater than to filter first item
2022-04-16 23:56:06 +02:00
13484d1834
Problem: no events is sent when a channel is created
Solution: fix bug when checking if channel was created
2022-04-16 23:55:10 +02:00
2 changed files with 4 additions and 4 deletions

View File

@ -195,7 +195,7 @@ func (b *memoryBackend) ChannelsCreate(name string) (microsub.Channel, error) {
try++ try++
continue continue
} }
if n, err := result.RowsAffected(); err != nil { if n, err := result.RowsAffected(); err == nil {
if n > 0 { if n > 0 {
b.broker.Notifier <- sse.Message{Event: "new channel", Object: channelMessage{1, channel}} b.broker.Notifier <- sse.Message{Event: "new channel", Object: channelMessage{1, channel}}
} }

View File

@ -127,7 +127,7 @@ WHERE "channel_id" = $1
log.Println(err) log.Println(err)
} else { } else {
args = append(args, b) args = append(args, b)
qb.WriteString(` AND "published_at" >= $2`) qb.WriteString(` AND "published_at" > $2`)
} }
} else if after != "" { } else if after != "" {
b, err := time.Parse(time.RFC3339, after) b, err := time.Parse(time.RFC3339, after)
@ -196,7 +196,7 @@ WHERE "channel_id" = $1
} }
func hasMoreBefore(conn *sql.Conn, before string) bool { func hasMoreBefore(conn *sql.Conn, before string) bool {
row := conn.QueryRowContext(context.Background(), `SELECT COUNT(*) FROM "items" WHERE "published_at" >= $1`, before) row := conn.QueryRowContext(context.Background(), `SELECT COUNT(*) FROM "items" WHERE "published_at" > $1`, before)
var count int var count int
if err := row.Scan(&count); err == sql.ErrNoRows { if err := row.Scan(&count); err == sql.ErrNoRows {
return false return false