Documentation ¶
Index ¶
- Constants
- Variables
- type AuthorsFilter
- type CategoriesFilter
- type Choices
- type Consumer
- type DaoIDsFilter
- type DaoProvider
- type DaoSucceededChoices
- type DataProvider
- type Direction
- type EnsResolver
- type EventRegistered
- type Filter
- type Order
- type OrderFilter
- type PageFilter
- type Proposal
- func (p *Proposal) CalculateState() State
- func (p *Proposal) Deleted() bool
- func (p *Proposal) InProgress() bool
- func (p *Proposal) IsBasic() bool
- func (p *Proposal) IsNotSucceededChoice() bool
- func (p *Proposal) IsSingleChoice() bool
- func (p *Proposal) IsVotedAgainst() bool
- func (p *Proposal) Pending() bool
- func (p *Proposal) QuorumReached() bool
- func (p *Proposal) QuorumSpecified() bool
- type ProposalIDsFilter
- type ProposalList
- type Publisher
- type Repo
- func (r *Repo) Create(p Proposal) error
- func (r *Repo) GetAvailableForVoting(window time.Duration) ([]*Proposal, error)
- func (r *Repo) GetByFilters(filters []Filter) (ProposalList, error)
- func (r *Repo) GetByID(id string) (*Proposal, error)
- func (r *Repo) GetCountByFilters(filters []Filter) (int64, error)
- func (r *Repo) GetEarliestByDaoID(daoID uuid.UUID) (*Proposal, error)
- func (r *Repo) GetSucceededChoices(daoId uuid.UUID) []string
- func (r *Repo) GetTop(filters []Filter) (ProposalList, error)
- func (r *Repo) Update(p Proposal) error
- func (r *Repo) UpdateVotes(list []ResolvedAddress) error
- type ResolvedAddress
- type Scores
- type Server
- type Service
- func (s *Service) GetByFilters(filters []Filter) (ProposalList, error)
- func (s *Service) GetByID(id string) (*Proposal, error)
- func (s *Service) GetTop(limit, offset int) (ProposalList, error)
- func (s *Service) HandleDeleted(ctx context.Context, pro Proposal) error
- func (s *Service) HandleProposal(ctx context.Context, pro Proposal) error
- func (s *Service) HandleProposalTimeline(_ context.Context, id string, tl Timeline) error
- func (s *Service) HandleResolvedAddresses(ctx context.Context, list []ResolvedAddress) error
- type SkipCanceled
- type SkipSpamFilter
- type State
- type Strategies
- type Strategy
- type Timeline
- func (t *Timeline) ActualizeTimeline() Timeline
- func (t *Timeline) AddNonUniqueAction(createdAt time.Time, action TimelineAction)
- func (t *Timeline) AddUniqueAction(createdAt time.Time, action TimelineAction) (isNew bool)
- func (t *Timeline) ContainsAction(action TimelineAction) bool
- func (t *Timeline) LastAction() TimelineAction
- func (t *Timeline) Sort()
- type TimelineAction
- type TimelineItem
- type TitleFilter
- type TopWorker
- type VotingWorker
Constants ¶
View Source
const ( StatePending = "pending" StateActive = "active" StateCancelled = "canceled" StateFailed = "failed" StateSucceeded = "succeeded" StateDefeated = "defeated" )
Variables ¶
View Source
var ( OrderByVotes = Order{ Field: "votes", Direction: DirectionDesc, } OrderByStates = Order{ Field: "array_position(array ['active','pending','succeeded','failed','defeated','canceled'], state)", Direction: DirectionAsc, } OrderByCreated = Order{ Field: "created", Direction: DirectionAsc, } )
Functions ¶
This section is empty.
Types ¶
type AuthorsFilter ¶
type AuthorsFilter struct {
List []string
}
type CategoriesFilter ¶
type CategoriesFilter struct {
Category string
}
type Consumer ¶
type Consumer struct {
// contains filtered or unexported fields
}
func NewConsumer ¶
type DaoIDsFilter ¶
type DaoIDsFilter struct {
DaoIDs []string
}
type DaoSucceededChoices ¶ added in v0.2.0
type DaoSucceededChoices struct { DaoID uuid.UUID `gorm:"primary_key"` Choices pq.StringArray `gorm:"type:text[]"` }
type DataProvider ¶
type DataProvider interface { Create(Proposal) error Update(proposal Proposal) error GetByID(string) (*Proposal, error) GetAvailableForVoting(time.Duration) ([]*Proposal, error) GetByFilters(filters []Filter) (ProposalList, error) GetTop(filters []Filter) (ProposalList, error) UpdateVotes(list []ResolvedAddress) error GetSucceededChoices(daoId uuid.UUID) []string }
type EnsResolver ¶
type EnsResolver interface {
AddRequests(list []string)
}
type EventRegistered ¶
type OrderFilter ¶
type OrderFilter struct {
Orders []Order
}
type PageFilter ¶
type Proposal ¶
type Proposal struct { ID string `gorm:"primary_key"` CreatedAt time.Time UpdatedAt time.Time Ipfs string Author string Created int DaoOriginalID string `gorm:"-"` DaoID uuid.UUID Network string Symbol string Type string Strategies Strategies `gorm:"serializer:json"` Title string Body string Discussion string Choices Choices `gorm:"serializer:json"` Start int End int Quorum float64 Privacy string Snapshot string State State OriginalState string Link string App string Scores Scores `gorm:"serializer:json"` ScoresState string ScoresTotal float32 ScoresUpdated int Votes int Timeline Timeline `gorm:"serializer:json"` EnsName string Spam bool SucceededChoices Choices `gorm:"-"` }
Proposal model todo: check queries to the DB and add indexes
func (*Proposal) CalculateState ¶
func (*Proposal) InProgress ¶
func (*Proposal) IsNotSucceededChoice ¶ added in v0.2.0
func (*Proposal) IsSingleChoice ¶ added in v0.2.0
func (*Proposal) IsVotedAgainst ¶
func (*Proposal) QuorumReached ¶
func (*Proposal) QuorumSpecified ¶
type ProposalIDsFilter ¶
type ProposalIDsFilter struct {
ProposalIDs []string
}
type ProposalList ¶
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
func (*Repo) Create ¶
Create creates one proposal object todo: check creating error/unique and others
func (*Repo) GetAvailableForVoting ¶
todo: think about limits, add pagination or cursor
func (*Repo) GetByFilters ¶
func (r *Repo) GetByFilters(filters []Filter) (ProposalList, error)
todo: add order by
func (*Repo) GetCountByFilters ¶ added in v0.1.8
func (*Repo) GetEarliestByDaoID ¶
func (*Repo) GetSucceededChoices ¶ added in v0.2.0
func (*Repo) Update ¶
Update single proposal object in database todo: think about updating fields to default value(boolean, string etc)
func (*Repo) UpdateVotes ¶
func (r *Repo) UpdateVotes(list []ResolvedAddress) error
type ResolvedAddress ¶
type Server ¶
type Server struct { storagepb.UnimplementedProposalServer // contains filtered or unexported fields }
func (*Server) GetByFilter ¶
func (s *Server) GetByFilter(_ context.Context, req *storagepb.ProposalByFilterRequest) (*storagepb.ProposalByFilterResponse, error)
func (*Server) GetByID ¶
func (s *Server) GetByID(_ context.Context, req *storagepb.ProposalByIDRequest) (*storagepb.ProposalByIDResponse, error)
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
todo: convert types to interfaces for unit testing
func NewService ¶
func NewService( r DataProvider, p Publisher, er EventRegistered, dp DaoProvider, ensResolver EnsResolver, ) (*Service, error)
func (*Service) GetByFilters ¶
func (s *Service) GetByFilters(filters []Filter) (ProposalList, error)
func (*Service) HandleDeleted ¶
func (*Service) HandleProposal ¶
func (*Service) HandleProposalTimeline ¶
func (*Service) HandleResolvedAddresses ¶
func (s *Service) HandleResolvedAddresses(ctx context.Context, list []ResolvedAddress) error
type SkipCanceled ¶
type SkipCanceled struct { }
type SkipSpamFilter ¶
type SkipSpamFilter struct{}
type Strategies ¶
type Strategies []Strategy
type Timeline ¶
type Timeline []TimelineItem
func (*Timeline) ActualizeTimeline ¶
func (*Timeline) AddNonUniqueAction ¶
func (t *Timeline) AddNonUniqueAction(createdAt time.Time, action TimelineAction)
func (*Timeline) AddUniqueAction ¶
func (t *Timeline) AddUniqueAction(createdAt time.Time, action TimelineAction) (isNew bool)
func (*Timeline) ContainsAction ¶
func (t *Timeline) ContainsAction(action TimelineAction) bool
func (*Timeline) LastAction ¶
func (t *Timeline) LastAction() TimelineAction
type TimelineAction ¶
type TimelineAction string
const ( None TimelineAction = "" ProposalCreated TimelineAction = "proposal.created" ProposalUpdated TimelineAction = "proposal.updated" ProposalVotingStartsSoon TimelineAction = "proposal.voting.starts_soon" ProposalVotingEndsSoon TimelineAction = "proposal.voting.ends_soon" ProposalVotingStarted TimelineAction = "proposal.voting.started" ProposalVotingQuorumReached TimelineAction = "proposal.voting.quorum_reached" ProposalVotingEnded TimelineAction = "proposal.voting.ended" )
func (TimelineAction) Equals ¶
func (a TimelineAction) Equals(action TimelineAction) bool
type TimelineItem ¶
type TimelineItem struct { CreatedAt time.Time `json:"created_at"` Action TimelineAction `json:"action"` }
type TitleFilter ¶
type TitleFilter struct {
Title string
}
type TopWorker ¶
type TopWorker struct {
// contains filtered or unexported fields
}
func NewTopWorker ¶
type VotingWorker ¶
type VotingWorker struct {
// contains filtered or unexported fields
}
func NewVotingWorker ¶
func NewVotingWorker(s *Service) *VotingWorker
Click to show internal directories.
Click to hide internal directories.