forked from mtusi2026/mtusi2026lab5
Реализация на 5
This commit is contained in:
@@ -25,10 +25,15 @@ func (r *AttachmentsRepo) Page(ctx context.Context, after uuid.UUID) ([]*Attachm
|
||||
}
|
||||
func (r *AttachmentsRepo) Exists(ctx context.Context, c *pgxpool.Conn, key string) (bool, error) {
|
||||
var found bool
|
||||
e := c.QueryRow(ctx, "SELECT EXISTS(SELECT 1 FROM attachments WHERE object_key=$1)", key).Scan(&found)
|
||||
e := c.QueryRow(ctx, "SELECT EXISTS(SELECT 1 FROM attachment_variants WHERE object_key=$1 UNION ALL SELECT 1 FROM attachments WHERE object_key=$1 OR staging_key=$1 OR variant_keys @> jsonb_build_object('thumbnail',$1::text) OR variant_keys @> jsonb_build_object('crop',$1::text) OR variant_keys @> jsonb_build_object('optimized',$1::text))", key).Scan(&found)
|
||||
return found, e
|
||||
}
|
||||
func (r *AttachmentsRepo) MarkMissing(ctx context.Context, c *pgxpool.Conn, id uuid.UUID, missing bool) (bool, error) {
|
||||
tag, e := c.Exec(ctx, "UPDATE attachments SET integrity_missing=$2,updated_at=clock_timestamp() WHERE id=$1 AND integrity_missing<>$2", id, missing)
|
||||
return tag.RowsAffected() == 1, e
|
||||
}
|
||||
|
||||
func (r *AttachmentsRepo) CheckConn(ctx context.Context, c *pgxpool.Conn) error {
|
||||
_, e := c.Exec(ctx, "SELECT 1")
|
||||
return e
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user