use worker

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2023-08-18 23:59:15 +03:00
parent 78f0ae14d7
commit 0e18a63f10
46 changed files with 2195 additions and 1181 deletions

View File

@@ -1,6 +1,7 @@
package models
import (
"database/sql"
"time"
pb "git.unistack.org/unistack-org/pkgdash/proto"
@@ -8,18 +9,20 @@ import (
)
type Package struct {
Name string `db:"name" json:"name"`
URL string `db:"url" json:"url"`
Modules []uint64 `db:"modules" json:"modules"`
Issues []uint64 `db:"issues" json:"issues,omitempty"`
Comments []uint64 `db:"comments" json:"comments,omitempty"`
ID uint64 `db:"id" json:"id"`
Created time.Time `db:"created" json:"created"`
Updated time.Time `db:"updated" json:"updated,omitempty"`
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"`
}
func NewPackage(pkg *Package) *pb.Package {
return &pb.Package{
rsp := &pb.Package{
Name: pkg.Name,
Url: pkg.URL,
Modules: pkg.Modules,
@@ -29,16 +32,20 @@ func NewPackage(pkg *Package) *pb.Package {
Created: timestamppb.New(pkg.Created),
Updated: timestamppb.New(pkg.Updated),
}
if pkg.LastCheck.Valid {
rsp.LastCheck = timestamppb.New(pkg.LastCheck.Time)
}
return rsp
}
type Module struct {
Created time.Time `db:"created"`
Updated time.Time `db:"updated"`
Name string `db:"name"`
Version string `db:"version"`
LastVersion string `db:"last_version"`
ID uint64 `db:"id"`
Package uint64 `db:"package"`
Created time.Time `db:"created" json:"created"`
Updated time.Time `db:"updated" json:"updated,omitempty"`
}
func NewModule(mod *Module) *pb.Module {
@@ -54,24 +61,24 @@ func NewModule(mod *Module) *pb.Module {
}
type Issue struct {
Desc string `db:"desc"`
Comment string `db:"comment"`
Modules []int64 `db:"modules"`
ID uint64 `db:"id"`
Status uint64 `db:"status"`
Package int64 `db:"package"`
Package uint64 `db:"package"`
}
type Comment struct {
Created time.Time `db:"created" json:"created"`
Updated time.Time `db:"updated" json:"updated,omitempty"`
Text string `db:"value" json:"text"`
ID uint64 `db:"id" json:"id"`
Created time.Time `db:"created"`
Updated time.Time `db:"updated"`
Comment string `db:"comment"`
ID uint64 `db:"id"`
}
func NewComment(com *Comment) *pb.Comment {
return &pb.Comment{
Id: com.ID,
Text: com.Text,
Comment: com.Comment,
Created: timestamppb.New(com.Created),
Updated: timestamppb.New(com.Updated),
}