Skip to content

Commit

Permalink
refactor: file_num + new: del sitemap
Browse files Browse the repository at this point in the history
Try to release memory?
  • Loading branch information
nickumia-reisys committed Jul 26, 2023
1 parent 2784217 commit 4ac22e8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions ckanext/geodatagov/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ def sitemap_to_s3(upload_to_s3: bool, page_size: int, max_per_page: int):
return

start = 0
file_num = 1

num_of_pages = (count // page_size) + 1

Expand All @@ -251,7 +250,7 @@ def sitemap_to_s3(upload_to_s3: bool, page_size: int, max_per_page: int):
{S3_ENDPOINT_URL}/{BUCKET_NAME}/{sitemap_index.filename_s3}"
)

for _ in range(num_of_pages):
for file_num in range(1, num_of_pages + 1):
sitemap = SitemapData(str(file_num), start, page_size)
sitemap.write_sitemap_header()
sitemap.write_pkgs(package_query)
Expand All @@ -269,16 +268,16 @@ def sitemap_to_s3(upload_to_s3: bool, page_size: int, max_per_page: int):
log.info(f"done with {sitemap.filename_s3}.")

start += page_size
file_num += 1

if upload_to_s3:
log.info("Uploading {sitemap.filename_s3}...")
get_s3()
log.info(f"Uploading {sitemap.filename_s3}...")
upload_sitemap_file(sitemap)
else:
log.info(f"Skip upload and return local copy of sitemap {file_num}.")
print(json.dumps(sitemap.to_json(), indent=4))

del sitemap


def _normalize_type(_type):
if isinstance(_type, model.domain_object.DomainObject):
Expand Down

0 comments on commit 4ac22e8

Please sign in to comment.