generated from VLADIMIR/template
update and fix
This commit is contained in:
@@ -53,10 +53,7 @@ func (s *Services) AddAction(ctx context.Context, req *proto.AddActionReq) (*pro
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
place, err := s.storyService.GetPlace(req.Place)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
place := s.storyService.GetPlace(req.Place)
|
||||
actions := []*models.Action{
|
||||
{
|
||||
Place: place.Code,
|
||||
@@ -87,10 +84,7 @@ func (s *Services) GetTeam(ctx context.Context, req *proto.GetTeamReq) (*proto.G
|
||||
res := make([]*proto.Action, 0, len(actions))
|
||||
for _, action := range actions {
|
||||
newAction := mapActionToProtoAction(action)
|
||||
place, err := s.storyService.GetPlace(action.Place)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
place := s.storyService.GetPlace(action.Place)
|
||||
newAction.Text = place.Text
|
||||
newAction.Name = place.Name
|
||||
newAction.Applications = make([]*proto.Application, 0, len(place.Applications))
|
||||
@@ -125,7 +119,7 @@ func (s *Services) GetTeams(ctx context.Context, _ *proto.GetTeamsReq) (*proto.G
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
newTeam.SpendTime = int64(20 * len(actions))
|
||||
newTeam.SpendTime = int64(len(actions))
|
||||
applications, err := s.repository.GetApplications(ctx, team.ID, "NEW")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -2,7 +2,6 @@ package story_service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
@@ -56,14 +55,18 @@ func NewStoryService() (*StoryService, error) {
|
||||
return &StoryService{story: story}, nil
|
||||
}
|
||||
|
||||
func (s *StoryService) GetPlace(code string) (*Place, error) {
|
||||
func (s *StoryService) GetPlace(code string) *Place {
|
||||
code = clearCode(code)
|
||||
for _, place := range s.story.Places {
|
||||
if clearCode(place.Code) == code {
|
||||
return place, nil
|
||||
return place
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("place not found: %s", code)
|
||||
return &Place{
|
||||
Code: code,
|
||||
Name: "Не найдено",
|
||||
Text: "Такой точки не существует.",
|
||||
}
|
||||
}
|
||||
|
||||
func clearCode(code string) string {
|
||||
|
||||
Reference in New Issue
Block a user