Merged in feature/track-filesize (pull request #200)
track file sizes for all documents in system * feature complete needs dev testing
This commit is contained in:
@@ -65,21 +65,22 @@ func (q *Queries) AddDocumentUpload(ctx context.Context, arg *AddDocumentUploadP
|
||||
}
|
||||
|
||||
const createDocument = `-- name: CreateDocument :one
|
||||
INSERT INTO documents (clientId, hash, batch_id, filename, folderId, originalPath) VALUES ($1, $2, $3, $4, $5, $6) RETURNING id
|
||||
INSERT INTO documents (clientId, hash, batch_id, filename, folderId, originalPath, file_size_bytes) VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING id
|
||||
`
|
||||
|
||||
type CreateDocumentParams struct {
|
||||
Clientid string `db:"clientid"`
|
||||
Hash string `db:"hash"`
|
||||
BatchID *uuid.UUID `db:"batch_id"`
|
||||
Filename *string `db:"filename"`
|
||||
Folderid *uuid.UUID `db:"folderid"`
|
||||
Originalpath *string `db:"originalpath"`
|
||||
Clientid string `db:"clientid"`
|
||||
Hash string `db:"hash"`
|
||||
BatchID *uuid.UUID `db:"batch_id"`
|
||||
Filename *string `db:"filename"`
|
||||
Folderid *uuid.UUID `db:"folderid"`
|
||||
Originalpath *string `db:"originalpath"`
|
||||
FileSizeBytes *int64 `db:"file_size_bytes"`
|
||||
}
|
||||
|
||||
// CreateDocument
|
||||
//
|
||||
// INSERT INTO documents (clientId, hash, batch_id, filename, folderId, originalPath) VALUES ($1, $2, $3, $4, $5, $6) RETURNING id
|
||||
// INSERT INTO documents (clientId, hash, batch_id, filename, folderId, originalPath, file_size_bytes) VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING id
|
||||
func (q *Queries) CreateDocument(ctx context.Context, arg *CreateDocumentParams) (uuid.UUID, error) {
|
||||
row := q.db.QueryRow(ctx, createDocument,
|
||||
arg.Clientid,
|
||||
@@ -88,6 +89,7 @@ func (q *Queries) CreateDocument(ctx context.Context, arg *CreateDocumentParams)
|
||||
arg.Filename,
|
||||
arg.Folderid,
|
||||
arg.Originalpath,
|
||||
arg.FileSizeBytes,
|
||||
)
|
||||
var id uuid.UUID
|
||||
err := row.Scan(&id)
|
||||
@@ -101,18 +103,20 @@ SELECT
|
||||
d.hash,
|
||||
d.folderId,
|
||||
d.filename,
|
||||
d.originalPath
|
||||
d.originalPath,
|
||||
d.file_size_bytes
|
||||
FROM documents d
|
||||
WHERE d.id = $1
|
||||
`
|
||||
|
||||
type GetDocumentEnrichedRow struct {
|
||||
ID uuid.UUID `db:"id"`
|
||||
Clientid string `db:"clientid"`
|
||||
Hash string `db:"hash"`
|
||||
Folderid *uuid.UUID `db:"folderid"`
|
||||
Filename *string `db:"filename"`
|
||||
Originalpath *string `db:"originalpath"`
|
||||
ID uuid.UUID `db:"id"`
|
||||
Clientid string `db:"clientid"`
|
||||
Hash string `db:"hash"`
|
||||
Folderid *uuid.UUID `db:"folderid"`
|
||||
Filename *string `db:"filename"`
|
||||
Originalpath *string `db:"originalpath"`
|
||||
FileSizeBytes *int64 `db:"file_size_bytes"`
|
||||
}
|
||||
|
||||
// Retrieves a document with extended metadata including folder and filename
|
||||
@@ -123,7 +127,8 @@ type GetDocumentEnrichedRow struct {
|
||||
// d.hash,
|
||||
// d.folderId,
|
||||
// d.filename,
|
||||
// d.originalPath
|
||||
// d.originalPath,
|
||||
// d.file_size_bytes
|
||||
// FROM documents d
|
||||
// WHERE d.id = $1
|
||||
func (q *Queries) GetDocumentEnriched(ctx context.Context, id uuid.UUID) (*GetDocumentEnrichedRow, error) {
|
||||
@@ -136,6 +141,7 @@ func (q *Queries) GetDocumentEnriched(ctx context.Context, id uuid.UUID) (*GetDo
|
||||
&i.Folderid,
|
||||
&i.Filename,
|
||||
&i.Originalpath,
|
||||
&i.FileSizeBytes,
|
||||
)
|
||||
return &i, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user