Semaphore/db/bolt/view.go

42 lines
1.1 KiB
Go
Raw Normal View History

2021-10-26 20:19:12 +02:00
package bolt
import "github.com/ansible-semaphore/semaphore/db"
func (d *BoltDb) GetView(projectID int, viewID int) (view db.View, err error) {
err = d.getObject(projectID, db.ViewProps, intObjectID(viewID), &view)
2021-10-26 20:19:12 +02:00
return
}
func (d *BoltDb) GetViews(projectID int) (views []db.View, err error) {
err = d.getObjects(projectID, db.ViewProps, db.RetrieveQueryParams{}, nil, &views)
2021-10-26 20:19:12 +02:00
return
}
func (d *BoltDb) UpdateView(view db.View) error {
return d.updateObject(view.ProjectID, db.ViewProps, view)
2021-10-26 20:19:12 +02:00
}
func (d *BoltDb) CreateView(view db.View) (db.View, error) {
newView, err := d.createObject(view.ProjectID, db.ViewProps, view)
return newView.(db.View), err
2021-10-26 20:19:12 +02:00
}
func (d *BoltDb) DeleteView(projectID int, viewID int) error {
return d.deleteObject(projectID, db.ViewProps, intObjectID(viewID), nil)
}
func (d *BoltDb) SetViewPositions(projectID int, positions map[int]int) error {
2021-10-27 14:15:36 +02:00
for id, position := range positions {
2021-10-27 13:58:45 +02:00
view, err := d.GetView(projectID, id)
if err != nil {
return err
}
view.Position = position
err = d.UpdateView(view)
if err != nil {
return err
}
}
2021-10-26 20:19:12 +02:00
return nil
}