dao

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveVotesWorker

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

func NewActiveVotesWorker

func NewActiveVotesWorker(s *Service) *ActiveVotesWorker

func (*ActiveVotesWorker) Process

func (w *ActiveVotesWorker) Process(ctx context.Context) error

type ActivitySinceRangeFilter

type ActivitySinceRangeFilter struct {
	From time.Time
	To   time.Time
}

func (ActivitySinceRangeFilter) Apply

func (f ActivitySinceRangeFilter) Apply(db *gorm.DB) *gorm.DB

type Categories

type Categories []string

type CategoryFilter

type CategoryFilter struct {
	Category string
}

func (CategoryFilter) Apply

func (f CategoryFilter) Apply(db *gorm.DB) *gorm.DB

type Consumer

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

func NewConsumer

func NewConsumer(nc *nats.Conn, s *Service) (*Consumer, error)

func (*Consumer) Start

func (c *Consumer) Start(ctx context.Context) error

type Dao

type Dao struct {
	ID              uuid.UUID `gorm:"primary_key"`
	CreatedAt       time.Time
	UpdatedAt       time.Time
	OriginalID      string
	Name            string
	Private         bool
	About           string
	Avatar          string
	Terms           string
	Location        string
	Website         string
	Twitter         string
	Github          string
	Coingecko       string
	Email           string
	Network         string
	Symbol          string
	Skin            string
	Domain          string
	Strategies      Strategies `gorm:"serializer:json"`
	Voting          Voting     `gorm:"serializer:json"`
	Categories      Categories `gorm:"serializer:json"`
	Treasures       Treasuries `gorm:"serializer:json"`
	FollowersCount  int
	ProposalsCount  int
	Guidelines      string
	Template        string
	ParentID        *uuid.UUID
	ActivitySince   int
	VotersCount     int
	PopularityIndex float64
	ActiveVotes     int
	Verified        bool
}

type DaoID

type DaoID struct {
	OriginalID string
	InternalID uuid.UUID
}

type DaoIDProvider

type DaoIDProvider interface {
	GetOrCreate(originID string) (uuid.UUID, error)
	GetAll() ([]DaoID, error)
}

type DaoIDRepo

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

func NewDaoIDRepo

func NewDaoIDRepo(conn *gorm.DB) *DaoIDRepo

func (*DaoIDRepo) GetAll

func (r *DaoIDRepo) GetAll() ([]DaoID, error)

func (*DaoIDRepo) Upsert

func (r *DaoIDRepo) Upsert(id string) (*DaoID, error)

type DaoIDService

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

func NewDaoIDService

func NewDaoIDService(repo *DaoIDRepo) *DaoIDService

func (*DaoIDService) GetAll

func (s *DaoIDService) GetAll() ([]DaoID, error)

func (*DaoIDService) GetOrCreate

func (s *DaoIDService) GetOrCreate(originID string) (uuid.UUID, error)

type DaoIDsFilter

type DaoIDsFilter struct {
	DaoIDs []string
}

func (DaoIDsFilter) Apply

func (f DaoIDsFilter) Apply(db *gorm.DB) *gorm.DB

type DaoList

type DaoList struct {
	Daos       []Dao
	TotalCount int64
}

type DataProvider

type DataProvider interface {
	Create(dao Dao) error
	Update(dao Dao) error
	GetByID(id uuid.UUID) (*Dao, error)
	UpdateProposalCnt(id uuid.UUID) error
	UpdateActiveVotes(id uuid.UUID) error
	UpdateActiveVotesAll() error
	GetByFilters(filters []Filter, count bool) (DaoList, error)
	GetCategories() ([]string, error)
	GetRecommended() ([]Recommendation, error)
}

type Filter

type Filter interface {
	Apply(*gorm.DB) *gorm.DB
}

type NameFilter

type NameFilter struct {
	Name string
}

func (NameFilter) Apply

func (f NameFilter) Apply(db *gorm.DB) *gorm.DB

type NewCategoryWorker

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

func NewNewCategoryWorker

func NewNewCategoryWorker(s *Service) *NewCategoryWorker

func (*NewCategoryWorker) ProcessNew

func (w *NewCategoryWorker) ProcessNew(ctx context.Context) error

func (*NewCategoryWorker) RemoveOutdated

func (w *NewCategoryWorker) RemoveOutdated(ctx context.Context) error

type NotCategoryFilter

type NotCategoryFilter struct {
	Category string
}

func (NotCategoryFilter) Apply

func (f NotCategoryFilter) Apply(db *gorm.DB) *gorm.DB

type OrderByFollowersFilter

type OrderByFollowersFilter struct {
}

func (OrderByFollowersFilter) Apply

func (f OrderByFollowersFilter) Apply(db *gorm.DB) *gorm.DB

type OrderByPopularityIndexFilter

type OrderByPopularityIndexFilter struct {
}

func (OrderByPopularityIndexFilter) Apply

func (f OrderByPopularityIndexFilter) Apply(db *gorm.DB) *gorm.DB

type OrderByVotersFilter

type OrderByVotersFilter struct {
}

func (OrderByVotersFilter) Apply

func (f OrderByVotersFilter) Apply(db *gorm.DB) *gorm.DB

type PageFilter

type PageFilter struct {
	Offset int
	Limit  int
}

func (PageFilter) Apply

func (f PageFilter) Apply(db *gorm.DB) *gorm.DB

type PopularCategoryWorker

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

func NewPopularCategoryWorker

func NewPopularCategoryWorker(s *Service) *PopularCategoryWorker

func (*PopularCategoryWorker) Process

func (w *PopularCategoryWorker) Process(ctx context.Context) error

type ProposalProvider

type ProposalProvider interface {
	GetEarliestByDaoID(uuid.UUID) (*proposal.Proposal, error)
}

type Publisher

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

type Recommendation added in v0.1.13

type Recommendation struct {
	OriginalId string
	InternalId string
	Name       string
	Symbol     string
	NetworkId  string
	Address    string
}

type RecommendationWorker added in v0.1.13

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

func NewRecommendationWorker added in v0.1.13

func NewRecommendationWorker(s *Service) *RecommendationWorker

func (*RecommendationWorker) Process added in v0.1.13

func (w *RecommendationWorker) Process(ctx context.Context) error

type Repo

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

func NewRepo

func NewRepo(db *gorm.DB) *Repo

func (*Repo) Create

func (r *Repo) Create(dao Dao) error

Create creates one dao object todo: check creating error/unique and others

func (*Repo) GetByFilters

func (r *Repo) GetByFilters(filters []Filter, count bool) (DaoList, error)

todo: add order by

func (*Repo) GetByID

func (r *Repo) GetByID(id uuid.UUID) (*Dao, error)

func (*Repo) GetByName

func (r *Repo) GetByName(name string) (*Dao, error)

func (*Repo) GetByOriginalID

func (r *Repo) GetByOriginalID(id string) (*Dao, error)

func (*Repo) GetCategories

func (r *Repo) GetCategories() ([]string, error)

func (*Repo) GetCountByFilters added in v0.1.8

func (r *Repo) GetCountByFilters(filters []Filter) (int64, error)

func (*Repo) GetRecommended added in v0.1.13

func (r *Repo) GetRecommended() ([]Recommendation, error)

GetRecommended returns the list of available dao strategies in our system

func (*Repo) Update

func (r *Repo) Update(dao Dao) error

Update single dao object in database todo: think about updating fields to default value(boolean, string etc)

func (*Repo) UpdateActiveVotes

func (r *Repo) UpdateActiveVotes(id uuid.UUID) error

func (*Repo) UpdateActiveVotesAll

func (r *Repo) UpdateActiveVotesAll() error

func (*Repo) UpdateProposalCnt

func (r *Repo) UpdateProposalCnt(id uuid.UUID) error

type Server

type Server struct {
	storagepb.UnimplementedDaoServer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(sp *Service) *Server

func (*Server) GetByID

func (*Server) GetRecommendationsList added in v0.1.13

type Service

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

func (*Service) GetByFilters

func (s *Service) GetByFilters(filters []Filter) (DaoList, error)

func (*Service) GetByID

func (s *Service) GetByID(id uuid.UUID) (*Dao, error)

func (*Service) GetIDByOriginalID

func (s *Service) GetIDByOriginalID(id string) (uuid.UUID, error)

func (*Service) GetTopByCategories

func (s *Service) GetTopByCategories(_ context.Context, limit int) (map[string]topList, error)

func (*Service) HandleActivitySince

func (s *Service) HandleActivitySince(_ context.Context, id uuid.UUID) (*Dao, error)

func (*Service) HandleDao

func (s *Service) HandleDao(ctx context.Context, dao Dao) error

func (*Service) PrefillDaoIDs

func (s *Service) PrefillDaoIDs() error

func (*Service) ProcessExistedProposal

func (s *Service) ProcessExistedProposal(_ context.Context, originalDaoID string) error

func (*Service) ProcessNewProposal

func (s *Service) ProcessNewProposal(_ context.Context, originalDaoID string) error

func (*Service) ProcessPopularityIndexUpdate

func (s *Service) ProcessPopularityIndexUpdate(_ context.Context, id uuid.UUID, index float64) error

func (*Service) ProcessUniqueVoters

func (s *Service) ProcessUniqueVoters(_ context.Context, voters []UniqueVoter) error

type Strategies

type Strategies []Strategy

type Strategy

type Strategy struct {
	Name    string
	Network string
	Params  map[string]interface{}
}

type TopDAOCache added in v0.1.10

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

func NewTopDAOCache added in v0.1.10

func NewTopDAOCache(repo DataProvider) *TopDAOCache

func (*TopDAOCache) GetTopList added in v0.1.10

func (w *TopDAOCache) GetTopList(limit uint) map[string]topList

func (*TopDAOCache) Start added in v0.1.10

func (w *TopDAOCache) Start(ctx context.Context) error

type Treasuries

type Treasuries []Treasury

type Treasury

type Treasury struct {
	Name    string
	Address string
	Network string
}

type UniqueVoter

type UniqueVoter struct {
	DaoID     uuid.UUID
	Voter     string
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (UniqueVoter) TableName

func (UniqueVoter) TableName() string

type UniqueVoterProvider

type UniqueVoterProvider interface {
	BatchCreate([]UniqueVoter) error
	UpdateVotersCount() error
}

type UniqueVoterRepo

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

func NewUniqueVoterRepo

func NewUniqueVoterRepo(db *gorm.DB) *UniqueVoterRepo

func (*UniqueVoterRepo) BatchCreate

func (r *UniqueVoterRepo) BatchCreate(data []UniqueVoter) error

func (*UniqueVoterRepo) UpdateVotersCount

func (r *UniqueVoterRepo) UpdateVotersCount() error

type VerifiedFilter added in v0.1.8

type VerifiedFilter struct {
}

func (VerifiedFilter) Apply added in v0.1.8

func (f VerifiedFilter) Apply(db *gorm.DB) *gorm.DB

type VotersCountWorker

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

func NewVotersCountWorker

func NewVotersCountWorker(s *Service) *VotersCountWorker

func (*VotersCountWorker) ProcessNew

func (w *VotersCountWorker) ProcessNew(ctx context.Context) error

type Voting

type Voting struct {
	Delay       int
	Period      int
	Type        string
	Quorum      float32
	Blind       bool
	HideAbstain bool
	Privacy     string
	Aliased     bool
}

Jump to

Keyboard shortcuts

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