Skip to content

Commit

Permalink
fix nb_resources__total, has_resources__total
Browse files Browse the repository at this point in the history
  • Loading branch information
abulte committed Nov 2, 2024
1 parent 22c0a4d commit 94e8589
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,6 @@ def from_payload(cls, payload: dict, prefix: str, licenses: list) -> "Dataset":
# the others will be taken as is from payload if they're defined on class
data["dataset_id"] = data.pop("id")
data["nb_resources"] = data["resources"]["total"]
# conflicts with relationship, needs to be removed
data.pop("resources")
data["organization"] = data["organization"]["id"] if data["organization"] else None
data["owner"] = data["owner"]["id"] if data["owner"] else None

Expand All @@ -228,14 +226,17 @@ def from_payload(cls, payload: dict, prefix: str, licenses: list) -> "Dataset":
[k for k in cls.__dict__.keys() if k.startswith("harvest__")]
)

db_data = {
**{k: v for k, v in data.items() if hasattr(cls, k)},
**computed_columns,
**indicators,
**harvest_info,
}
# conflicts with relationship, needs to be removed after indicators are computed
data.pop("resources")

return cls(**db_data)
return cls(
**{
**{k: v for k, v in data.items() if hasattr(cls, k)},
**computed_columns,
**indicators,
**harvest_info,
}
)


class ResourceComputedColumns:
Expand Down

0 comments on commit 94e8589

Please sign in to comment.