Skip to content

Commit 3fcffeb

Browse files
committed
[DOP-22578] Add id field to the top of detailed response schema
1 parent 5898078 commit 3fcffeb

31 files changed

+68
-8
lines changed

data_rentgen/server/schemas/v1/dataset.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class DatasetResponseV1(BaseModel):
1919

2020

2121
class DatasetDetailedResponseV1(BaseModel):
22+
id: str = Field(description="Dataset id", coerce_numbers_to_str=True)
2223
data: DatasetResponseV1 = Field(description="Dataset data")
2324

2425
model_config = ConfigDict(from_attributes=True)

data_rentgen/server/schemas/v1/job.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class JobResponseV1(BaseModel):
2020

2121

2222
class JobDetailedResponseV1(BaseModel):
23+
id: str = Field(description="Job id", coerce_numbers_to_str=True)
2324
data: JobResponseV1 = Field(description="Job data")
2425

2526
model_config = ConfigDict(from_attributes=True)

data_rentgen/server/schemas/v1/location.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class LocationStatisticsReponseV1(BaseModel):
4343

4444

4545
class LocationDetailedResponseV1(BaseModel):
46+
id: str = Field(description="Location id", coerce_numbers_to_str=True)
4647
data: LocationResponseV1 = Field(description="Location data")
4748
statistics: LocationStatisticsReponseV1 = Field(description="Location statistics")
4849

data_rentgen/server/schemas/v1/operation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class OperationStatisticsReponseV1(BaseModel):
8686
class OperationDetailedResponseV1(BaseModel):
8787
"""Operation response."""
8888

89+
id: UUID = Field(description="Operation id")
8990
data: OperationResponseV1 = Field(description="Operation data")
9091
statistics: OperationStatisticsReponseV1 = Field(
9192
description="Operation statistics",

data_rentgen/server/schemas/v1/run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class RunStatisticsReponseV1(BaseModel):
103103
class RunDetailedResponseV1(BaseModel):
104104
"""Run response."""
105105

106+
id: UUID = Field(description="Run id")
106107
data: RunResponseV1 = Field(description="Run data")
107108
statistics: RunStatisticsReponseV1 = Field(description="Run statistics")
108109

data_rentgen/server/services/dataset.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
@dataclass
1414
class DatasetServiceResult:
15+
id: int
1516
data: Dataset
1617

1718

@@ -41,5 +42,5 @@ async def paginate(
4142
page=pagination.page,
4243
page_size=pagination.page_size,
4344
total_count=pagination.total_count,
44-
items=[DatasetServiceResult(data=dataset) for dataset in pagination.items],
45+
items=[DatasetServiceResult(id=dataset.id, data=dataset) for dataset in pagination.items],
4546
)

data_rentgen/server/services/job.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
@dataclass
1414
class JobServiceResult:
15+
id: int
1516
data: Job
1617

1718

@@ -41,5 +42,5 @@ async def paginate(
4142
page=pagination.page,
4243
page_size=pagination.page_size,
4344
total_count=pagination.total_count,
44-
items=[JobServiceResult(data=job) for job in pagination.items],
45+
items=[JobServiceResult(id=job.id, data=job) for job in pagination.items],
4546
)

data_rentgen/server/services/location.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class LocationServiceStatistics:
4343

4444
@dataclass
4545
class LocationServiceResult:
46+
id: int
4647
data: Location
4748
statistics: LocationServiceStatistics
4849

@@ -80,6 +81,7 @@ async def paginate(
8081
total_count=pagination.total_count,
8182
items=[
8283
LocationServiceResult(
84+
id=location.id,
8385
data=location,
8486
statistics=LocationServiceStatistics(
8587
datasets=LocationServiceDatasetStatistics.from_row(dataset_stats.get(location.id)),
@@ -99,6 +101,7 @@ async def update_external_id(
99101
dataset_stats = await self._uow.dataset.get_stats_by_location_ids([location.id])
100102
job_stats = await self._uow.job.get_stats_by_location_ids([location.id])
101103
return LocationServiceResult(
104+
id=location.id,
102105
data=location,
103106
statistics=LocationServiceStatistics(
104107
datasets=LocationServiceDatasetStatistics.from_row(dataset_stats.get(location.id)),

data_rentgen/server/services/operation.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def from_row(cls, row: Row | None):
2727

2828
return cls(
2929
total_datasets=row.total_datasets,
30-
total_bytes=row.total_bytes,
31-
total_rows=row.total_rows,
32-
total_files=row.total_files,
30+
total_bytes=row.total_bytes or 0,
31+
total_rows=row.total_rows or 0,
32+
total_files=row.total_files or 0,
3333
)
3434

3535

@@ -41,6 +41,7 @@ class OperationServiceStatistics:
4141

4242
@dataclass
4343
class OperationServicePageItem:
44+
id: UUID
4445
data: Operation
4546
statistics: OperationServiceStatistics
4647

@@ -80,6 +81,7 @@ async def paginate(
8081
total_count=pagination.total_count,
8182
items=[
8283
OperationServicePageItem(
84+
id=operation.id,
8385
data=operation,
8486
statistics=OperationServiceStatistics(
8587
inputs=OperationServiceIOStatistics.from_row(input_stats.get(operation.id)),

data_rentgen/server/services/run.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def from_row(cls, row: Row | None):
2727

2828
return cls(
2929
total_datasets=row.total_datasets,
30-
total_bytes=row.total_bytes,
31-
total_rows=row.total_rows,
32-
total_files=row.total_files,
30+
total_bytes=row.total_bytes or 0,
31+
total_rows=row.total_rows or 0,
32+
total_files=row.total_files or 0,
3333
)
3434

3535

@@ -56,6 +56,7 @@ class RunServiceStatistics:
5656

5757
@dataclass
5858
class RunServicePageItem:
59+
id: UUID
5960
data: Run
6061
statistics: RunServiceStatistics
6162

@@ -100,6 +101,7 @@ async def paginate(
100101
total_count=pagination.total_count,
101102
items=[
102103
RunServicePageItem(
104+
id=run.id,
103105
data=run,
104106
statistics=RunServiceStatistics(
105107
inputs=RunServiceIOStatistics.from_row(input_stats.get(run.id)),

0 commit comments

Comments
 (0)