add stat and fix get place

This commit is contained in:
2025-12-06 16:50:06 +07:00
parent dad8d1c3a2
commit 0fe8b77d12
13 changed files with 136 additions and 11 deletions
+5 -3
View File
@@ -183,7 +183,7 @@ func (s *Services) AddTeams(ctx context.Context, req *proto.AddTeamsReq) (*proto
for _, team := range teams {
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) {
@@ -218,8 +218,10 @@ func (s *Services) GetGraph(ctx context.Context, req *proto.GetGraphReq) (*proto
})
}
return &proto.GetGraphRsp{
Nodes: nodes,
Edges: edges,
Nodes: nodes,
Edges: edges,
CountNodes: int32(len(nodes)),
CountEdges: int32(len(edges)),
}, nil
}
+7 -2
View File
@@ -87,8 +87,13 @@ func (s *StoryService) GetPlace(code string) *Place {
for _, place := range s.story.Places {
if clearCode(place.Code) == code {
re := regexp.MustCompile(`\(\[[a-zA-Zа-яА-Я\d-]+\]\)`)
place.Text = re.ReplaceAllString(place.Text, "")
return place
text := re.ReplaceAllString(place.Text, "")
return &Place{
Code: place.Code,
Name: place.Name,
Text: text,
Applications: place.Applications,
}
}
}
return &Place{
+1 -1
View File
@@ -13,7 +13,7 @@ func TestGetApplication(t *testing.T) {
defer close()
createTeamResp, err := createTeam(client, "Тестовая команда")
assert.Nil(t, err, "запрос отправлену спешно")
assert.Nil(t, err, "запрос отправлен успешно")
team := createTeamResp.Teams[0]
+7
View File
@@ -79,3 +79,10 @@ func addAction(
_, err := client.AddAction(ctx, req)
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
View 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))
}
+25 -1
View File
@@ -3,8 +3,32 @@
{
"code": "Т-1",
"name": "Точка 1",
"text": "Текст точки 1",
"text": "Текст точки 1([Т-2])([Т-3])",
"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" }]
}
]
}