db

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message added in v0.5.1

type Message struct {
	ID        string `gorm:"primarykey"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt  `gorm:"index"`
	MCI       int             `gorm:"unique_index"`
	Space     string          `gorm:"index:space_type_idx"`
	Timestamp time.Time       `gorm:"index:space_type_idx"`
	Type      MessageType     `gorm:"index:space_type_idx"`
	Snapshot  json.RawMessage `gorm:"type:jsonb;serializer:json"`
	IpfsID    string          `gorm:"-"` // virtual property
}

type MessageRepo added in v0.5.1

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

func NewMessageRepo added in v0.5.1

func NewMessageRepo(conn *gorm.DB) *MessageRepo

func (*MessageRepo) CreateInBatches added in v0.5.1

func (r *MessageRepo) CreateInBatches(messages []*Message) (newRows int, err error)

func (*MessageRepo) FindDaoUpdateSettings added in v0.5.3

func (r *MessageRepo) FindDaoUpdateSettings(limit, offset int) ([]string, error)

func (*MessageRepo) FindDeleteProposals added in v0.5.1

func (r *MessageRepo) FindDeleteProposals(limit, offset int) ([]string, error)

func (*MessageRepo) FindLatestMCI added in v0.5.1

func (r *MessageRepo) FindLatestMCI() (int, error)

func (*MessageRepo) FindSpacesWithNewVotes added in v0.5.1

func (r *MessageRepo) FindSpacesWithNewVotes(after time.Time) ([]string, error)

func (*MessageRepo) Upsert added in v0.5.1

func (r *MessageRepo) Upsert(m *Message) (isNew bool, err error)

type MessageService added in v0.5.1

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

func NewMessageService added in v0.5.1

func NewMessageService(repo *MessageRepo, publisher Publisher) *MessageService

func (*MessageService) FindDaoUpdateSettings added in v0.5.3

func (s *MessageService) FindDaoUpdateSettings(limit, offset int) ([]string, error)

func (*MessageService) FindDeleteProposals added in v0.5.1

func (s *MessageService) FindDeleteProposals(limit, offset int) ([]string, error)

func (*MessageService) FindSpacesWithNewVotes added in v0.5.1

func (s *MessageService) FindSpacesWithNewVotes(after time.Time) ([]string, error)

func (*MessageService) GetLatestMCI added in v0.5.1

func (s *MessageService) GetLatestMCI() (int, error)

func (*MessageService) Upsert added in v0.5.1

func (s *MessageService) Upsert(message ...*Message) error

type MessageType added in v0.5.1

type MessageType string
const (
	VoteMessage            MessageType = "vote"
	ProposalMessage        MessageType = "proposal"
	InvalidProposalMessage MessageType = "invalid-proposal"
	ArchiveProposalMessage MessageType = "archive-proposal"
	DeleteProposalMessage  MessageType = "delete-proposal"
	SettingsMessage        MessageType = "settings"
)

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
	RefetchedAt sql.NullTime
	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) GetFinishedShutterProposals added in v0.6.6

func (r *ProposalRepo) GetFinishedShutterProposals(limit int) ([]string, 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(spaces []string, interval time.Duration, limit int, randOrder bool) ([]string, error)

func (*ProposalRepo) MarkProposalAsRefetched added in v0.6.6

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

func (*ProposalRepo) MarkVotesProcessed

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

func (*ProposalRepo) RemoveFetchedVotes added in v0.6.6

func (r *ProposalRepo) RemoveFetchedVotes(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) GetFinishedShutterProposals added in v0.6.6

func (s *ProposalService) GetFinishedShutterProposals(limit int) ([]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(spaces []string, interval time.Duration, limit int, randOrder bool) ([]string, error)

func (*ProposalService) MarkAsRefetched added in v0.6.6

func (s *ProposalService) MarkAsRefetched(id 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() (*Vote, error)

func (*VoteRepo) GetLatestVoteByProposal added in v0.5.1

func (r *VoteRepo) GetLatestVoteByProposal(proposalID 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() (*Vote, error)

func (*VoteService) GetLatestVoteByProposal added in v0.5.1

func (s *VoteService) GetLatestVoteByProposal(proposalID 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