db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type DeleteRemovedReposParams

type DeleteRemovedReposParams struct {
	Column1 uuid.UUID
	Column2 []string
}

type DequeueSyncJobRow

type DequeueSyncJobRow struct {
	ID              int64
	CreatedAt       time.Time
	Status          string
	RepoSyncID      uuid.UUID
	RepoID          uuid.UUID
	SyncType        string
	Settings        pgtype.JSONB
	ID_2            uuid.UUID
	ScheduleEnabled bool
	Repo            string
	Ref             sql.NullString
	IsGithub        sql.NullBool
	RepoSettings    pgtype.JSONB
}

type GetRepoIDsFromRepoImportParams added in v0.1.0

type GetRepoIDsFromRepoImportParams struct {
	Importid  uuid.UUID
	Reposurls []string
}

type GitBlame added in v0.0.6

type GitBlame struct {
	RepoID            uuid.UUID
	AuthorEmail       sql.NullString
	AuthorName        sql.NullString
	AuthorWhen        sql.NullTime
	CommitHash        sql.NullString
	LineNo            int32
	Line              sql.NullString
	Path              string
	MergestatSyncedAt time.Time
}

type GitBranch

type GitBranch struct {
	RepoID            uuid.UUID
	FullName          string
	Hash              sql.NullString
	Name              sql.NullString
	Remote            sql.NullString
	Target            sql.NullString
	Type              sql.NullString
	TagCommitHash     sql.NullString
	MergestatSyncedAt time.Time
}

type GitCommit

type GitCommit struct {
	RepoID            uuid.UUID
	Hash              string
	Message           string
	AuthorName        string
	AuthorEmail       string
	AuthorWhen        time.Time
	CommitterName     string
	CommitterEmail    string
	CommitterWhen     time.Time
	Parents           int32
	MergestatSyncedAt time.Time
}

Git repository commits

type GitCommitStat

type GitCommitStat struct {
	RepoID            uuid.UUID
	CommitHash        string
	FilePath          string
	Additions         int32
	Deletions         int32
	MergestatSyncedAt time.Time
	OldFileMode       string
	NewFileMode       string
}

Commit stats

type GitFile

type GitFile struct {
	RepoID            uuid.UUID
	Path              string
	Executable        bool
	Contents          sql.NullString
	MergestatSyncedAt time.Time
}

Git repository files

type GitRef

type GitRef struct {
	RepoID            uuid.UUID
	FullName          string
	Hash              sql.NullString
	Name              sql.NullString
	Remote            sql.NullString
	Target            sql.NullString
	Type              sql.NullString
	TagCommitHash     sql.NullString
	MergestatSyncedAt time.Time
}

Refs for a Git repo

type GitTag

type GitTag struct {
	RepoID            uuid.UUID
	FullName          string
	Hash              sql.NullString
	Name              sql.NullString
	Remote            sql.NullString
	Target            sql.NullString
	Type              sql.NullString
	TagCommitHash     sql.NullString
	MergestatSyncedAt time.Time
}

type GithubIssue

type GithubIssue struct {
	RepoID              uuid.UUID
	AuthorLogin         sql.NullString
	Body                sql.NullString
	Closed              sql.NullBool
	ClosedAt            sql.NullTime
	CommentCount        sql.NullInt32
	CreatedAt           sql.NullTime
	CreatedViaEmail     sql.NullBool
	DatabaseID          int32
	EditorLogin         sql.NullString
	IncludesCreatedEdit sql.NullBool
	LabelCount          sql.NullInt32
	LastEditedAt        sql.NullTime
	Locked              sql.NullBool
	MilestoneCount      sql.NullInt32
	Number              int32
	ParticipantCount    sql.NullInt32
	PublishedAt         sql.NullTime
	ReactionCount       sql.NullInt32
	State               sql.NullString
	Title               sql.NullString
	UpdatedAt           sql.NullTime
	Url                 sql.NullString
	Labels              pgtype.JSONB
	MergestatSyncedAt   time.Time
}

GitHub issues

type GithubPullRequest

type GithubPullRequest struct {
	RepoID              uuid.UUID
	Additions           sql.NullInt32
	AuthorLogin         sql.NullString
	AuthorAssociation   sql.NullString
	AuthorAvatarUrl     sql.NullString
	AuthorName          sql.NullString
	BaseRefOid          sql.NullString
	BaseRefName         sql.NullString
	BaseRepositoryName  sql.NullString
	Body                sql.NullString
	ChangedFiles        sql.NullInt32
	Closed              sql.NullBool
	ClosedAt            sql.NullTime
	CommentCount        sql.NullInt32
	CommitCount         sql.NullInt32
	CreatedAt           sql.NullTime
	CreatedViaEmail     sql.NullBool
	DatabaseID          int32
	Deletions           sql.NullInt32
	EditorLogin         sql.NullString
	HeadRefName         sql.NullString
	HeadRefOid          sql.NullString
	HeadRepositoryName  sql.NullString
	IsDraft             sql.NullBool
	LabelCount          sql.NullInt32
	LastEditedAt        sql.NullTime
	Locked              sql.NullBool
	MaintainerCanModify sql.NullBool
	MantainerCanModify  sql.NullBool
	Mergeable           sql.NullString
	Merged              sql.NullBool
	MergedAt            sql.NullTime
	MergedBy            sql.NullString
	Number              sql.NullInt32
	ParticipantCount    sql.NullInt32
	PublishedAt         sql.NullTime
	ReviewDecision      sql.NullString
	State               sql.NullString
	Title               sql.NullString
	UpdatedAt           sql.NullTime
	Url                 sql.NullString
	Labels              pgtype.JSONB
	MergestatSyncedAt   time.Time
}

GitHub pull requests

type GithubPullRequestCommit

type GithubPullRequestCommit struct {
	RepoID            uuid.UUID
	PrNumber          int32
	Hash              sql.NullString
	Message           sql.NullString
	AuthorName        sql.NullString
	AuthorEmail       sql.NullString
	AuthorWhen        sql.NullTime
	CommitterName     sql.NullString
	CommitterEmail    sql.NullString
	CommitterWhen     sql.NullTime
	Additions         sql.NullInt32
	Deletions         sql.NullInt32
	ChangedFiles      sql.NullInt32
	Url               sql.NullString
	MergestatSyncedAt time.Time
}

GitHub pull request commits

type GithubPullRequestReview

type GithubPullRequestReview struct {
	RepoID                    uuid.UUID
	PrNumber                  int32
	ID                        string
	AuthorLogin               sql.NullString
	AuthorUrl                 sql.NullString
	AuthorAssociation         sql.NullString
	AuthorCanPushToRepository sql.NullBool
	Body                      sql.NullString
	CommentCount              sql.NullInt32
	CreatedAt                 sql.NullTime
	CreatedViaEmail           sql.NullBool
	EditorLogin               sql.NullString
	LastEditedAt              sql.NullTime
	PublishedAt               sql.NullTime
	State                     sql.NullString
	SubmittedAt               sql.NullTime
	UpdatedAt                 sql.NullTime
	MergestatSyncedAt         time.Time
}

GitHub pull request reviews

type GithubRepoInfo

type GithubRepoInfo struct {
	RepoID                   uuid.UUID
	Owner                    string
	Name                     string
	CreatedAt                sql.NullTime
	DefaultBranchName        sql.NullString
	Description              sql.NullString
	DiskUsage                sql.NullInt32
	ForkCount                sql.NullInt32
	HomepageUrl              sql.NullString
	IsArchived               sql.NullBool
	IsDisabled               sql.NullBool
	IsMirror                 sql.NullBool
	IsPrivate                sql.NullBool
	TotalIssuesCount         sql.NullInt32
	LatestReleaseAuthor      sql.NullString
	LatestReleaseCreatedAt   sql.NullTime
	LatestReleaseName        sql.NullString
	LatestReleasePublishedAt sql.NullTime
	LicenseKey               sql.NullString
	LicenseName              sql.NullString
	LicenseNickname          sql.NullString
	OpenGraphImageUrl        sql.NullString
	PrimaryLanguage          sql.NullString
	PushedAt                 sql.NullTime
	ReleasesCount            sql.NullInt32
	StargazersCount          sql.NullInt32
	UpdatedAt                sql.NullTime
	WatchersCount            sql.NullInt32
	MergestatSyncedAt        time.Time
}

GitHub metadata about a repo

type GithubStargazer

type GithubStargazer struct {
	RepoID            uuid.UUID
	Login             string
	Email             sql.NullString
	Name              sql.NullString
	Bio               sql.NullString
	Company           sql.NullString
	AvatarUrl         sql.NullString
	CreatedAt         sql.NullTime
	UpdatedAt         sql.NullTime
	Twitter           sql.NullString
	Website           sql.NullString
	Location          sql.NullString
	StarredAt         sql.NullTime
	MergestatSyncedAt time.Time
}

GitHub stargazers for a repo

type InsertGitHubRepoInfoParams

type InsertGitHubRepoInfoParams struct {
	RepoID                   uuid.UUID
	Owner                    string
	Name                     string
	CreatedAt                sql.NullTime
	DefaultBranchName        sql.NullString
	Description              sql.NullString
	DiskUsage                sql.NullInt32
	ForkCount                sql.NullInt32
	HomepageUrl              sql.NullString
	IsArchived               sql.NullBool
	IsDisabled               sql.NullBool
	IsMirror                 sql.NullBool
	IsPrivate                sql.NullBool
	TotalIssuesCount         sql.NullInt32
	LatestReleaseAuthor      sql.NullString
	LatestReleaseCreatedAt   sql.NullTime
	LatestReleaseName        sql.NullString
	LatestReleasePublishedAt sql.NullTime
	LicenseKey               sql.NullString
	LicenseName              sql.NullString
	LicenseNickname          sql.NullString
	OpenGraphImageUrl        sql.NullString
	PrimaryLanguage          sql.NullString
	PushedAt                 sql.NullTime
	ReleasesCount            sql.NullInt32
	StargazersCount          sql.NullInt32
	UpdatedAt                sql.NullTime
	WatchersCount            sql.NullInt32
}

type InsertNewDefaultSyncParams added in v0.1.0

type InsertNewDefaultSyncParams struct {
	Repoid   uuid.UUID
	Synctype string
}

type InsertSyncJobLogParams

type InsertSyncJobLogParams struct {
	LogType         string
	Message         string
	RepoSyncQueueID int64
}

type ListRepoImportsDueForImportRow

type ListRepoImportsDueForImportRow struct {
	ID        uuid.UUID
	CreatedAt time.Time
	UpdatedAt time.Time
	Type      string
	Settings  pgtype.JSONB
}

type MergestatLatestRepoSync

type MergestatLatestRepoSync struct {
	ID         int64
	CreatedAt  time.Time
	RepoSyncID uuid.UUID
	Status     string
	StartedAt  sql.NullTime
	DoneAt     sql.NullTime
}

type MergestatRepoImport

type MergestatRepoImport struct {
	ID                  uuid.UUID
	CreatedAt           time.Time
	UpdatedAt           time.Time
	Type                string
	Settings            pgtype.JSONB
	LastImport          sql.NullTime
	ImportInterval      sql.NullString
	LastImportStartedAt sql.NullTime
}

Table for "dynamic" repo imports - regularly loading from a GitHub org for example

type MergestatRepoImportType

type MergestatRepoImportType struct {
	Type        string
	Description string
}

Types of repo imports

type MergestatRepoSync

type MergestatRepoSync struct {
	RepoID          uuid.UUID
	SyncType        string
	Settings        pgtype.JSONB
	ID              uuid.UUID
	ScheduleEnabled bool
}

type MergestatRepoSyncLog

type MergestatRepoSyncLog struct {
	ID              int64
	CreatedAt       time.Time
	LogType         string
	Message         string
	RepoSyncQueueID int64
}

type MergestatRepoSyncLogType

type MergestatRepoSyncLogType struct {
	Type        string
	Description sql.NullString
}

type MergestatRepoSyncQueue

type MergestatRepoSyncQueue struct {
	ID            int64
	CreatedAt     time.Time
	RepoSyncID    uuid.UUID
	Status        string
	StartedAt     sql.NullTime
	DoneAt        sql.NullTime
	LastKeepAlive sql.NullTime
	Priority      int32
}

type MergestatRepoSyncQueueStatusType

type MergestatRepoSyncQueueStatusType struct {
	Type        string
	Description sql.NullString
}

type MergestatRepoSyncType

type MergestatRepoSyncType struct {
	Type        string
	Description sql.NullString
	ShortName   string
}

type MergestatServiceAuthCredential added in v0.0.6

type MergestatServiceAuthCredential struct {
	ID          uuid.UUID
	CreatedAt   time.Time
	UpdatedAt   time.Time
	Type        string
	Credentials []byte
}

type MergestatServiceAuthCredentialType added in v0.0.6

type MergestatServiceAuthCredentialType struct {
	Type        string
	Description string
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CleanOldRepoSyncQueue added in v0.0.3

func (q *Queries) CleanOldRepoSyncQueue(ctx context.Context, dollar_1 int32) error

func (*Queries) DeleteGitHubRepoInfo

func (q *Queries) DeleteGitHubRepoInfo(ctx context.Context, repoID uuid.UUID) error

func (*Queries) DeleteRemovedRepos

func (q *Queries) DeleteRemovedRepos(ctx context.Context, arg DeleteRemovedReposParams) error

func (*Queries) DequeueSyncJob

func (q *Queries) DequeueSyncJob(ctx context.Context) (DequeueSyncJobRow, error)

func (*Queries) EnqueueAllSyncs

func (q *Queries) EnqueueAllSyncs(ctx context.Context) error

We use a CTE here to retrieve all the repo_sync_jobs that were previously enqueued, to make sure that we *do not* re-enqueue anything new until the previously enqueued jobs are *completed*. This allows us to make sure all repo syncs complete before we reschedule a new batch.

func (*Queries) GetRepoIDsFromRepoImport added in v0.1.0

func (q *Queries) GetRepoIDsFromRepoImport(ctx context.Context, arg GetRepoIDsFromRepoImportParams) ([]uuid.UUID, error)

func (*Queries) GetRepoImportByID

func (q *Queries) GetRepoImportByID(ctx context.Context, id uuid.UUID) (MergestatRepoImport, error)

func (*Queries) GetRepoUrlFromImport added in v0.1.0

func (q *Queries) GetRepoUrlFromImport(ctx context.Context, importid uuid.UUID) ([]string, error)

func (*Queries) InsertGitHubRepoInfo

func (q *Queries) InsertGitHubRepoInfo(ctx context.Context, arg InsertGitHubRepoInfoParams) error

func (*Queries) InsertNewDefaultSync added in v0.1.0

func (q *Queries) InsertNewDefaultSync(ctx context.Context, arg InsertNewDefaultSyncParams) error

func (*Queries) InsertSyncJobLog

func (q *Queries) InsertSyncJobLog(ctx context.Context, arg InsertSyncJobLogParams) error

func (*Queries) ListRepoImportsDueForImport

func (q *Queries) ListRepoImportsDueForImport(ctx context.Context) ([]ListRepoImportsDueForImportRow, error)

func (*Queries) MarkRepoImportAsUpdated

func (q *Queries) MarkRepoImportAsUpdated(ctx context.Context, id uuid.UUID) error

func (*Queries) MarkSyncsAsTimedOut

func (q *Queries) MarkSyncsAsTimedOut(ctx context.Context) ([]int64, error)

func (*Queries) SetLatestKeepAliveForJob

func (q *Queries) SetLatestKeepAliveForJob(ctx context.Context, id int64) error

func (*Queries) SetSyncJobStatus

func (q *Queries) SetSyncJobStatus(ctx context.Context, arg SetSyncJobStatusParams) error

func (*Queries) UpsertRepo

func (q *Queries) UpsertRepo(ctx context.Context, arg UpsertRepoParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type Repo

type Repo struct {
	ID                uuid.UUID
	Repo              string
	Ref               sql.NullString
	IsGithub          sql.NullBool
	CreatedAt         time.Time
	Settings          pgtype.JSONB
	Tags              pgtype.JSONB
	RepoImportID      uuid.NullUUID
	MergestatSyncedAt time.Time
}

Git repositories to track

type SetSyncJobStatusParams

type SetSyncJobStatusParams struct {
	Status string
	ID     int64
}

type TrivyRepoScan added in v0.0.6

type TrivyRepoScan struct {
	RepoID            uuid.UUID
	Results           pgtype.JSONB
	MergestatSyncedAt time.Time
}

type TrivyRepoVulnerability added in v0.0.6

type TrivyRepoVulnerability struct {
	RepoID                        uuid.UUID
	Vulnerability                 pgtype.JSONB
	Target                        interface{}
	Class                         interface{}
	Type                          interface{}
	VulnerabilityID               interface{}
	VulnerabilityPkgName          interface{}
	VulnerabilityInstalledVersion interface{}
	VulnerabilitySeverity         interface{}
	VulnerabilityTitle            interface{}
	VulnerabilityDescription      interface{}
	MergestatSyncedAt             time.Time
}

type UpsertRepoParams

type UpsertRepoParams struct {
	Repo         string
	IsGithub     sql.NullBool
	RepoImportID uuid.NullUUID
	Tags         pgtype.JSONB
}

Jump to

Keyboard shortcuts

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