models

package
v0.0.0-...-3f45c39 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// InProgress is when the report generation is in-progress.
	InProgress = iota
	// Complete is when the report generation is complete.
	Complete
	// Failed is when the report generation failed.
	Failed
)

Variables

This section is empty.

Functions

func AddRepo

func AddRepo(r *Repository) (err error)

AddRepo adds a new Repository to the database. It returns the columns affected and error (if exists).

func AddReport

func AddReport(r *Report) (err error)

AddReport adds a new report to the database. Returns an error if fails.

func HasReport

func HasReport(repoID string, commit string) bool

HasReport returns whether a specific report is in the database.

func SetupEngine

func SetupEngine() *xorm.Engine

SetupEngine sets up the xorm engine according to the database configuration, and syncs the schema.

func SetupTestEngine

func SetupTestEngine()

func UpdateIssues

func UpdateIssues(r *Report) (err error)

UpdateIssues updates or inserts the issues of a report in the database.

func UpdateRepo

func UpdateRepo(r *Repository) (err error)

UpdateRepo updates a Repository in the database. It returns the columns affected and error (if exists).

func UpdateReport

func UpdateReport(r *Report) (err error)

UpdateReport updates an existing report in the database. Returns an error if fails.

Types

type Issue

type Issue struct {
	IssueID       int    `xorm:"autoincr pk"`
	ReportID      int64  `xorm:"notnull"`
	CheckName     string `xorm:"varchar(16) notnull"`
	FilePath      string `xorm:"varchar(32) notnull"`
	LineNumber    int    `xorm:"null"`
	ColumnNumber  int    `xorm:"null"`
	Description   string `xorm:"varchar(128) notnull"`
	SourceSnippet string `xorm:"text null"`
}

Issue represents a single issue, which is usually a part of a Report along with other Issues.

type Report

type Report struct {
	ReportID     int64        `xorm:"pk autoincr"`
	RepositoryID string       `xorm:"varchar(64) notnull"`
	Commit       string       `xorm:"index varchar(40) notnull"`
	Status       ReportStatus `xorm:"notnull"`
	CreatedUnix  int64        `xorm:"created"`
	Issues       []*Issue     `xorm:"-"`
}

Report represents a report of a specific commit of a project.

func (*Report) LoadIssues

func (r *Report) LoadIssues() (err error)

LoadIssues loads all issues in a report.

type ReportStatus

type ReportStatus int

ReportStatus represents the generation status of a report.

type Repository

type Repository struct {
	RepoID       string    `xorm:"varchar(64) pk"`
	IssueID      int       `xorm:"null"` // stored id of the main issue for checkstyle report
	SecretKey    string    `xorm:"varchar(32) null"`
	LatestCommit string    `xorm:"varchar(40) null"`
	Reports      []*Report `xorm:"-"`
}

Repository represents a specific GitLab project. It keeps track of the issue tracker post and all the reports of that specific repository.

func GetRepo

func GetRepo(id string) (*Repository, error)

GetRepo returns the repository from the project ID. It returns the repository and error (if exists).

func (*Repository) GetReport

func (r *Repository) GetReport(sha string) (*Report, bool)

GetReport returns the report and whether it exists or not based on the commit SHA.

Jump to

Keyboard shortcuts

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