models

package
v0.0.0-...-08d4403 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateRepository

func CreateRepository(repoName string) (string, error)

CreateRepository creates a new repository in the database

func CreateSubscriptions

func CreateSubscriptions(userID, repoID string, labels Labels) error

CreateSubscriptions creates a new entry in the database with given `userID`, `repoID` and `labels`

func CreateUser

func CreateUser(username, email string) (string, error)

CreateUser creates a new `User` in the database and returns the `userID` of the newly created `User`

func DeleteRepositoriesWithNoLabels

func DeleteRepositoriesWithNoLabels() error

DeleteRepositoriesWithNoLabels deletes repositories which have no subscribed `labels`

func GetRepositoryIDByName

func GetRepositoryIDByName(repoName string) (string, error)

GetRepositoryIDByName gets `repoID` for the given `repoName`

func GetUserIDByUsername

func GetUserIDByUsername(username string) (string, error)

GetUserIDByUsername gets `userID` for the given `username`

func RemoveSubscriptions

func RemoveSubscriptions(userID, repoID string, labels Labels) error

RemoveSubscriptions removes all the given `labels` for the given `userID` and `repoID`

func UpdateLastEventAtByRepoID

func UpdateLastEventAtByRepoID(repoID, lastEventAt string) error

UpdateLastEventAtByRepoID updates `lastEventAt` time for the given `repoID`

func UpdateSubscriptions

func UpdateSubscriptions(userID, repoID string, labels Labels) error

UpdateSubscriptions updates an existing subscription by adding the new `labels` for the given `userID` and `repoID`

Types

type Label

type Label struct {
	Name  string `json:"name" db:"label_name"`
	Color string `json:"color" db:"label_color"`
}

Label struct to store label information from database

type Labels

type Labels []Label

Labels is of type `[]Label`

func GetSubscribedLabelsByUserIDAndRepoID

func GetSubscribedLabelsByUserIDAndRepoID(userID, repoID string) (Labels, error)

GetSubscribedLabelsByUserIDAndRepoID gets all the subscribed `labels` for the given `userID` and `repoID`

func (*Labels) Scan

func (a *Labels) Scan(value interface{}) error

Scan for the `Labels` struct implement the sql.Scanner interface. This method simply decodes a JSON-encoded value into the struct fields.

func (Labels) Value

func (a Labels) Value() (driver.Value, error)

Value for the `Labels` struct to implement the driver Valuer interface. This method enables types to convert themselves to a driver Value.

type Repository

type Repository struct {
	RepoID      uuid.UUID `json:"repoID" db:"repo_id"`
	RepoName    string    `json:"repoName" db:"repo_name"`
	LastEventAt time.Time `json:"lastEventAt" db:"last_event_at"`
}

Repository struct to store repository information from database

func GetAllRepositories

func GetAllRepositories() ([]Repository, error)

GetAllRepositories gets all repositories from the database

type Subscription

type Subscription struct {
	RepoName string `json:"repoName" db:"repo_name"`
	Labels   Labels `json:"labels" db:"labels"`
}

Subscription struct to store subscription info for a single repository

func GetSubscriptionsByUserID

func GetSubscriptionsByUserID(userID string) ([]Subscription, error)

GetSubscriptionsByUserID gets all subscribed `labels` and the `userID` of the user who has subscribed for that particular for the give `repoID`

type User

type User struct {
	UserID   uuid.UUID `json:"userID" db:"user_id"`
	Username string    `json:"username" db:"username"`
	Email    string    `json:"email" db:"email"`
}

User struct to store user information from database

type UserIDLabel

type UserIDLabel struct {
	UserID uuid.UUID `json:"userID"`
	Label  string    `json:"label"`
}

UserIDLabel struct stores userID-label pair

func GetSubscriptionsByRepoID

func GetSubscriptionsByRepoID(repoID string) ([]UserIDLabel, error)

GetSubscriptionsByRepoID gets all subscriptions for the given `repoID`

Jump to

Keyboard shortcuts

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