Merge branch 'partmanIntvl115' of git.dynatron.me:amigan/stillbox into partmanIntvl115
This commit is contained in:
commit
ba8590b4fd
2 changed files with 44 additions and 5 deletions
|
@ -108,7 +108,7 @@ type AddCallParams struct {
|
|||
Frequency int `json:"frequency"`
|
||||
Frequencies []int `json:"frequencies"`
|
||||
Patches []int `json:"patches"`
|
||||
TalkerAlias *string `json:"talkerAlias"`
|
||||
TalkerAlias *string `json:"talkerAlias,omitempty"`
|
||||
TGLabel *string `json:"tgLabel"`
|
||||
TGAlphaTag *string `json:"tgAlphaTag"`
|
||||
TGGroup *string `json:"tgGroup"`
|
||||
|
@ -205,7 +205,7 @@ type GetCallRow struct {
|
|||
Frequency int `json:"frequency"`
|
||||
Frequencies []int `json:"frequencies"`
|
||||
Patches []int `json:"patches"`
|
||||
TalkerAlias *string `json:"talkerAlias"`
|
||||
TalkerAlias *string `json:"talkerAlias,omitempty"`
|
||||
TGLabel *string `json:"tgLabel"`
|
||||
TGAlphaTag *string `json:"tgAlphaTag"`
|
||||
TGGroup *string `json:"tgGroup"`
|
||||
|
@ -401,8 +401,8 @@ type ListCallsPRow struct {
|
|||
Duration *int32 `json:"duration"`
|
||||
SystemID int `json:"systemId"`
|
||||
TGID int `json:"tgid"`
|
||||
TalkerAlias *string `json:"talkerAlias"`
|
||||
Incidents int64 `json:"incidents"`
|
||||
TalkerAlias *string `json:"talkerAlias,omitempty"`
|
||||
Incidents int64 `json:"incidents,omitempty"`
|
||||
}
|
||||
|
||||
func (q *Queries) ListCallsP(ctx context.Context, arg ListCallsPParams) ([]ListCallsPRow, error) {
|
||||
|
|
|
@ -12,10 +12,46 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
const filePath = "./pkg/database/models.go"
|
||||
type FileMap map[string]FieldDecider
|
||||
|
||||
var filePaths = FileMap{
|
||||
"./pkg/database/models.go": AllFields{},
|
||||
"./pkg/database/calls.sql.go": FieldMap{
|
||||
"TalkerAlias": true,
|
||||
"Incidents": true,
|
||||
},
|
||||
}
|
||||
|
||||
type FieldDecider interface {
|
||||
Check(fields []*ast.Ident) bool
|
||||
}
|
||||
|
||||
type FieldMap map[string]bool
|
||||
|
||||
func (fm FieldMap) Check(f []*ast.Ident) bool {
|
||||
for _, v := range f {
|
||||
if v != nil && fm[v.Name] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
type AllFields struct{}
|
||||
|
||||
func (AllFields) Check(_ []*ast.Ident) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Parse the source code
|
||||
for k, v := range filePaths {
|
||||
process(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
func process(filePath string, fd FieldDecider) {
|
||||
fset := token.NewFileSet()
|
||||
f, err := parser.ParseFile(fset, filePath, nil, parser.ParseComments)
|
||||
if err != nil {
|
||||
|
@ -27,6 +63,9 @@ func main() {
|
|||
switch x := n.(type) {
|
||||
case *ast.StructType:
|
||||
for _, field := range x.Fields.List {
|
||||
if !fd.Check(field.Names) {
|
||||
continue
|
||||
}
|
||||
if field.Tag == nil {
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue