mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2026-01-06 00:13:16 -06:00
adds support for unending polls to be created locally
This commit is contained in:
parent
312cb8b9c7
commit
98e0fea4eb
2 changed files with 51 additions and 28 deletions
|
|
@ -88,12 +88,15 @@ func (p *pollDB) getPoll(ctx context.Context, lookup string, dbQuery func(*gtsmo
|
|||
func (p *pollDB) GetOpenPolls(ctx context.Context) ([]*gtsmodel.Poll, error) {
|
||||
var pollIDs []string
|
||||
|
||||
// Select all polls with unset `closed_at` time.
|
||||
// Select all polls with:
|
||||
// - UNSET `closed_at`
|
||||
// - SET `expires_at`
|
||||
if err := p.db.NewSelect().
|
||||
Table("polls").
|
||||
Column("polls.id").
|
||||
Join("JOIN ? ON ? = ?", bun.Ident("statuses"), bun.Ident("polls.id"), bun.Ident("statuses.poll_id")).
|
||||
Where("? = true", bun.Ident("statuses.local")).
|
||||
Where("? IS NOT NULL", bun.Ident("polls.expires_at")).
|
||||
Where("? IS NULL", bun.Ident("polls.closed_at")).
|
||||
Scan(ctx, &pollIDs); err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue