add GetComments and update proto

This commit is contained in:
2023-08-14 14:27:29 +03:00
parent 85d1191dd9
commit 37e92e8473
16 changed files with 850 additions and 142 deletions

View File

@@ -1,7 +1,9 @@
package models
import (
"github.com/jackc/pgtype"
pb "go.unistack.org/unistack-org/pkgdash/proto"
"time"
)
type ListPackage []*Package
@@ -42,3 +44,28 @@ func (l ListModule) Decode() []*pb.Module {
return result
}
type ListComment []*Comment
func (l ListComment) Decode() []*pb.Comment {
result := make([]*pb.Comment, 0, len(l))
for i := range l {
temp := &pb.Comment{
Id: l[i].ID,
//Package: l[i].,
Text: l[i].Text,
}
if l[i].Created.Status == pgtype.Present {
temp.Created = l[i].Created.Time.Format(time.DateTime)
}
if l[i].Updated.Status == pgtype.Present {
temp.Updated = l[i].Updated.Time.Format(time.DateTime)
}
result = append(result, temp)
}
return result
}