This commit is contained in:
Wir
2024-10-22 16:47:37 +02:00
3 changed files with 11 additions and 9 deletions

2
.gitignore vendored
View File

@@ -1,6 +1,8 @@
# by me: # by me:
resources/ resources/
.vscode/
# ---> Python # ---> Python
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/

View File

@@ -101,9 +101,9 @@
" response = farm_client.resource.get('log', type)\n", " response = farm_client.resource.get('log', type)\n",
" ret = []\n", " ret = []\n",
" for log in response['data']:\n", " for log in response['data']:\n",
" assets = log['relationships']['asset']['data']\n", " log_assets = log['relationships']['asset']['data']\n",
" for asset in assets:\n", " for log_asset in log_assets:\n",
" if asset['id'] == id:\n", " if log_asset['id'] == asset['id']:\n",
" ret.append(log)\n", " ret.append(log)\n",
" return ret\n", " return ret\n",
"\n", "\n",
@@ -129,7 +129,7 @@
" for asset in assets:\n", " for asset in assets:\n",
" if asset['type'] == 'asset--plant': \n", " if asset['type'] == 'asset--plant': \n",
" plant_id = asset['id']\n", " plant_id = asset['id']\n",
" seedings = get_related_logs_of_type(plant_id, 'seeding')\n", " seedings = get_related_logs_of_type(asset, 'seeding')\n",
" for seeding in seedings:\n", " for seeding in seedings:\n",
" area_quants = get_related_quantities_of_measure(seeding, 'area')\n", " area_quants = get_related_quantities_of_measure(seeding, 'area')\n",
" for area_quant in area_quants:\n", " for area_quant in area_quants:\n",
@@ -158,7 +158,7 @@
"print(df)\n", "print(df)\n",
"\n", "\n",
"# Speichere die Tabelle in einer CSV-Datei\n", "# Speichere die Tabelle in einer CSV-Datei\n",
"csv_file_path = 'harvest_logs.csv'\n", "csv_file_path = 'resources/harvest_logs.csv'\n",
"df.to_csv(csv_file_path, index=False)\n", "df.to_csv(csv_file_path, index=False)\n",
"\n", "\n",
"print(f\"Die Tabelle wurde erfolgreich in der Datei '{csv_file_path}' gespeichert.\")" "print(f\"Die Tabelle wurde erfolgreich in der Datei '{csv_file_path}' gespeichert.\")"

View File

@@ -21,9 +21,9 @@ def get_related_logs_of_type(asset, type):
response = farm_client.resource.get('log', type) response = farm_client.resource.get('log', type)
ret = [] ret = []
for log in response['data']: for log in response['data']:
assets = log['relationships']['asset']['data'] log_assets = log['relationships']['asset']['data']
for asset in assets: for log_asset in log_assets:
if asset['id'] == id: if log_asset['id'] == asset['id']:
ret.append(log) ret.append(log)
return ret return ret
@@ -49,7 +49,7 @@ for item in response['data']:
for asset in assets: for asset in assets:
if asset['type'] == 'asset--plant': if asset['type'] == 'asset--plant':
plant_id = asset['id'] plant_id = asset['id']
seedings = get_related_logs_of_type(plant_id, 'seeding') seedings = get_related_logs_of_type(asset, 'seeding')
for seeding in seedings: for seeding in seedings:
area_quants = get_related_quantities_of_measure(seeding, 'area') area_quants = get_related_quantities_of_measure(seeding, 'area')
for area_quant in area_quants: for area_quant in area_quants: