2023-08-16 13:17:42 +03:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
2023-08-18 23:59:15 +03:00
|
|
|
"database/sql"
|
2023-08-16 13:17:42 +03:00
|
|
|
"time"
|
|
|
|
|
|
|
|
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
|
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Package struct {
|
2023-08-18 23:59:15 +03:00
|
|
|
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"`
|
|
|
|
LastCheck sql.NullTime `db:"last_check"`
|
2023-08-16 13:17:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewPackage(pkg *Package) *pb.Package {
|
2023-08-18 23:59:15 +03:00
|
|
|
rsp := &pb.Package{
|
2023-08-16 13:17:42 +03:00
|
|
|
Name: pkg.Name,
|
|
|
|
Url: pkg.URL,
|
|
|
|
Modules: pkg.Modules,
|
|
|
|
Issues: pkg.Issues,
|
|
|
|
Comments: pkg.Comments,
|
|
|
|
Id: pkg.ID,
|
|
|
|
Created: timestamppb.New(pkg.Created),
|
|
|
|
Updated: timestamppb.New(pkg.Updated),
|
|
|
|
}
|
2023-08-18 23:59:15 +03:00
|
|
|
if pkg.LastCheck.Valid {
|
|
|
|
rsp.LastCheck = timestamppb.New(pkg.LastCheck.Time)
|
|
|
|
}
|
|
|
|
return rsp
|
2023-08-16 13:17:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type Module struct {
|
2023-08-18 23:59:15 +03:00
|
|
|
Created time.Time `db:"created"`
|
|
|
|
Updated time.Time `db:"updated"`
|
2023-08-16 13:17:42 +03:00
|
|
|
Name string `db:"name"`
|
|
|
|
Version string `db:"version"`
|
|
|
|
LastVersion string `db:"last_version"`
|
|
|
|
ID uint64 `db:"id"`
|
|
|
|
Package uint64 `db:"package"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewModule(mod *Module) *pb.Module {
|
|
|
|
return &pb.Module{
|
|
|
|
Name: mod.Name,
|
|
|
|
Version: mod.Version,
|
|
|
|
LastVersion: mod.LastVersion,
|
|
|
|
Package: mod.Package,
|
|
|
|
Id: mod.ID,
|
|
|
|
Created: timestamppb.New(mod.Created),
|
|
|
|
Updated: timestamppb.New(mod.Updated),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type Issue struct {
|
2023-08-18 23:59:15 +03:00
|
|
|
Comment string `db:"comment"`
|
2023-08-16 13:17:42 +03:00
|
|
|
Modules []int64 `db:"modules"`
|
|
|
|
ID uint64 `db:"id"`
|
|
|
|
Status uint64 `db:"status"`
|
2023-08-18 23:59:15 +03:00
|
|
|
Package uint64 `db:"package"`
|
2023-08-16 13:17:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type Comment struct {
|
2023-08-18 23:59:15 +03:00
|
|
|
Created time.Time `db:"created"`
|
|
|
|
Updated time.Time `db:"updated"`
|
|
|
|
Comment string `db:"comment"`
|
|
|
|
ID uint64 `db:"id"`
|
2023-08-16 13:17:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewComment(com *Comment) *pb.Comment {
|
|
|
|
return &pb.Comment{
|
|
|
|
Id: com.ID,
|
2023-08-18 23:59:15 +03:00
|
|
|
Comment: com.Comment,
|
2023-08-16 13:17:42 +03:00
|
|
|
Created: timestamppb.New(com.Created),
|
|
|
|
Updated: timestamppb.New(com.Updated),
|
|
|
|
}
|
|
|
|
}
|