fleet/server/datastore/mysql/scheduled_queries.go
Zachary Wasserman 26dc30bd25
Update query and pack interfaces for fleetctl (#1670)
- 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
2018-01-03 11:18:05 -08:00

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
}