Adds select actions by plan function

This commit is contained in:
2020-12-29 19:10:54 -06:00
parent e6158e680f
commit acf793ae41
5 changed files with 88 additions and 11 deletions

View File

@@ -26,6 +26,16 @@ func (store *postgresStore) SelectActions() ([]*models.Action, error) {
return actions, nil
}
func (store *postgresStore) SelectActionsByPlanID(plan *models.Plan) ([]*models.Action, error) {
queryString := store.db.Rebind("SELECT action_id, action_description, estimated_chunks, completed_chunks, completed_on, created_at, updated_at, plan_id FROM actions WHERE plan_id = ?")
actions := make([]*models.Action, 0)
err := store.db.Select(&actions, queryString, plan.PlanID)
if err != nil {
return nil, err
}
return actions, nil
}
func (store *postgresStore) SelectActionByID(id int) (*models.Action, error) {
action := models.Action{}
err := store.db.Get(&action, store.db.Rebind("SELECT action_id, action_description, estimated_chunks, completed_chunks, completed_on, created_at, updated_at, plan_id FROM actions WHERE action_id = ?"), id)