Skip to content

Commit

Permalink
fix project import/export
Browse files Browse the repository at this point in the history
  • Loading branch information
AstridKery committed May 10, 2024
1 parent b61b79c commit 58ac4c9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
17 changes: 10 additions & 7 deletions backend/django/core/management/commands/export_database_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ class Command(BaseCommand):

def handle(self, *args, **kwargs):
export_projects = ExternalDatabase.objects.filter(cron_export=True).values_list(
flat=True
"project_id", flat=True
)
if len(export_projects) == 0:
print("No projects have cron_export set to True.")
for pk in export_projects:
print("Exporting project", pk)
response = {}
export_table(pk, response)
if "success_message" in response:
print(response["success_message"])
if "error" in response:
print(response["error"])
try:
response = {}
export_table(pk, response)
if "success_message" in response:
print(response["success_message"])
if "error" in response:
print(response["error"])
except Exception as e:
print("ERROR:", e)
19 changes: 11 additions & 8 deletions backend/django/core/management/commands/ingest_database_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ class Command(BaseCommand):

def handle(self, *args, **kwargs):
ingest_projects = ExternalDatabase.objects.filter(cron_ingest=True).values_list(
flat=True
"project_id", flat=True
)
if len(ingest_projects) == 0:
print("No projects have cron_ingest set to True.")
for pk in ingest_projects:
print("Ingesting project", pk)
project = Project.objects.get(pk=pk)
response = {}
response = load_ingest_table(project, response)
if "num_added" in response:
print("Imported", response["num_added"], "new items")
if "error" in response:
print(response["error"])
try:
project = Project.objects.get(pk=pk)
response = {}
response = load_ingest_table(project, response)
if "num_added" in response:
print("Imported", response["num_added"], "new items")
if "error" in response:
print(response["error"])
except Exception as e:
print("ERROR:", e)

0 comments on commit 58ac4c9

Please sign in to comment.