item

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BucketMinVotes = map[uint32]string{
	1: "1",
	2: "2",
	3: "3-4",
	4: "5-7",
	5: "8-12",
	6: "13+",
}

Functions

This section is empty.

Types

type ActiveDaoProposalTotals

type ActiveDaoProposalTotals struct {
	DaoTotal                uint64
	DaoTotalPrevPeriod      uint64
	ProposalTotal           uint64
	ProposalTotalPrevPeriod uint64
}

type AnalyticsItem

type AnalyticsItem struct {
	DaoID          uuid.UUID                `json:"dao_id"`
	EventType      EventType                `json:"event_type"`
	EventTime      time.Time                `json:"event_time"`
	CreatedAt      int                      `json:"created_at"`
	ProposalID     string                   `json:"proposal_id"`
	Voter          string                   `json:"voter"`
	Network        string                   `json:"network"`
	Strategies     []events.StrategyPayload `json:"strategies"`
	Categories     Categories               `json:"categories"`
	FollowersCount int                      `json:"followers_count"`
	ProposalsCount int                      `json:"proposals_count"`
	Author         string                   `json:"author"`
	Type           string                   `json:"type"`
	Title          string                   `json:"title"`
	Body           string                   `json:"body"`
	Choices        Choices                  `json:"choices"`
	Start          int                      `json:"start"`
	End            int                      `json:"end"`
	Quorum         float64                  `json:"quorum"`
	State          string                   `json:"state"`
	Scores         Scores                   `json:"scores"`
	ScoresState    string                   `json:"scores_state"`
	ScoresTotal    float32                  `json:"scores_total"`
	ScoresUpdated  int                      `json:"scores_updated"`
	Votes          int                      `json:"votes"`
	App            string                   `json:"app"`
	Choice         int                      `json:"choice"`
	Vp             float64                  `json:"vp"`
	VpByStrategy   []float64                `json:"vp_by_strategy"`
	VpState        string                   `json:"vp_state"`
}

type Bin

type Bin struct {
	UpperBound float32
	Count      uint32
	TotalAvp   float32
}

type Bucket

type Bucket struct {
	GroupId uint32
	Voters  uint64
}

type Categories

type Categories []string

type Choices

type Choices []string

type DaoVoters

type DaoVoters struct {
	DaoID       uuid.UUID
	VotersCount uint32
}

type DataProvider

type DataProvider interface {
	GetMonthlyActiveUsersByDaoId(id uuid.UUID, period uint32) ([]*MonthlyActiveUser, error)
	GetVoterBucketsByDaoId(id uuid.UUID) ([]*Bucket, error)
	GetVotesGroupsByDaoId(id uuid.UUID) ([]*Bucket, error)
	GetExclusiveVotersByDaoId(id uuid.UUID) (*ExclusiveVoters, error)
	GetMonthlyNewProposalsByDaoId(id uuid.UUID, period uint32) ([]*ProposalsByMonth, error)
	GetProposalsCountByDaoId(id uuid.UUID) (*FinalProposalCounts, error)
	GetMutualDaos(id uuid.UUID, limit uint64) ([]*DaoVoters, error)
	GetTopVotersByVp(id uuid.UUID, limit int, offset int, period uint32) ([]*VoterWithVp, error)
	GetTotalVpAvgForActiveVoters(id uuid.UUID, period uint32) (*VpAvgTotal, error)
	GetVoterTotalsForPeriods(periodInDays uint32) (*VoterTotals, error)
	GetDaoProposalTotalsForPeriods(periodInDays uint32) (*ActiveDaoProposalTotals, error)
	GetMonthlyDaos() ([]*MonthlyTotal, error)
	GetMonthlyProposals() ([]*MonthlyTotal, error)
	GetMonthlyVoters() ([]*MonthlyTotal, error)
	GetDaoProposalForPeriod(period uint8) (map[uuid.UUID]float64, error)
	GetDaoVotersForPeriod(period uint8) (map[uuid.UUID]float64, error)
	GetDaoVotesForPeriod(period uint8) (map[uuid.UUID]float64, error)
	GetGoverlandIndexAdditives() (map[uuid.UUID]float64, error)
	GetDaos() ([]uuid.UUID, error)
	GetVpAvgList(id uuid.UUID, period uint32, price float32) ([]float32, error)
	GetTokenPrice(id uuid.UUID) (float32, error)
}

type EcosystemTotals

type EcosystemTotals struct {
	Daos      TotalsForTwoPeriods
	Proposals TotalsForTwoPeriods
	Voters    TotalsForTwoPeriods
	Votes     TotalsForTwoPeriods
}

type EventType

type EventType string
const (
	None       EventType = ""
	DaoCreated EventType = "dao_created"
	DaoUpdated EventType = "dao_updated"
)

type ExclusiveVoters

type ExclusiveVoters struct {
	Exclusive uint32
	Total     uint32
}

type FinalProposalCounts

type FinalProposalCounts struct {
	Succeeded uint32
	Finished  uint32
}

type MonthlyActiveUser

type MonthlyActiveUser struct {
	PeriodStarted  time.Time
	ActiveUsers    uint64
	NewActiveUsers uint64
}

type MonthlyTotal

type MonthlyTotal struct {
	PeriodStarted time.Time
	Total         uint64
	TotalOfNew    uint64
}

type MonthlyUser

type MonthlyUser struct {
	PeriodStarted time.Time
	ActiveUsers   uint64
}

type MutualDao

type MutualDao struct {
	DaoID         uuid.UUID
	VotersCount   uint32
	VotersPercent float32
}

type PopularityWorker

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

func NewPopularityWorker

func NewPopularityWorker(s *Service) *PopularityWorker

func (*PopularityWorker) Process

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

type ProposalsByMonth

type ProposalsByMonth struct {
	PeriodStarted  time.Time
	ProposalsCount uint64
	SpamCount      uint64
}

type Publisher

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

type Repo

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

func NewRepo

func NewRepo(db *gorm.DB) *Repo

func (*Repo) GetDaoProposalForPeriod

func (r *Repo) GetDaoProposalForPeriod(period uint8) (map[uuid.UUID]float64, error)

func (*Repo) GetDaoProposalTotalsForPeriods

func (r *Repo) GetDaoProposalTotalsForPeriods(periodInDays uint32) (*ActiveDaoProposalTotals, error)

func (*Repo) GetDaoVotersForPeriod

func (r *Repo) GetDaoVotersForPeriod(period uint8) (map[uuid.UUID]float64, error)

func (*Repo) GetDaoVotesForPeriod

func (r *Repo) GetDaoVotesForPeriod(period uint8) (map[uuid.UUID]float64, error)

func (*Repo) GetDaos

func (r *Repo) GetDaos() ([]uuid.UUID, error)

func (*Repo) GetExclusiveVotersByDaoId

func (r *Repo) GetExclusiveVotersByDaoId(id uuid.UUID) (*ExclusiveVoters, error)

func (*Repo) GetGoverlandIndexAdditives

func (r *Repo) GetGoverlandIndexAdditives() (map[uuid.UUID]float64, error)

func (*Repo) GetMonthlyActiveUsersByDaoId

func (r *Repo) GetMonthlyActiveUsersByDaoId(id uuid.UUID, period uint32) ([]*MonthlyActiveUser, error)

func (*Repo) GetMonthlyDaos

func (r *Repo) GetMonthlyDaos() ([]*MonthlyTotal, error)

func (*Repo) GetMonthlyNewProposalsByDaoId

func (r *Repo) GetMonthlyNewProposalsByDaoId(id uuid.UUID, period uint32) ([]*ProposalsByMonth, error)

func (*Repo) GetMonthlyProposals

func (r *Repo) GetMonthlyProposals() ([]*MonthlyTotal, error)

func (*Repo) GetMonthlyVoters

func (r *Repo) GetMonthlyVoters() ([]*MonthlyTotal, error)

func (*Repo) GetMutualDaos

func (r *Repo) GetMutualDaos(id uuid.UUID, limit uint64) ([]*DaoVoters, error)

func (*Repo) GetProposalsCountByDaoId

func (r *Repo) GetProposalsCountByDaoId(id uuid.UUID) (*FinalProposalCounts, error)

func (*Repo) GetTokenPrice

func (r *Repo) GetTokenPrice(id uuid.UUID) (float32, error)

func (*Repo) GetTopVotersByVp

func (r *Repo) GetTopVotersByVp(id uuid.UUID, offset int, limit int, period uint32) ([]*VoterWithVp, error)

func (*Repo) GetTotalVpAvgForActiveVoters

func (r *Repo) GetTotalVpAvgForActiveVoters(id uuid.UUID, period uint32) (*VpAvgTotal, error)

func (*Repo) GetVoterBucketsByDaoId

func (r *Repo) GetVoterBucketsByDaoId(id uuid.UUID) ([]*Bucket, error)

func (*Repo) GetVoterTotalsForPeriods

func (r *Repo) GetVoterTotalsForPeriods(periodInDays uint32) (*VoterTotals, error)

func (*Repo) GetVotesGroupsByDaoId

func (r *Repo) GetVotesGroupsByDaoId(id uuid.UUID) ([]*Bucket, error)

func (*Repo) GetVpAvgList

func (r *Repo) GetVpAvgList(id uuid.UUID, period uint32, price float32) ([]float32, error)

type Scores

type Scores []float32

type Server

type Server struct {
	internalapi.UnimplementedAnalyticsServer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(service *Service) *Server

type Service

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

func NewService

func NewService(p Publisher, r DataProvider) (*Service, error)

func (*Service) GetExclusiveVoters

func (s *Service) GetExclusiveVoters(id uuid.UUID) (*ExclusiveVoters, error)

func (*Service) GetMonthlyActiveUsers

func (s *Service) GetMonthlyActiveUsers(id uuid.UUID, period uint32) ([]*MonthlyActiveUser, error)

func (*Service) GetMonthlyDaos

func (s *Service) GetMonthlyDaos() ([]*MonthlyTotal, error)

func (*Service) GetMonthlyNewProposals

func (s *Service) GetMonthlyNewProposals(id uuid.UUID, period uint32) ([]*ProposalsByMonth, error)

func (*Service) GetMonthlyProposals

func (s *Service) GetMonthlyProposals() ([]*MonthlyTotal, error)

func (*Service) GetMonthlyVoters

func (s *Service) GetMonthlyVoters() ([]*MonthlyTotal, error)

func (*Service) GetMutualDaos

func (s *Service) GetMutualDaos(id uuid.UUID, limit uint64) ([]*MutualDao, error)

func (*Service) GetSucceededProposalsCount

func (s *Service) GetSucceededProposalsCount(id uuid.UUID) (*FinalProposalCounts, error)

func (*Service) GetTopVotersByVp

func (s *Service) GetTopVotersByVp(id uuid.UUID, offset uint32, limit uint32, period uint32) ([]*VoterWithVp, error)

func (*Service) GetTotalVpAvg

func (s *Service) GetTotalVpAvg(id uuid.UUID, period uint32) (*VpAvgTotal, error)

func (*Service) GetTotalsForLastPeriods

func (s *Service) GetTotalsForLastPeriods(period uint32) (*EcosystemTotals, error)

func (*Service) GetVoterBuckets

func (s *Service) GetVoterBuckets(id uuid.UUID) ([]*Bucket, error)

func (*Service) GetVotesGroups

func (s *Service) GetVotesGroups(id uuid.UUID) ([]*Bucket, error)

func (*Service) GetVpAvgList

func (s *Service) GetVpAvgList(id uuid.UUID, period uint32, minBalance float32) (*VpHistogram, error)

type Strategies

type Strategies []Strategy

type Strategy

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

type TotalForDaos

type TotalForDaos struct {
	DaoID uuid.UUID
	Total float64
}

type TotalsForTwoPeriods

type TotalsForTwoPeriods struct {
	Current  uint64
	Previous uint64
}

type VoterTotals

type VoterTotals struct {
	VoterTotal           uint64
	VoterTotalPrevPeriod uint64
	VotesTotal           uint64
	VotesTotalPrevPeriod uint64
}

type VoterWithVp

type VoterWithVp struct {
	Voter      string
	VpAvg      float32
	VotesCount uint32
}

type VpAvgTotal

type VpAvgTotal struct {
	VpAvgs float32
	Voters uint64
}

type VpHistogram

type VpHistogram struct {
	VpValue        float32
	VotersTotal    uint32
	VotersCutted   uint32
	AvpTotal       float32
	AvpTotalCutted float32
	Bins           []Bin
}

Jump to

Keyboard shortcuts

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