TP-55555 | cybertron ui (#13)
* TP-55555 | cybertron ui * TP-55555 clean up * TP-55555 clean up * TP-55555 | latest push
This commit is contained in:
49
service/searchService.go
Normal file
49
service/searchService.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"cybertron/internal/client/elastic"
|
||||
"cybertron/pkg/log"
|
||||
"github.com/elastic/go-elasticsearch/v8/typedapi/types"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type SearchService struct {
|
||||
logger *log.Logger
|
||||
elasticSearchClient *elastic.ElasticSearchClient
|
||||
}
|
||||
|
||||
func NewSearchService(logger *log.Logger, elasticSearchClient *elastic.ElasticSearchClient) *SearchService {
|
||||
return &SearchService{
|
||||
logger: logger,
|
||||
elasticSearchClient: elasticSearchClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SearchService) Search(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func (s *SearchService) GetErrorDetails(c *gin.Context) {
|
||||
documentId := c.Query("document_id")
|
||||
response, _ := s.elasticSearchClient.GetDocument(documentId)
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
func (s *SearchService) GetErrorList(c *gin.Context) {
|
||||
//todo pagination and aggregation of errors
|
||||
projectId := c.Query("project_id")
|
||||
println(projectId)
|
||||
query := &types.Query{
|
||||
Term: map[string]types.TermQuery{
|
||||
"project_id": {
|
||||
Value: projectId,
|
||||
},
|
||||
},
|
||||
}
|
||||
fields := []string{"error", "significant_stack", "title"}
|
||||
var response, _ = s.elasticSearchClient.SearchDocuments(query, fields)
|
||||
|
||||
c.JSON(http.StatusOK, response)
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user