Documentation ¶
Index ¶
- func QueryForModelReviews(q *gorm.DB, modelID uint) *gorm.DB
- func QueryForReviews(q *gorm.DB) *gorm.DB
- func ToReviewStatus(status ReviewStatus) fuel.Review_ReviewStatus
- type CreateModelReview
- type CreateReview
- type ModelReview
- type ModelReviews
- type Protobuffer
- type Review
- type ReviewStatus
- type Reviews
- type Service
- func (s *Service) CreateModelReview(cmr CreateModelReview, tx *gorm.DB, creator *users.User) (*ModelReview, *gz.ErrMsg)
- func (s *Service) GetResourceInstance() interface{}
- func (s *Service) GetResourceSlice(len int, cap int) interface{}
- func (s *Service) ReviewList(p *gz.PaginationRequest, tx *gorm.DB, owner *string, order, search string, ...) (interface{}, *gz.PaginationResult, *gz.ErrMsg)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func QueryForModelReviews ¶
QueryForModelReviews returns a list of reviews for a selected model using modelID requested by the user
func QueryForReviews ¶
QueryForReviews returns a gorm query configured to query Reviews
func ToReviewStatus ¶
func ToReviewStatus(status ReviewStatus) fuel.Review_ReviewStatus
ToReviewStatus converts ReviewStatus type to fuel ReviewStatus enum
Types ¶
type CreateModelReview ¶
type CreateModelReview struct { // relay all fields from CreateReview struct CreateReview // Model ID under review ModelID *uint }
CreateModelReview contains information for creating a review for a model
type CreateReview ¶
type CreateReview struct { // Owner of the model. Must be a user or an org // If not set, the current user will be used as the owner Owner string `json:"owner" form:"owner"` // Reviewers for the review Reviewers []string `json:"reviewers" validate:"omitempty" form:"reviewers"` // Approvals for the review Approvals []string `json:"approvals" validate:"omitempty" form:"approvals"` // Description of the review Description string `json:"description" form:"description"` // Branch associated with the review Branch *string `json:"branch" validate:"omitempty" form:"branch"` // Status of the review Status ReviewStatus `json:"status" form:"status"` // Title of the review // required: true Title string `json:"title" validate:"required,noforwardslash,nopercent" form:"title"` }
CreateReview encapulates data required to create a review
type ModelReview ¶
type ModelReview struct { // Review for a model Review // ModelID that is under review ModelID *uint }
ModelReview contains information to create a review for a model
func NewModelReview ¶
func NewModelReview(title, description, owner, branch *string, status ReviewStatus, reviewers, approvals []string, modelID *uint) (ModelReview, error)
NewModelReview creates a new Review struct
func (*ModelReview) ToProto ¶
func (mr *ModelReview) ToProto() interface{}
ToProto creates a new 'fuel.Review' from the given review.
type Protobuffer ¶
type Protobuffer interface { // This method returns a protobuf representation of the object // Note: consider using proto.Message interface instead of just an empty // interface as ToProto return data type. // https://godoc.org/github.com/golang/protobuf/proto#Message ToProto() interface{} }
Protobuffer should be implemented by resources that have a protobuf representation. It provides methods to convert to a protobuf representation.
type Review ¶
type Review struct { // ID of the review // Overrides the default GORM Review fields ID uint `gorm:"primary_key" json:"-"` CreatedAt time.Time `gorm:"type:timestamp(3) NULL"` UpdatedAt time.Time // Creator contains the username of the User that created this model (usually // got from the JWT) Creator *string `json:"creator,omitempty"` // Title of the review (max 65,535 chars) Title *string `gorm:"type:text" json:"title,omitempty"` // Description of the review (max 65,535 chars) // Interesting post about TEXT vs VARCHAR(30000) performance: // https://nicj.net/mysql-text-vs-varchar-performance/ Description *string `gorm:"type:text" json:"description,omitempty"` // Owner of this review Owner *string `json:"owner,omitempty"` // Branch associated with this review Branch *string `json:"branch,omitempty"` // Status of the review Status ReviewStatus `json:"status,omitempty"` // Reviewers for the review Reviewers []string `gorm:"-" json:"reviewers,omitempty"` // Approvals for the review Approvals []string `gorm:"-" json:"approvals,omitempty"` // Private - True to make this a private resource Private *bool `gorm:"default:true" json:"private,omitempty"` }
Review contains changes proposed for a resource
A review contains changes for a resource such as a model or a world. It is also known as a pull request.
swagger:review dbReview
type ReviewStatus ¶
type ReviewStatus int
const ( // Open means review is still active ReviewOpen ReviewStatus = iota // Merged means reivew has been merged ReviewMerged // Merged means reivew is closed without being merged ReviewClosed )
type Service ¶
Service is the main struct exported by this Reviews Service. It was meant as a way to structure code and help future extensions.
func (*Service) CreateModelReview ¶
func (s *Service) CreateModelReview(cmr CreateModelReview, tx *gorm.DB, creator *users.User) (*ModelReview, *gz.ErrMsg)
CreateModelReview creates a new model review
func (*Service) GetResourceInstance ¶
func (s *Service) GetResourceInstance() interface{}
GetResourceInstance returns an instance of the type contained in ResourceType.
func (*Service) GetResourceSlice ¶
GetResourceSlice returns a slice of the type contained in ResourceType.
func (*Service) ReviewList ¶
func (s *Service) ReviewList(p *gz.PaginationRequest, tx *gorm.DB, owner *string, order, search string, modelID *uint, user *users.User) (interface{}, *gz.PaginationResult, *gz.ErrMsg)
ReviewList returns a paginated list of reviews. This function returns a list of Reviews that can then be mashalled into json or protobuf.