mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 01:15:22 +00:00
26dc30bd25
- Add new Apply spec methods for queries and packs - Remove now extraneous datastore/service methods - Remove import service (unused, and had many dependencies that this breaks) - Refactor tests as appropriate
29 lines
730 B
Go
29 lines
730 B
Go
package mysql
|
|
|
|
import (
|
|
"github.com/kolide/fleet/server/kolide"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func (d *Datastore) ListScheduledQueriesInPack(id uint, opts kolide.ListOptions) ([]*kolide.ScheduledQuery, error) {
|
|
query := `
|
|
SELECT
|
|
sq.id, sq.pack_id, sq.name, sq.query_name, q.query,
|
|
sq.description, sq.interval, sq.snapshot, sq.removed, sq.platform,
|
|
sq.version, sq.shard
|
|
FROM scheduled_queries sq
|
|
JOIN queries q
|
|
ON sq.query_name = q.name
|
|
WHERE sq.pack_id = ?
|
|
AND NOT sq.deleted
|
|
`
|
|
query = appendListOptionsToSQL(query, opts)
|
|
results := []*kolide.ScheduledQuery{}
|
|
|
|
if err := d.db.Select(&results, query, id); err != nil {
|
|
return nil, errors.Wrap(err, "listing scheduled queries")
|
|
}
|
|
|
|
return results, nil
|
|
}
|