feat(judgement,approvals,governance,ui): a class earns a raise after N approvals and drops on denial or failure; a freeze holds changing actions (#2004)
This commit is contained in:
17 files changed
+1185
-58
No files matched your search
@@ -62,6 +62,11 @@ type Settings struct {
|
||||
OrgID string `db:"org_id"`
|
||||
// ApprovalDeadlineMS is how long an approval request waits for an answer.
|
||||
ApprovalDeadlineMS int64 `db:"approval_deadline_ms"`
|
||||
// RaiseAfter is how many approvals in a row earn a proposal to raise an
|
||||
// action class.
|
||||
RaiseAfter int `db:"raise_after"`
|
||||
// Frozen holds every action that changes something at propose and wait.
|
||||
Frozen bool `db:"frozen"`
|
||||
}
|
||||
|
||||
// Settings returns the organisation's settings; ok is false when none were
|
||||
@@ -69,7 +74,7 @@ type Settings struct {
|
||||
func (s *Store) Settings(ctx context.Context, orgID string) (Settings, bool, error) {
|
||||
var out Settings
|
||||
err := s.db.GetContext(ctx, &out, `
|
||||
SELECT org_id, approval_deadline_ms FROM governance.settings WHERE org_id = $1`, orgID)
|
||||
SELECT org_id, approval_deadline_ms, raise_after, frozen FROM governance.settings WHERE org_id = $1`, orgID)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return Settings{}, false, nil
|
||||
}
|
||||
@@ -82,10 +87,11 @@ func (s *Store) Settings(ctx context.Context, orgID string) (Settings, bool, err
|
||||
// PutSettings records the organisation's settings.
|
||||
func (s *Store) PutSettings(ctx context.Context, set Settings) error {
|
||||
if _, err := s.db.NamedExecContext(ctx, `
|
||||
INSERT INTO governance.settings (org_id, approval_deadline_ms)
|
||||
VALUES (:org_id, :approval_deadline_ms)
|
||||
INSERT INTO governance.settings (org_id, approval_deadline_ms, raise_after, frozen)
|
||||
VALUES (:org_id, :approval_deadline_ms, :raise_after, :frozen)
|
||||
ON CONFLICT (org_id) DO UPDATE
|
||||
SET approval_deadline_ms = EXCLUDED.approval_deadline_ms, updated_at = now()`, set); err != nil {
|
||||
SET approval_deadline_ms = EXCLUDED.approval_deadline_ms, raise_after = EXCLUDED.raise_after,
|
||||
frozen = EXCLUDED.frozen, updated_at = now()`, set); err != nil {
|
||||
return fmt.Errorf("put settings: %w", err)
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in new issue
Block a user