bring in updates from relayer.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package postgresql
|
||||
|
||||
import (
|
||||
"github.com/fiatjaf/eventstore"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/jmoiron/sqlx/reflectx"
|
||||
_ "github.com/lib/pq"
|
||||
@@ -14,6 +15,8 @@ const (
|
||||
queryTagsLimit = 10
|
||||
)
|
||||
|
||||
var _ eventstore.Storage = (*PostgresBackend)(nil)
|
||||
|
||||
func (b *PostgresBackend) Init() error {
|
||||
db, err := sqlx.Connect("postgres", b.DatabaseURL)
|
||||
if err != nil {
|
||||
|
||||
@@ -17,11 +17,13 @@ func (b PostgresBackend) QueryEvents(ctx context.Context, filter nostr.Filter) (
|
||||
|
||||
query, params, err := b.queryEventsSql(filter, false)
|
||||
if err != nil {
|
||||
close(ch)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rows, err := b.DB.Query(query, params...)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
close(ch)
|
||||
return nil, fmt.Errorf("failed to fetch events using query %q: %w", query, err)
|
||||
}
|
||||
|
||||
@@ -155,11 +157,11 @@ func (b PostgresBackend) queryEventsSql(filter nostr.Filter, doCount bool) (stri
|
||||
}
|
||||
|
||||
if filter.Since != nil {
|
||||
conditions = append(conditions, "created_at > ?")
|
||||
conditions = append(conditions, "created_at >= ?")
|
||||
params = append(params, filter.Since)
|
||||
}
|
||||
if filter.Until != nil {
|
||||
conditions = append(conditions, "created_at < ?")
|
||||
conditions = append(conditions, "created_at <= ?")
|
||||
params = append(params, filter.Until)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user