generated from VLADIMIR/template
add stat and fix get place
This commit is contained in:
parent
dad8d1c3a2
commit
0fe8b77d12
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -17,7 +17,7 @@
|
|||||||
"buildFlags": "-tags local"
|
"buildFlags": "-tags local"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Local Launch",
|
"name": "Launch for tests",
|
||||||
"type": "go",
|
"type": "go",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"mode": "debug",
|
"mode": "debug",
|
||||||
|
|||||||
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -11,5 +11,9 @@
|
|||||||
"palces",
|
"palces",
|
||||||
"qrcode",
|
"qrcode",
|
||||||
"signintech"
|
"signintech"
|
||||||
|
],
|
||||||
|
"makefile.configureOnOpen": false,
|
||||||
|
"go.testFlags": [
|
||||||
|
"-count=1",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
33
.vscode/tasks.json
vendored
Normal file
33
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
|
// for the documentation about the tasks.json format
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "Gen Config",
|
||||||
|
"type": "shell",
|
||||||
|
"isBackground": true,
|
||||||
|
"command": "make generate",
|
||||||
|
"presentation": {
|
||||||
|
"reveal": "always",
|
||||||
|
"panel": "new"
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$go"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Tests",
|
||||||
|
"type": "shell",
|
||||||
|
"isBackground": true,
|
||||||
|
"command": "make test",
|
||||||
|
"presentation": {
|
||||||
|
"reveal": "always",
|
||||||
|
"panel": "new"
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$go"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -191,6 +191,8 @@ message GetGraphReq {}
|
|||||||
message GetGraphRsp {
|
message GetGraphRsp {
|
||||||
repeated Node nodes = 1;
|
repeated Node nodes = 1;
|
||||||
repeated Edge edges = 2;
|
repeated Edge edges = 2;
|
||||||
|
int32 countNodes = 3;
|
||||||
|
int32 countEdges = 4;
|
||||||
|
|
||||||
message Node {
|
message Node {
|
||||||
int32 id = 1;
|
int32 id = 1;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -183,7 +183,7 @@ func (s *Services) AddTeams(ctx context.Context, req *proto.AddTeamsReq) (*proto
|
|||||||
for _, team := range teams {
|
for _, team := range teams {
|
||||||
res = append(res, mapTeamsToTeamFull(team))
|
res = append(res, mapTeamsToTeamFull(team))
|
||||||
}
|
}
|
||||||
return &proto.AddTeamsRsp{Teams: res}, err
|
return &proto.AddTeamsRsp{Teams: res}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Services) DownloadTeamsQrCodesFile(ctx context.Context, req *proto.DownloadTeamsQrCodesFileReq) (*proto.DownloadTeamsQrCodesFileRsp, error) {
|
func (s *Services) DownloadTeamsQrCodesFile(ctx context.Context, req *proto.DownloadTeamsQrCodesFileReq) (*proto.DownloadTeamsQrCodesFileRsp, error) {
|
||||||
@ -218,8 +218,10 @@ func (s *Services) GetGraph(ctx context.Context, req *proto.GetGraphReq) (*proto
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
return &proto.GetGraphRsp{
|
return &proto.GetGraphRsp{
|
||||||
Nodes: nodes,
|
Nodes: nodes,
|
||||||
Edges: edges,
|
Edges: edges,
|
||||||
|
CountNodes: int32(len(nodes)),
|
||||||
|
CountEdges: int32(len(edges)),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -87,8 +87,13 @@ func (s *StoryService) GetPlace(code string) *Place {
|
|||||||
for _, place := range s.story.Places {
|
for _, place := range s.story.Places {
|
||||||
if clearCode(place.Code) == code {
|
if clearCode(place.Code) == code {
|
||||||
re := regexp.MustCompile(`\(\[[a-zA-Zа-яА-Я\d-]+\]\)`)
|
re := regexp.MustCompile(`\(\[[a-zA-Zа-яА-Я\d-]+\]\)`)
|
||||||
place.Text = re.ReplaceAllString(place.Text, "")
|
text := re.ReplaceAllString(place.Text, "")
|
||||||
return place
|
return &Place{
|
||||||
|
Code: place.Code,
|
||||||
|
Name: place.Name,
|
||||||
|
Text: text,
|
||||||
|
Applications: place.Applications,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &Place{
|
return &Place{
|
||||||
|
|||||||
@ -13,7 +13,7 @@ func TestGetApplication(t *testing.T) {
|
|||||||
defer close()
|
defer close()
|
||||||
|
|
||||||
createTeamResp, err := createTeam(client, "Тестовая команда")
|
createTeamResp, err := createTeam(client, "Тестовая команда")
|
||||||
assert.Nil(t, err, "запрос отправлену спешно")
|
assert.Nil(t, err, "запрос отправлен успешно")
|
||||||
|
|
||||||
team := createTeamResp.Teams[0]
|
team := createTeamResp.Teams[0]
|
||||||
|
|
||||||
|
|||||||
@ -79,3 +79,10 @@ func addAction(
|
|||||||
_, err := client.AddAction(ctx, req)
|
_, err := client.AddAction(ctx, req)
|
||||||
assert.Nil(t, err, "запрос отправлен успешно")
|
assert.Nil(t, err, "запрос отправлен успешно")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getGraph(client pb.EveningDetectiveClient) (*pb.GetGraphRsp, error) {
|
||||||
|
ctx, cancel := getContext()
|
||||||
|
defer cancel()
|
||||||
|
req := &pb.GetGraphReq{}
|
||||||
|
return client.GetGraph(ctx, req)
|
||||||
|
}
|
||||||
|
|||||||
18
internal/tests/statistics_test.go
Normal file
18
internal/tests/statistics_test.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package tests
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_StoryStatistics(t *testing.T) {
|
||||||
|
client, close := getClient()
|
||||||
|
defer close()
|
||||||
|
|
||||||
|
getGraphResp, err := getGraph(client)
|
||||||
|
assert.Nil(t, err, "запрос отправлен успешно")
|
||||||
|
|
||||||
|
assert.Equal(t, 5, int(getGraphResp.CountNodes))
|
||||||
|
assert.Equal(t, 3, int(getGraphResp.CountEdges))
|
||||||
|
}
|
||||||
@ -3,8 +3,32 @@
|
|||||||
{
|
{
|
||||||
"code": "Т-1",
|
"code": "Т-1",
|
||||||
"name": "Точка 1",
|
"name": "Точка 1",
|
||||||
"text": "Текст точки 1",
|
"text": "Текст точки 1([Т-2])([Т-3])",
|
||||||
"applications": [{ "name": "application 1" }]
|
"applications": [{ "name": "application 1" }]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "Т-2",
|
||||||
|
"name": "Точка 2",
|
||||||
|
"text": "Текст точки 2([Т-4])",
|
||||||
|
"applications": [{ "name": "application 2" }]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "Т-3",
|
||||||
|
"name": "Точка 3",
|
||||||
|
"text": "Текст точки 3",
|
||||||
|
"applications": [{ "name": "application 3" }]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "Т-4",
|
||||||
|
"name": "Точка 4",
|
||||||
|
"text": "Текст точки 4",
|
||||||
|
"applications": [{ "name": "application 4" }]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "Т-5",
|
||||||
|
"name": "Точка 5",
|
||||||
|
"text": "Текст точки 5",
|
||||||
|
"applications": [{ "name": "application 5" }]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1290,6 +1290,8 @@ type GetGraphRsp struct {
|
|||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
Nodes []*GetGraphRsp_Node `protobuf:"bytes,1,rep,name=nodes,proto3" json:"nodes,omitempty"`
|
Nodes []*GetGraphRsp_Node `protobuf:"bytes,1,rep,name=nodes,proto3" json:"nodes,omitempty"`
|
||||||
Edges []*GetGraphRsp_Edge `protobuf:"bytes,2,rep,name=edges,proto3" json:"edges,omitempty"`
|
Edges []*GetGraphRsp_Edge `protobuf:"bytes,2,rep,name=edges,proto3" json:"edges,omitempty"`
|
||||||
|
CountNodes int32 `protobuf:"varint,3,opt,name=countNodes,proto3" json:"countNodes,omitempty"`
|
||||||
|
CountEdges int32 `protobuf:"varint,4,opt,name=countEdges,proto3" json:"countEdges,omitempty"`
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
}
|
}
|
||||||
@ -1338,6 +1340,20 @@ func (x *GetGraphRsp) GetEdges() []*GetGraphRsp_Edge {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *GetGraphRsp) GetCountNodes() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.CountNodes
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetGraphRsp) GetCountEdges() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.CountEdges
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
type GetGraphRsp_Node struct {
|
type GetGraphRsp_Node struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
@ -1519,10 +1535,16 @@ const file_main_proto_rawDesc = "" +
|
|||||||
"\x1bDownloadTeamsQrCodesFileReq\"5\n" +
|
"\x1bDownloadTeamsQrCodesFileReq\"5\n" +
|
||||||
"\x1bDownloadTeamsQrCodesFileRsp\x12\x16\n" +
|
"\x1bDownloadTeamsQrCodesFileRsp\x12\x16\n" +
|
||||||
"\x06result\x18\x01 \x01(\fR\x06result\"\r\n" +
|
"\x06result\x18\x01 \x01(\fR\x06result\"\r\n" +
|
||||||
"\vGetGraphReq\"\x81\x02\n" +
|
"\vGetGraphReq\"\xc1\x02\n" +
|
||||||
"\vGetGraphRsp\x12?\n" +
|
"\vGetGraphRsp\x12?\n" +
|
||||||
"\x05nodes\x18\x01 \x03(\v2).crabs.evening_detective.GetGraphRsp.NodeR\x05nodes\x12?\n" +
|
"\x05nodes\x18\x01 \x03(\v2).crabs.evening_detective.GetGraphRsp.NodeR\x05nodes\x12?\n" +
|
||||||
"\x05edges\x18\x02 \x03(\v2).crabs.evening_detective.GetGraphRsp.EdgeR\x05edges\x1a,\n" +
|
"\x05edges\x18\x02 \x03(\v2).crabs.evening_detective.GetGraphRsp.EdgeR\x05edges\x12\x1e\n" +
|
||||||
|
"\n" +
|
||||||
|
"countNodes\x18\x03 \x01(\x05R\n" +
|
||||||
|
"countNodes\x12\x1e\n" +
|
||||||
|
"\n" +
|
||||||
|
"countEdges\x18\x04 \x01(\x05R\n" +
|
||||||
|
"countEdges\x1a,\n" +
|
||||||
"\x04Node\x12\x0e\n" +
|
"\x04Node\x12\x0e\n" +
|
||||||
"\x02id\x18\x01 \x01(\x05R\x02id\x12\x14\n" +
|
"\x02id\x18\x01 \x01(\x05R\x02id\x12\x14\n" +
|
||||||
"\x05label\x18\x02 \x01(\tR\x05label\x1aB\n" +
|
"\x05label\x18\x02 \x01(\tR\x05label\x1aB\n" +
|
||||||
|
|||||||
@ -487,6 +487,14 @@
|
|||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/definitions/GetGraphRspEdge"
|
"$ref": "#/definitions/GetGraphRspEdge"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"countNodes": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"countEdges": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int32"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user