feat(storage): add native PostgreSQL runtime and verified offline application import
Build and publish container images / images (push) Failing after 12m29s
Build and publish container images / images (push) Failing after 12m29s
This commit is contained in:
1 parent
96065d1e89
commit
0ba1dcfef0
243 files changed
+21441
-3090
No files matched your search
@@ -5,6 +5,7 @@ import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Dashboard is owner-scoped presentation metadata. It never contains executable
|
||||
@@ -80,13 +81,14 @@ func normalizeDashboard(items []DashboardWidget) ([]DashboardWidget, error) {
|
||||
return out, ValidateDashboard(out)
|
||||
}
|
||||
|
||||
func (s *Store) Dashboard(ctx context.Context, domain, actor string) (DashboardLayout, error) {
|
||||
func (s *Store) Dashboard(ctx context.Context, domain, actor string) (result0 DashboardLayout, resultErr error) {
|
||||
defer func() { resultErr = s.sqlError("organizer repository", resultErr) }()
|
||||
p := DashboardLayout{Widgets: DefaultDashboard()}
|
||||
if err := taskActor(ctx, s.DB, domain, actor, false); err != nil {
|
||||
if err := s.taskActor(ctx, s.DB, domain, actor, false); err != nil {
|
||||
return p, err
|
||||
}
|
||||
var raw string
|
||||
err := s.DB.QueryRowContext(ctx, `SELECT version,data FROM organizer_dashboard_layouts WHERE domain_uuid=? AND owner_uuid=?`, domain, actor).Scan(&p.Version, &raw)
|
||||
err := s.DB.QueryRowContext(ctx, `SELECT version,data FROM organizer_dashboard_layouts WHERE domain_uuid=`+s.sqlParam(1)+` AND owner_uuid=`+s.sqlParam(2)+``, domain, actor).Scan(&p.Version, &raw)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return p, nil
|
||||
}
|
||||
@@ -98,7 +100,10 @@ func (s *Store) Dashboard(ctx context.Context, domain, actor string) (DashboardL
|
||||
}
|
||||
|
||||
// Layout updates do not invalidate in-flight email delivery consent/version.
|
||||
func (s *Store) SaveDashboard(ctx context.Context, domain, actor string, version int64, widgets []DashboardWidget) (DashboardLayout, error) {
|
||||
func (s *Store) SaveDashboard(ctx context.Context, domain, actor string, version int64, widgets []DashboardWidget) (result0 DashboardLayout, resultErr error) {
|
||||
defer func() { resultErr = s.sqlError("organizer repository", resultErr) }()
|
||||
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
||||
defer cancel()
|
||||
p := DashboardLayout{}
|
||||
if s.ReadOnly {
|
||||
return p, ErrReadOnly
|
||||
@@ -116,10 +121,10 @@ func (s *Store) SaveDashboard(ctx context.Context, domain, actor string, version
|
||||
return p, err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
if err = taskProductivityWriter(ctx, tx, domain, actor); err != nil {
|
||||
if err = s.taskProductivityWriter(ctx, tx, domain, actor); err != nil {
|
||||
return p, err
|
||||
}
|
||||
err = tx.QueryRowContext(ctx, `SELECT version FROM organizer_dashboard_layouts WHERE domain_uuid=? AND owner_uuid=?`, domain, actor).Scan(&p.Version)
|
||||
err = tx.QueryRowContext(ctx, `SELECT version FROM organizer_dashboard_layouts WHERE domain_uuid=`+s.sqlParam(1)+` AND owner_uuid=`+s.sqlParam(2)+``, domain, actor).Scan(&p.Version)
|
||||
if err != nil && !errors.Is(err, sql.ErrNoRows) {
|
||||
return p, err
|
||||
}
|
||||
@@ -135,7 +140,7 @@ func (s *Store) SaveDashboard(ctx context.Context, domain, actor string, version
|
||||
if err != nil {
|
||||
return p, err
|
||||
}
|
||||
_, err = tx.ExecContext(ctx, `INSERT INTO organizer_dashboard_layouts(domain_uuid,owner_uuid,version,data) VALUES(?,?,?,?) ON CONFLICT(domain_uuid,owner_uuid) DO UPDATE SET version=excluded.version,data=excluded.data`, domain, actor, p.Version, string(data))
|
||||
_, err = tx.ExecContext(ctx, `INSERT INTO organizer_dashboard_layouts(domain_uuid,owner_uuid,version,data) VALUES(`+s.sqlParam(1)+`,`+s.sqlParam(2)+`,`+s.sqlParam(3)+`,`+s.sqlParam(4)+`) ON CONFLICT(domain_uuid,owner_uuid) DO UPDATE SET version=excluded.version,data=excluded.data`, domain, actor, p.Version, string(data))
|
||||
if err != nil {
|
||||
return p, err
|
||||
}
|
||||
@@ -150,14 +155,15 @@ type DashboardProgress struct {
|
||||
|
||||
// Deliberately count all rows, not a truncated list response. Cancelled and
|
||||
// archived items are excluded from both numerator and denominator.
|
||||
func (s *Store) DashboardProgress(ctx context.Context, domain, actor, day string) (DashboardProgress, error) {
|
||||
func (s *Store) DashboardProgress(ctx context.Context, domain, actor, day string) (result0 DashboardProgress, resultErr error) {
|
||||
defer func() { resultErr = s.sqlError("organizer repository", resultErr) }()
|
||||
p := DashboardProgress{Date: day}
|
||||
if !validTaskDate(day) || day == "" {
|
||||
return p, ErrTaskInvalid
|
||||
}
|
||||
if err := taskActor(ctx, s.DB, domain, actor, false); err != nil {
|
||||
if err := s.taskActor(ctx, s.DB, domain, actor, false); err != nil {
|
||||
return p, err
|
||||
}
|
||||
err := s.DB.QueryRowContext(ctx, `SELECT count(*),COALESCE(sum(status='done'),0) FROM organizer_items WHERE domain_uuid=? AND owner_uuid=? AND kind='task' AND archived=0 AND status!='cancelled' AND planned_on=?`, domain, actor, day).Scan(&p.Total, &p.Done)
|
||||
err := s.DB.QueryRowContext(ctx, `SELECT count(*),COALESCE(sum(CASE WHEN status='done' THEN 1 ELSE 0 END),0) FROM organizer_items WHERE domain_uuid=`+s.sqlParam(1)+` AND owner_uuid=`+s.sqlParam(2)+` AND kind='task' AND archived=0 AND status!='cancelled' AND planned_on=`+s.sqlParam(3)+``, domain, actor, day).Scan(&p.Total, &p.Done)
|
||||
return p, err
|
||||
}
|
||||
Reference in new issue
Block a user