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
@@ -1,5 +1,10 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
type RecentObject struct {
|
||||
UUID string
|
||||
Path string
|
||||
@@ -23,11 +28,11 @@ func (s *Store) ListRecentObjectsInDomain(
|
||||
limit int,
|
||||
) ([]RecentObject, error) {
|
||||
|
||||
if limit <= 0 {
|
||||
if limit <= 0 || limit > 200 {
|
||||
limit = 20
|
||||
}
|
||||
|
||||
rows, err := s.DB.Query(`
|
||||
query := `
|
||||
WITH latest AS (
|
||||
SELECT
|
||||
r.uuid,
|
||||
@@ -76,11 +81,22 @@ func (s *Store) ListRecentObjectsInDomain(
|
||||
ORDER BY
|
||||
COALESCE(latest.created_at, o.created_at) DESC
|
||||
LIMIT ?
|
||||
`, domainUUID, limit)
|
||||
`
|
||||
if s.sqlBackend == storePostgreSQL {
|
||||
query = `SELECT o.uuid,p.path,0,COALESCE(r.created_at,o.created_at),COALESCE(r.document_hash,'')
|
||||
FROM (SELECT DISTINCT ON (object_uuid) object_uuid,path FROM paths WHERE domain_uuid=$1 ORDER BY object_uuid,is_primary DESC,path) p
|
||||
JOIN objects o ON o.uuid=p.object_uuid
|
||||
LEFT JOIN LATERAL (SELECT created_at,document_hash FROM revisions WHERE object_uuid=o.uuid ORDER BY created_at_ms DESC,uuid DESC LIMIT 1) r ON true
|
||||
ORDER BY COALESCE(r.created_at,o.created_at) DESC,o.uuid LIMIT $2`
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer cancel()
|
||||
rows, err := s.DB.QueryContext(ctx, query, domainUUID, limit)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, s.sqlError("recent objects", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var out []RecentObject
|
||||
|
||||
|
||||
Reference in new issue
Block a user