feat(assist-api): added data field to response

This commit is contained in:
Alexander 2025-04-15 15:49:52 +02:00
parent 25adc0410d
commit fee79521a1
2 changed files with 9 additions and 6 deletions

View file

@ -169,7 +169,10 @@ func (e *handlersImpl) socketsLiveByProject(w http.ResponseWriter, r *http.Reque
return
}
e.log.Debug(context.Background(), "socketsLiveByProject request, filters: %v, projectKey: %s, response: %v", req, projectKey, resp)
e.responser.ResponseWithJSON(e.log, r.Context(), w, resp, startTime, r.URL.Path, bodySize)
response := map[string]interface{}{
"data": resp,
}
e.responser.ResponseWithJSON(e.log, r.Context(), w, response, startTime, r.URL.Path, bodySize)
}
func (e *handlersImpl) socketsLiveBySession(w http.ResponseWriter, r *http.Request) {

View file

@ -44,7 +44,7 @@ type SessionManager interface {
Start()
Stop()
GetByID(projectID, sessionID string) (*SessionData, error)
GetAll(projectID string, filters []*Filter, sort SortOrder, page, limit int) ([]*SessionData, int, map[string]map[string]int, error)
GetAll(projectID string, filters []*Filter, sort SortOrder, page, limit int) ([]string, int, map[string]map[string]int, error)
Autocomplete(projectID string, key FilterType, value string) ([]string, error)
}
@ -375,7 +375,7 @@ func (sm *sessionManagerImpl) GetByID(projectID, sessionID string) (*SessionData
return sessionData, nil
}
func (sm *sessionManagerImpl) GetAll(projectID string, filters []*Filter, sort SortOrder, page, limit int) ([]*SessionData, int, map[string]map[string]int, error) {
func (sm *sessionManagerImpl) GetAll(projectID string, filters []*Filter, sort SortOrder, page, limit int) ([]string, int, map[string]map[string]int, error) {
if page < 1 || limit < 1 {
page, limit = 1, 10 // Set default values
}
@ -393,21 +393,21 @@ func (sm *sessionManagerImpl) GetAll(projectID string, filters []*Filter, sort S
counter[string(filter.Type)][value] = 0
}
}
filtered := make([]*SessionData, 0, limit)
filtered := make([]string, 0, limit)
for _, session := range sm.sorted {
sm.log.Info(sm.ctx, "projectID: %s, sessionID: %s", session.ProjectID, session.SessionID)
if session.ProjectID != projectID {
continue
}
if matchesFilters(session, filters, counter) {
filtered = append(filtered, session)
filtered = append(filtered, session.Raw)
}
}
start := (page - 1) * limit
end := start + limit
if start > len(filtered) {
return []*SessionData{}, 0, make(map[string]map[string]int), nil
return []string{}, 0, make(map[string]map[string]int), nil
}
if end > len(filtered) {
end = len(filtered)