Rename download_rebrickable to insert_rebrickable and make it return if an insertion occured

This commit is contained in:
Gregoo 2025-01-27 10:04:24 +01:00
parent 5e02a902d4
commit b84552b352
2 changed files with 8 additions and 4 deletions

View File

@ -52,8 +52,8 @@ class RebrickableSet(BrickRecord):
if record is not None:
self.ingest(record)
# Import the set from Rebrickable
def download_rebrickable(self, /) -> None:
# Insert the set from Rebrickable
def insert_rebrickable(self, /) -> bool:
# Insert the Rebrickable set to the database
rows, _ = self.insert(
commit=False,
@ -61,10 +61,14 @@ class RebrickableSet(BrickRecord):
override_query=RebrickableSet.insert_query
)
if rows > 0:
inserted = rows > 0
if inserted:
if not current_app.config['USE_REMOTE_IMAGES']:
RebrickableImage(self).download()
return inserted
# Ingest a set
def ingest(self, record: Row | dict[str, Any], /):
super().ingest(record)

View File

@ -54,7 +54,7 @@ class BrickSet(RebrickableSet):
self.insert(commit=False)
# Execute the parent download method
self.download_rebrickable()
self.insert_rebrickable()
# Load the inventory
RebrickableParts(self.socket, self).download()