Move SignedInUser to user service and RoleType and Roles to org (#53445)
* Move SignedInUser to user service and RoleType and Roles to org * Use go naming convention for roles * Fix some imports and leftovers * Fix ldap debug test * Fix lint * Fix lint 2 * Fix lint 3 * Fix type and not needed conversion * Clean up messages in api tests * Clean up api tests 2
This commit is contained in:
@@ -6,13 +6,13 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
)
|
||||
|
||||
// createQuery adds a query into query history
|
||||
func (s QueryHistoryService) createQuery(ctx context.Context, user *models.SignedInUser, cmd CreateQueryInQueryHistoryCommand) (QueryHistoryDTO, error) {
|
||||
func (s QueryHistoryService) createQuery(ctx context.Context, user *user.SignedInUser, cmd CreateQueryInQueryHistoryCommand) (QueryHistoryDTO, error) {
|
||||
queryHistory := QueryHistory{
|
||||
OrgID: user.OrgId,
|
||||
UID: util.GenerateShortUID(),
|
||||
@@ -45,7 +45,7 @@ func (s QueryHistoryService) createQuery(ctx context.Context, user *models.Signe
|
||||
}
|
||||
|
||||
// searchQueries searches for queries in query history based on provided parameters
|
||||
func (s QueryHistoryService) searchQueries(ctx context.Context, user *models.SignedInUser, query SearchInQueryHistoryQuery) (QueryHistorySearchResult, error) {
|
||||
func (s QueryHistoryService) searchQueries(ctx context.Context, user *user.SignedInUser, query SearchInQueryHistoryQuery) (QueryHistorySearchResult, error) {
|
||||
var dtos []QueryHistoryDTO
|
||||
var allQueries []interface{}
|
||||
|
||||
@@ -109,7 +109,7 @@ func (s QueryHistoryService) searchQueries(ctx context.Context, user *models.Sig
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (s QueryHistoryService) deleteQuery(ctx context.Context, user *models.SignedInUser, UID string) (int64, error) {
|
||||
func (s QueryHistoryService) deleteQuery(ctx context.Context, user *user.SignedInUser, UID string) (int64, error) {
|
||||
var queryID int64
|
||||
err := s.SQLStore.WithTransactionalDbSession(ctx, func(session *sqlstore.DBSession) error {
|
||||
// Try to unstar the query first
|
||||
@@ -135,7 +135,7 @@ func (s QueryHistoryService) deleteQuery(ctx context.Context, user *models.Signe
|
||||
}
|
||||
|
||||
// patchQueryComment searches updates comment for query in query history
|
||||
func (s QueryHistoryService) patchQueryComment(ctx context.Context, user *models.SignedInUser, UID string, cmd PatchQueryCommentInQueryHistoryCommand) (QueryHistoryDTO, error) {
|
||||
func (s QueryHistoryService) patchQueryComment(ctx context.Context, user *user.SignedInUser, UID string, cmd PatchQueryCommentInQueryHistoryCommand) (QueryHistoryDTO, error) {
|
||||
var queryHistory QueryHistory
|
||||
var isStarred bool
|
||||
|
||||
@@ -180,7 +180,7 @@ func (s QueryHistoryService) patchQueryComment(ctx context.Context, user *models
|
||||
}
|
||||
|
||||
// starQuery adds query into query_history_star table together with user_id and org_id
|
||||
func (s QueryHistoryService) starQuery(ctx context.Context, user *models.SignedInUser, UID string) (QueryHistoryDTO, error) {
|
||||
func (s QueryHistoryService) starQuery(ctx context.Context, user *user.SignedInUser, UID string) (QueryHistoryDTO, error) {
|
||||
var queryHistory QueryHistory
|
||||
var isStarred bool
|
||||
|
||||
@@ -230,7 +230,7 @@ func (s QueryHistoryService) starQuery(ctx context.Context, user *models.SignedI
|
||||
}
|
||||
|
||||
// unstarQuery deletes query with with user_id and org_id from query_history_star table
|
||||
func (s QueryHistoryService) unstarQuery(ctx context.Context, user *models.SignedInUser, UID string) (QueryHistoryDTO, error) {
|
||||
func (s QueryHistoryService) unstarQuery(ctx context.Context, user *user.SignedInUser, UID string) (QueryHistoryDTO, error) {
|
||||
var queryHistory QueryHistory
|
||||
var isStarred bool
|
||||
|
||||
@@ -273,7 +273,7 @@ func (s QueryHistoryService) unstarQuery(ctx context.Context, user *models.Signe
|
||||
}
|
||||
|
||||
// migrateQueries adds multiple queries into query history
|
||||
func (s QueryHistoryService) migrateQueries(ctx context.Context, user *models.SignedInUser, cmd MigrateQueriesToQueryHistoryCommand) (int, int, error) {
|
||||
func (s QueryHistoryService) migrateQueries(ctx context.Context, user *user.SignedInUser, cmd MigrateQueriesToQueryHistoryCommand) (int, int, error) {
|
||||
queryHistories := make([]*QueryHistory, 0, len(cmd.Queries))
|
||||
starredQueries := make([]*QueryHistoryStar, 0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user