Skip to content

Commit

Permalink
wip(today's fortune): Who are you?
Browse files Browse the repository at this point in the history
  • Loading branch information
joscha committed Dec 15, 2024
1 parent 7cda327 commit 80f4cc5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 25 deletions.
2 changes: 1 addition & 1 deletion sources/affinity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def process_and_yield_fields(
case PersonValue() | CompanyValue():
ret[new_column] = value.data.id if value.data else None
case PersonsValue() | CompaniesValue():
ret[f"{new_column}_id"] = [e.id for e in value.data]
ret[f"{new_column}_id"] = [e.id for e in value.data] if value.data else []
case TextValue() | FloatValue() | TextValue() | TextsValue() | FloatsValue() | LocationValue() | LocationsValue():
ret[new_column] = value.data
case _:
Expand Down
6 changes: 3 additions & 3 deletions sources/affinity/model/generate_model.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ main() {
local python_version
python_version=$(./current_python_major_minor.py)

# TODO: This is currently not fully generating a valid model,
# due to https://github.com/koxudaxi/datamodel-code-generator/pull/2216
datamodel-codegen \
--input v2_spec.json \
--output v2.py \
Expand All @@ -24,7 +22,9 @@ main() {
--disable-timestamp \
--target-python-version "${python_version}"

git apply ./v2_model_patches.diff
git apply \
--allow-empty \
./v2_model_patches.diff
}

main "$@"
2 changes: 1 addition & 1 deletion sources/affinity/model/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
datamodel-code-generator>=0.26.3
datamodel-code-generator>=0.26.4
18 changes: 11 additions & 7 deletions sources/affinity/model/v2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions sources/affinity/model/v2_model_patches.diff
Original file line number Diff line number Diff line change
@@ -1,13 +0,0 @@
diff --git a/sources/affinity/model/v2.py b/sources/affinity/model/v2.py
index 76cdeeef..06e64771 100644
--- a/sources/affinity/model/v2.py
+++ b/sources/affinity/model/v2.py
@@ -278,7 +278,7 @@ class DropdownsValue(MyBaseModel):
"""
The type of value
"""
- data: List[Dropdown]
+ data: List[Dropdown] | None
"""
The value for many dropdown items
"""
3 changes: 3 additions & 0 deletions sources/affinity_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ def load_affinity_data() -> None:
list_refs=[
ListReference(248283),
ListReference(247888, 1869904),
ListReference(69224, 351112),
ListReference(126638, 1133940),
ListReference(157541, 831583)
]
)
# data.add_limit(1)
Expand Down

0 comments on commit 80f4cc5

Please sign in to comment.