feat: move report artifacts to OSS storage
This commit is contained in:
@@ -414,6 +414,8 @@ ORDER BY period_start DESC
|
||||
DAILY_DOWNLOAD_SQL = """
|
||||
SELECT
|
||||
artifact.artifact_kind,
|
||||
artifact.storage_provider,
|
||||
artifact.bucket_alias,
|
||||
artifact.original_filename,
|
||||
artifact.object_key,
|
||||
artifact.sha256,
|
||||
@@ -432,6 +434,8 @@ WHERE run.run_key = %s
|
||||
MONTHLY_DOWNLOAD_SQL = """
|
||||
SELECT
|
||||
artifact.artifact_kind,
|
||||
artifact.storage_provider,
|
||||
artifact.bucket_alias,
|
||||
artifact.original_filename,
|
||||
artifact.object_key,
|
||||
artifact.sha256,
|
||||
@@ -443,7 +447,6 @@ JOIN ingestion.artifacts AS artifact
|
||||
WHERE run.id = %s
|
||||
AND run.report_status IN ('active', 'superseded')
|
||||
AND artifact.artifact_kind = 'monthly_xlsx'
|
||||
AND artifact.storage_provider = 'local'
|
||||
""".strip()
|
||||
|
||||
|
||||
@@ -815,13 +818,23 @@ class PostgresPortalRepository:
|
||||
if len(rows) != 1:
|
||||
raise PortalDataError("DOWNLOAD_NOT_FOUND", "文件不存在或尚未生成")
|
||||
row = rows[0]
|
||||
if len(row) >= 8:
|
||||
provider = str(row[1] or "local")
|
||||
bucket_alias = str(row[2] or "arr-project-root")
|
||||
filename_index, key_index, hash_index, size_index, mime_index = 3, 4, 5, 6, 7
|
||||
else:
|
||||
provider = "local"
|
||||
bucket_alias = "arr-project-root"
|
||||
filename_index, key_index, hash_index, size_index, mime_index = 1, 2, 3, 4, 5
|
||||
descriptor = ArtifactDescriptor(
|
||||
file_kind=str(row[0] or ""),
|
||||
original_filename=str(row[1] or ""),
|
||||
storage_key=str(row[2] or ""),
|
||||
sha256=str(row[3] or "").lower(),
|
||||
byte_size=int(row[4]),
|
||||
mime_type=str(row[5] or "application/octet-stream"),
|
||||
original_filename=str(row[filename_index] or ""),
|
||||
storage_key=str(row[key_index] or ""),
|
||||
sha256=str(row[hash_index] or "").lower(),
|
||||
byte_size=int(row[size_index]),
|
||||
mime_type=str(row[mime_index] or "application/octet-stream"),
|
||||
storage_provider=provider,
|
||||
bucket_alias=bucket_alias,
|
||||
)
|
||||
descriptor.validate()
|
||||
return descriptor
|
||||
|
||||
Reference in New Issue
Block a user