@@ -8,20 +8,48 @@ import (
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
ID uint64 `db:"id"`
|
||||
Package uint64 `db:"package"`
|
||||
Name string `db:"name"`
|
||||
Coverage sql.NullFloat64 `db:"coverage"`
|
||||
}
|
||||
|
||||
func NewHandler(hdlr *Handler) *pb.Handler {
|
||||
if hdlr == nil {
|
||||
return nil
|
||||
}
|
||||
rsp := &pb.Handler{
|
||||
Id: hdlr.ID,
|
||||
Package: hdlr.Package,
|
||||
Name: hdlr.Name,
|
||||
}
|
||||
if hdlr.Coverage.Valid {
|
||||
rsp.Coverage = hdlr.Coverage.Float64
|
||||
}
|
||||
return rsp
|
||||
}
|
||||
|
||||
type Package struct {
|
||||
LastCheck sql.NullTime `db:"last_check"`
|
||||
Created time.Time `db:"created"`
|
||||
Updated time.Time `db:"updated"`
|
||||
Name string `db:"name"`
|
||||
URL string `db:"url"`
|
||||
Modules uint64 `db:"modules"`
|
||||
Issues uint64 `db:"issues"`
|
||||
Comments uint64 `db:"comments"`
|
||||
ID uint64 `db:"id"`
|
||||
Status uint64 `db:"status"`
|
||||
Created time.Time `db:"created"`
|
||||
Updated time.Time `db:"updated"`
|
||||
LastCheck sql.NullTime `db:"last_check"`
|
||||
Type string `db:"type"`
|
||||
Name string `db:"name"`
|
||||
URL string `db:"url"`
|
||||
Description sql.NullString `db:"description"`
|
||||
Coverage sql.NullFloat64 `db:"coverage"`
|
||||
Modules uint64 `db:"modules"`
|
||||
ID uint64 `db:"id"`
|
||||
Status uint64 `db:"status"`
|
||||
Comments uint64 `db:"comments"`
|
||||
Issues uint64 `db:"issues"`
|
||||
}
|
||||
|
||||
func NewPackage(pkg *Package) *pb.Package {
|
||||
if pkg == nil {
|
||||
return nil
|
||||
}
|
||||
rsp := &pb.Package{
|
||||
Name: pkg.Name,
|
||||
Url: pkg.URL,
|
||||
@@ -31,10 +59,20 @@ func NewPackage(pkg *Package) *pb.Package {
|
||||
Id: pkg.ID,
|
||||
Created: timestamppb.New(pkg.Created),
|
||||
Updated: timestamppb.New(pkg.Updated),
|
||||
Type: pkg.Type,
|
||||
}
|
||||
if rsp.Type == "" {
|
||||
rsp.Type = "package"
|
||||
}
|
||||
if pkg.Description.Valid {
|
||||
rsp.Description = pkg.Description.String
|
||||
}
|
||||
if pkg.LastCheck.Valid {
|
||||
rsp.LastCheck = timestamppb.New(pkg.LastCheck.Time)
|
||||
}
|
||||
if pkg.Coverage.Valid {
|
||||
rsp.Coverage = pkg.Coverage.Float64
|
||||
}
|
||||
return rsp
|
||||
}
|
||||
|
||||
@@ -46,6 +84,9 @@ type Module struct {
|
||||
}
|
||||
|
||||
func NewModule(mod *Module) *pb.Module {
|
||||
if mod == nil {
|
||||
return nil
|
||||
}
|
||||
rsp := &pb.Module{
|
||||
Name: mod.Name,
|
||||
Version: mod.Version,
|
||||
@@ -73,6 +114,9 @@ type Comment struct {
|
||||
}
|
||||
|
||||
func NewComment(com *Comment) *pb.Comment {
|
||||
if com == nil {
|
||||
return nil
|
||||
}
|
||||
return &pb.Comment{
|
||||
Id: com.ID,
|
||||
Comment: com.Comment,
|
||||
|
Reference in New Issue
Block a user