db

package
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PreparedVote

type PreparedVote struct {
	ID        uuid.UUID `gorm:"primarykey;type:uuid"`
	CreatedAt time.Time

	Voter    string
	Proposal string

	TypedData string
}

type PreparedVoteRepo

type PreparedVoteRepo struct {
	// contains filtered or unexported fields
}

func NewPreparedVoteRepo

func NewPreparedVoteRepo(conn *gorm.DB) *PreparedVoteRepo

func (*PreparedVoteRepo) Create

func (r *PreparedVoteRepo) Create(pv *PreparedVote) error

func (*PreparedVoteRepo) Get

type Proposal

type Proposal struct {
	ID        string `gorm:"primarykey"`
	SpaceID   string `gorm:"index"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt  `gorm:"index"`
	Snapshot  json.RawMessage `gorm:"type:jsonb;serializer:json"`

	VoteProcessed bool
}

type ProposalRepo

type ProposalRepo struct {
	// contains filtered or unexported fields
}

func NewProposalRepo

func NewProposalRepo(conn *gorm.DB) *ProposalRepo

func (*ProposalRepo) DeleteByID

func (r *ProposalRepo) DeleteByID(id ...string) error

func (*ProposalRepo) GetByID

func (r *ProposalRepo) GetByID(id string) (*Proposal, error)

func (*ProposalRepo) GetLatestProposal

func (r *ProposalRepo) GetLatestProposal() (*Proposal, error)

func (*ProposalRepo) GetProposalForVotes

func (r *ProposalRepo) GetProposalForVotes(limit int) ([]string, error)

func (*ProposalRepo) GetProposalIDsForUpdate

func (r *ProposalRepo) GetProposalIDsForUpdate(interval time.Duration, limit int, randOrder bool) ([]string, error)

func (*ProposalRepo) MarkVotesProcessed

func (r *ProposalRepo) MarkVotesProcessed(id string) error

func (*ProposalRepo) Upsert

func (r *ProposalRepo) Upsert(p *Proposal) (isNew bool, err error)

type ProposalService

type ProposalService struct {
	// contains filtered or unexported fields
}

func NewProposalService

func NewProposalService(repo *ProposalRepo, publisher Publisher) *ProposalService

func (*ProposalService) Delete

func (s *ProposalService) Delete(ids []string) error

func (*ProposalService) GetLatestProposal

func (s *ProposalService) GetLatestProposal() (*Proposal, error)

func (*ProposalService) GetProposalForVotes

func (s *ProposalService) GetProposalForVotes(limit int) ([]string, error)

func (*ProposalService) GetProposalIDsForUpdate

func (s *ProposalService) GetProposalIDsForUpdate(interval time.Duration, limit int, randOrder bool) ([]string, error)

func (*ProposalService) MarkVotesProcessed

func (s *ProposalService) MarkVotesProcessed(id string) error

func (*ProposalService) Upsert

func (s *ProposalService) Upsert(p *Proposal) error

type Publisher

type Publisher interface {
	PublishJSON(ctx context.Context, subject string, obj any) error
}

type Space

type Space struct {
	ID        string `gorm:"primarykey"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt  `gorm:"index"`
	Snapshot  json.RawMessage `gorm:"type:jsonb;serializer:json"`
}

type SpaceRepo

type SpaceRepo struct {
	// contains filtered or unexported fields
}

func NewSpaceRepo

func NewSpaceRepo(conn *gorm.DB) *SpaceRepo

func (*SpaceRepo) FindUndefinedSpaceIDs

func (r *SpaceRepo) FindUndefinedSpaceIDs(limit int) ([]string, error)

func (*SpaceRepo) Upsert

func (r *SpaceRepo) Upsert(s *Space) (isNew bool, err error)

type SpaceService

type SpaceService struct {
	// contains filtered or unexported fields
}

func NewSpaceService

func NewSpaceService(repo *SpaceRepo, publisher Publisher) *SpaceService

func (*SpaceService) GetUndefinedSpaceIDs

func (s *SpaceService) GetUndefinedSpaceIDs(limit int) ([]string, error)

func (*SpaceService) Upsert

func (s *SpaceService) Upsert(space *Space) error

type Vote

type Vote struct {
	ID           string `gorm:"primarykey"`
	Ipfs         string
	CreatedAt    time.Time
	UpdatedAt    time.Time
	DeletedAt    gorm.DeletedAt `gorm:"index"`
	Voter        string
	SpaceID      string
	ProposalID   string
	Choice       json.RawMessage `gorm:"serializer:json"`
	Reason       string
	App          string
	Vp           float64
	VpByStrategy []float64 `gorm:"serializer:json"`
	VpState      string
	Published    bool
}

type VoteRepo

type VoteRepo struct {
	// contains filtered or unexported fields
}

func NewVoteRepo

func NewVoteRepo(conn *gorm.DB) *VoteRepo

func (*VoteRepo) BatchCreate

func (r *VoteRepo) BatchCreate(data []Vote) error

BatchCreate creates votes in batch

func (*VoteRepo) GetLatestVote

func (r *VoteRepo) GetLatestVote(id string) (*Vote, error)

func (*VoteRepo) MarkAsPublished

func (r *VoteRepo) MarkAsPublished(votes []Vote) error

func (*VoteRepo) SelectForPublish

func (r *VoteRepo) SelectForPublish(limit int) ([]Vote, error)

func (*VoteRepo) Upsert

func (r *VoteRepo) Upsert(v *Vote) (isNew bool, err error)

type VoteService

type VoteService struct {
	// contains filtered or unexported fields
}

func NewVoteService

func NewVoteService(repo *VoteRepo, publisher Publisher) *VoteService

func (*VoteService) BatchCreate

func (s *VoteService) BatchCreate(votes []Vote) error

func (*VoteService) GetLatestVote

func (s *VoteService) GetLatestVote(id string) (*Vote, error)

func (*VoteService) Publish

func (s *VoteService) Publish(votes []Vote, batchSize int) error

func (*VoteService) Upsert

func (s *VoteService) Upsert(vote *Vote) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL