forked from TranSign-STAC/Back-End
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtranslationHistory.go
More file actions
35 lines (28 loc) · 1.09 KB
/
translationHistory.go
File metadata and controls
35 lines (28 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package controllers
import (
"context"
"transign/cmd/server/models"
"transign/configs"
pb "transign/gen"
)
// TranslationHistoryServer has methods for service translationHistory
type TranslationHistoryServer struct {
pb.UnimplementedTranslationHistoryServer
}
// GetHistory is a function for handling retrieving list of history request
func (s *TranslationHistoryServer) GetHistory(ctx context.Context, in *pb.UUIDMessage) (*pb.TranslationHistoryResponse, error) {
var translations []models.Translation
var requestHistory []*pb.TextToSignLangRequest
if in.Uuid == "" {
requestHistory = make([]*pb.TextToSignLangRequest, 0)
response := &pb.TranslationHistoryResponse{History: requestHistory}
return response, nil
}
configs.DB.Where(&models.Translation{UUID: in.Uuid}).Find(&translations)
requestHistory = make([]*pb.TextToSignLangRequest, len(translations))
for i, translation := range translations {
requestHistory[i] = &pb.TextToSignLangRequest{Uuid: translation.UUID, Text: translation.Text}
}
response := &pb.TranslationHistoryResponse{History: requestHistory}
return response, nil
}