model

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DailyStat

type DailyStat struct {
	Count     int       `json:"count"`
	Name      string    `json:"name"`
	TrendDate time.Time `json:"trend_date"`
}

type Developer

type Developer struct {
	Id              int                `json:"developer_id"` // primary key saved in DB.
	GhId            int                `json:"id"`           // id from github repository api response.
	Username        string             `json:"login"`        // github api use login as username.
	AvatarUrl       string             `json:"avatar_url"`
	Name            dbutils.NullString `json:"name"`
	Company         dbutils.NullString `json:"company"`
	Blog            dbutils.NullString `json:"blog"`
	Location        dbutils.NullString `json:"location"`
	Email           dbutils.NullString `json:"email"`
	Bio             dbutils.NullString `json:"bio"`
	TwitterUsername dbutils.NullString `json:"twitter_username"`
	PublicRepos     int                `json:"public_repos"`
	PublicGists     int                `json:"public_gists"`
	Followers       int                `json:"followers"`
	Following       int                `json:"following"`
	Trendings       []Trending         `json:"trendings"`
	CreatedAt       time.Time          `json:"created_at"`
	UpdatedAt       time.Time          `json:"updated_at"`
}

type DeveloperRepo

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

func NewDeveloperRepo

func NewDeveloperRepo(db database.DB, qb *dbutils.QueryBuilder) *DeveloperRepo

func (*DeveloperRepo) FindAll added in v0.6.3

func (dr *DeveloperRepo) FindAll(ctx context.Context, opts ...any) ([]Developer, error)

func (*DeveloperRepo) FindById added in v0.5.0

func (dr *DeveloperRepo) FindById(ctx context.Context, id int) (Developer, error)

func (*DeveloperRepo) FindDevelopersByUsernames

func (dr *DeveloperRepo) FindDevelopersByUsernames(ctx context.Context, names []string) ([]Developer, error)

func (*DeveloperRepo) FindTrendingDevelopers added in v0.5.0

func (dr *DeveloperRepo) FindTrendingDevelopers(ctx context.Context, opts ...any) ([]TrendingDeveloperResponse, error)

func (*DeveloperRepo) Save

func (dr *DeveloperRepo) Save(ctx context.Context, developer Developer) (int64, error)

func (*DeveloperRepo) Update added in v0.6.3

func (dr *DeveloperRepo) Update(ctx context.Context, developer Developer) error

type GhRepository

type GhRepository struct {
	Id            int                `json:"repository_id"` // primary key saved in DB.
	GhrId         int                `json:"id"`            // id from github repository api response.
	FullName      string             `json:"full_name"`
	Owner         Owner              `json:"owner"`
	Forks         int                `json:"forks"`
	Stars         int                `json:"watchers"`
	Language      string             `json:"language"`
	Description   dbutils.NullString `json:"description"`
	DefaultBranch dbutils.NullString `json:"default_branch"`
	Homepage      dbutils.NullString `json:"homepage"`
	Tags          []Tag              `json:"tags"`
	Trendings     []Trending         `json:"trendings"`
	CreatedAt     time.Time          `json:"created_at"`
	UpdatedAt     time.Time          `json:"updated_at"`
}

func (GhRepository) GetDescription

func (gr GhRepository) GetDescription() string

type GhRepositoryRepo

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

func NewGhRepositoryRepo

func NewGhRepositoryRepo(db database.DB, qb *dbutils.QueryBuilder) *GhRepositoryRepo

func (*GhRepositoryRepo) FindAll

func (gr *GhRepositoryRepo) FindAll(ctx context.Context, opts ...any) ([]GhRepository, error)

func (*GhRepositoryRepo) FindAllWithTags

func (gr *GhRepositoryRepo) FindAllWithTags(ctx context.Context, filter string) ([]*GhRepository, error)

func (*GhRepositoryRepo) FindById

func (gr *GhRepositoryRepo) FindById(ctx context.Context, id int) (GhRepository, error)

func (*GhRepositoryRepo) FindByName

func (gr *GhRepositoryRepo) FindByName(ctx context.Context, name string) (GhRepository, error)

func (*GhRepositoryRepo) FindRepositoriesByNames

func (gr *GhRepositoryRepo) FindRepositoriesByNames(ctx context.Context, names []string) ([]GhRepository, error)

func (*GhRepositoryRepo) FindTrendingRepositories

func (gr *GhRepositoryRepo) FindTrendingRepositories(ctx context.Context, opts ...any) ([]TrendingRepositoryResponse, error)

func (*GhRepositoryRepo) Save

func (gr *GhRepositoryRepo) Save(ctx context.Context, ghRepo GhRepository) (int64, error)

func (*GhRepositoryRepo) SaveTags

func (gr *GhRepositoryRepo) SaveTags(ctx context.Context, ghRepo GhRepository, tags []Tag) error

func (*GhRepositoryRepo) Update

func (gr *GhRepositoryRepo) Update(ctx context.Context, ghRepo GhRepository) error

type Owner

type Owner struct {
	Name      string `json:"login"`
	AvatarUrl string `json:"avatar_url"`
}

type RankedTrendingDevelopers

type RankedTrendingDevelopers = map[int]TrendingDeveloper

type RankedTrendingRepository

type RankedTrendingRepository = map[int]TrendingRepository

type StatsRepo

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

func NewStatsRepo

func NewStatsRepo(db database.DB) *StatsRepo

func (*StatsRepo) FindTrendingTopicsStats

func (sr *StatsRepo) FindTrendingTopicsStats(ctx context.Context, dataRange int) ([]DailyStat, error)

type Tag

type Tag struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

type TagRepo

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

func NewTagRepo

func NewTagRepo(db database.DB) *TagRepo

func (*TagRepo) Find

func (tr *TagRepo) Find(ctx context.Context, name string) ([]Tag, error)

func (*TagRepo) FindByName

func (tr *TagRepo) FindByName(ctx context.Context, name string) (Tag, error)

func (*TagRepo) Save

func (tr *TagRepo) Save(ctx context.Context, tag Tag) (int, error)
type Trending struct {
	TrendingLanguage dbutils.NullString `json:"trending_language"`
	TrendDate        string             `json:"trend_date"`
	Rank             int                `json:"rank"`
}

type TrendingDeveloper

type TrendingDeveloper struct {
	Id          int
	Username    string
	Language    dbutils.NullString
	Rank        int
	ScrapedAt   time.Time
	TrendDate   time.Time
	DeveloperId dbutils.NullInt64
}

type TrendingDeveloperRepo

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

func NewTrendingDeveloperRepo

func NewTrendingDeveloperRepo(db database.DB) *TrendingDeveloperRepo

func (*TrendingDeveloperRepo) FindRankedTrendingDevelopersByDate

func (tdr *TrendingDeveloperRepo) FindRankedTrendingDevelopersByDate(ctx context.Context, date time.Time, language string) (RankedTrendingDevelopers, error)

func (*TrendingDeveloperRepo) FindUnlinkedDevelopers

func (tdr *TrendingDeveloperRepo) FindUnlinkedDevelopers(ctx context.Context) ([]string, error)

func (*TrendingDeveloperRepo) LinkDeveloper

func (tdr *TrendingDeveloperRepo) LinkDeveloper(ctx context.Context, developer Developer) error

func (*TrendingDeveloperRepo) Save

func (tdr *TrendingDeveloperRepo) Save(ctx context.Context, trendingDeveloper TrendingDeveloper) error

func (*TrendingDeveloperRepo) Update

func (tdr *TrendingDeveloperRepo) Update(ctx context.Context, trendingDeveloper TrendingDeveloper) error

type TrendingDeveloperResponse added in v0.5.0

type TrendingDeveloperResponse struct {
	Developer
	BestRanking   int `json:"best_ranking"`   // non db column field
	FeaturedCount int `json:"featured_count"` // non db column field
}

type TrendingRepository

type TrendingRepository struct {
	Id           int
	RepoFullName string
	Language     dbutils.NullString
	Rank         int
	ScrapedAt    time.Time
	TrendDate    time.Time
	RepositoryId dbutils.NullInt64
}

type TrendingRepositoryRepo

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

func NewTrendingRepositoryRepo

func NewTrendingRepositoryRepo(db database.DB) *TrendingRepositoryRepo

func (*TrendingRepositoryRepo) FindRankedTrendingRepoByDate

func (tr *TrendingRepositoryRepo) FindRankedTrendingRepoByDate(ctx context.Context, date time.Time, language string) (RankedTrendingRepository, error)

func (*TrendingRepositoryRepo) FindUnlinkedRepositories

func (tr *TrendingRepositoryRepo) FindUnlinkedRepositories(ctx context.Context) ([]string, error)

Get all repositories' full name when there is no repository_id set in the table.

func (*TrendingRepositoryRepo) LinkRepository

func (tr *TrendingRepositoryRepo) LinkRepository(ctx context.Context, repository GhRepository) error

Save the relation between trending repositories and repositories.

func (*TrendingRepositoryRepo) Save

func (tr *TrendingRepositoryRepo) Save(ctx context.Context, trendingRepository TrendingRepository) error

func (*TrendingRepositoryRepo) Update

func (tr *TrendingRepositoryRepo) Update(ctx context.Context, trendingRepository TrendingRepository) error

Update the trending repository as well as unlink the relationship between tranding repository and repository as the repository might be changed in the same rank. Then we leave the linking service to re-link the repository properly.

type TrendingRepositoryResponse

type TrendingRepositoryResponse struct {
	GhRepository
	BestRanking   int `json:"best_ranking"`   // non db column field
	FeaturedCount int `json:"featured_count"` // non db column field
}

type User

type User struct {
	Id        int
	Username  string
	Password  string
	Role      string
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (*User) IsPasswordValid

func (user *User) IsPasswordValid(plainPassword string) bool

func (*User) SetPassword

func (user *User) SetPassword(plainPassword string) error

type UserRepo

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

func NewUserRepo

func NewUserRepo(db database.DB) *UserRepo

func (*UserRepo) FindByName

func (ur *UserRepo) FindByName(ctx context.Context, username string) (User, error)

func (*UserRepo) Save

func (ur *UserRepo) Save(ctx context.Context, user User) (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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