Compare commits
2 Commits
6bf8417451
...
eba40a4eee
Author | SHA1 | Date | |
---|---|---|---|
eba40a4eee | |||
13484d1834 |
|
@ -186,7 +186,7 @@ func (b *memoryBackend) ChannelsCreate(name string) (microsub.Channel, error) {
|
|||
for {
|
||||
varMicrosub.Add("ChannelsCreate.RandStringBytes", 1)
|
||||
channel.UID = util.RandStringBytes(24)
|
||||
result, err := b.database.Exec(`insert into "channels" ("uid", "name", "created_at") values($1, $2, DEFAULT)`, channel.UID, channel.Name)
|
||||
result, err := b.database.Exec(`insert into "channels" ("uid", "name", "created_at") values ($1, $2, DEFAULT)`, channel.UID, channel.Name)
|
||||
if err != nil {
|
||||
log.Println("channels insert", err)
|
||||
if !shouldRetryWithNewUID(err, try) {
|
||||
|
@ -195,7 +195,7 @@ func (b *memoryBackend) ChannelsCreate(name string) (microsub.Channel, error) {
|
|||
try++
|
||||
continue
|
||||
}
|
||||
if n, err := result.RowsAffected(); err != nil {
|
||||
if n, err := result.RowsAffected(); err == nil {
|
||||
if n > 0 {
|
||||
b.broker.Notifier <- sse.Message{Event: "new channel", Object: channelMessage{1, channel}}
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ WHERE "channel_id" = $1
|
|||
log.Println(err)
|
||||
} else {
|
||||
args = append(args, b)
|
||||
qb.WriteString(` AND "published_at" >= $2`)
|
||||
qb.WriteString(` AND "published_at" > $2`)
|
||||
}
|
||||
} else if after != "" {
|
||||
b, err := time.Parse(time.RFC3339, after)
|
||||
|
@ -196,7 +196,7 @@ WHERE "channel_id" = $1
|
|||
}
|
||||
|
||||
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
|
||||
if err := row.Scan(&count); err == sql.ErrNoRows {
|
||||
return false
|
||||
|
|
Loading…
Reference in New Issue
Block a user