Query history: Create API to star and unstar query in query history (#45077)

* Query history: Add starring and unstarring API

* Return dto with starred info when commenting

* Add documentation for starring and unstarring of query

* Return dto when starring/unstarring

* Update documentation

* Update deleting with unstarring

* Check queryUID length in queryhistory

* Fix linting issues

* Update docs/sources/http_api/query_history.md

Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>

* Update docs/sources/http_api/query_history.md

Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>

Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>
This commit is contained in:
Ivana Huckova
2022-02-23 17:03:04 +01:00
committed by GitHub
co-authored by Piotr Jamróz
parent 3cfbbbdbf2
commit a3a852be81
10 changed files with 369 additions and 9 deletions
@@ -78,6 +78,7 @@ func (*OSSMigrations) AddMigration(mg *Migrator) {
accesscontrol.AddTeamMembershipMigrations(mg)
}
}
addQueryHistoryStarMigrations(mg)
if mg.Cfg != nil && mg.Cfg.IsFeatureToggleEnabled != nil {
if mg.Cfg.IsFeatureToggleEnabled(featuremgmt.FlagDashboardComments) || mg.Cfg.IsFeatureToggleEnabled(featuremgmt.FlagAnnotationComments) {
@@ -0,0 +1,23 @@
package migrations
import (
. "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
)
func addQueryHistoryStarMigrations(mg *Migrator) {
queryHistoryStarV1 := Table{
Name: "query_history_star",
Columns: []*Column{
{Name: "id", Type: DB_BigInt, Nullable: false, IsPrimaryKey: true, IsAutoIncrement: true},
{Name: "query_uid", Type: DB_NVarchar, Length: 40, Nullable: false},
{Name: "user_id", Type: DB_Int, Nullable: false},
},
Indices: []*Index{
{Cols: []string{"user_id", "query_uid"}, Type: UniqueIndex},
},
}
mg.AddMigration("create query_history_star table v1", NewAddTableMigration(queryHistoryStarV1))
mg.AddMigration("add index query_history.user_id-query_uid", NewAddIndexMigration(queryHistoryStarV1, queryHistoryStarV1.Indices[0]))
}