Merged in feature/import (pull request #157)
Feature/import * importstart * pp * tests * importtests * 100GB * lint * passtests * utc * awsprofile * doublequotes * host
This commit is contained in:
@@ -44,3 +44,26 @@ SELECT id FROM documents WHERE hash = $1 and clientId = $2;
|
||||
|
||||
-- name: ListDocumentIDsBatch :many
|
||||
SELECT id, totalCount FROM listDocumentIDs(@clientId, @batchSize, @pageOffset);
|
||||
|
||||
-- name: AddDocumentUpload :exec
|
||||
INSERT INTO documentUploads (id, clientId, bucket, key, part, createdAt) VALUES ($1, $2, $3, $4, $5, $6);
|
||||
|
||||
-- name: GetDocumentUploadCurrentPart :one
|
||||
WITH client as (
|
||||
select clientId from clients where clientId = @clientId
|
||||
),
|
||||
parts as (
|
||||
SELECT docs.part
|
||||
FROM client as c
|
||||
JOIN documentUploads as docs on docs.clientId = c.clientId
|
||||
WHERE date(docs.createdAt) = date(@queryDate)
|
||||
),
|
||||
max_part as (
|
||||
SELECT COALESCE(max(part), 0) as max_part_num FROM parts
|
||||
)
|
||||
SELECT
|
||||
COALESCE(p.part, 0)::unsignedsmallint as part,
|
||||
COUNT(p.part) as count
|
||||
FROM parts p
|
||||
RIGHT JOIN max_part mp ON p.part = mp.max_part_num
|
||||
GROUP BY p.part;
|
||||
|
||||
Reference in New Issue
Block a user