SQLStore: customise the limit of retrieved datasources per organisation (#29358)
* SQLStore: customise the limit of retrieved datasources per organisation * update all suggestions regarding nil or 0 as default * Apply suggestions from code review Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com> * correct default.ini description + adding unittest * Apply suggestions from code review Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com> * modify unittest name Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com> Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
This commit is contained in:
co-authored by
Emil Tullstedt
Sofia Papagiannaki
parent
ac922f4e1d
commit
375e8e4fd0
@@ -67,8 +67,12 @@ func GetDataSourceByName(query *models.GetDataSourceByNameQuery) error {
|
||||
}
|
||||
|
||||
func GetDataSources(query *models.GetDataSourcesQuery) error {
|
||||
sess := x.Limit(5000, 0).Where("org_id=?", query.OrgId).Asc("name")
|
||||
|
||||
var sess *xorm.Session
|
||||
if query.DataSourceLimit <= 0 {
|
||||
sess = x.Where("org_id=?", query.OrgId).Asc("name")
|
||||
} else {
|
||||
sess = x.Limit(query.DataSourceLimit, 0).Where("org_id=?", query.OrgId).Asc("name")
|
||||
}
|
||||
query.Result = make([]*models.DataSource, 0)
|
||||
return sess.Find(&query.Result)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user