Skip to content

Commit

Permalink
init script to fetch rust downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
chirag-jn committed Apr 3, 2024
1 parent 74b9846 commit ed3537a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/tools/vdb_table/fetch-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def update_json_files(directory, headers=None):
dockerhub_url = data.get("docker_pulls", {}).get("source_url", "")
npm_url = data.get("npm_downloads", {}).get("source_url", "")
pypi_url = data.get("pypi_downloads", {}).get("source_url", "")
rust_url = data.get("rust_downloads", {}).get("source_url", "")

for source in sources:
if 'value_90_days' not in data[source]:
Expand Down Expand Up @@ -162,6 +163,18 @@ def update_json_files(directory, headers=None):
downloads = get_pypi_downloads_last_90(pypi_package_name, headers, start_date.strftime('%Y-%m-%d'), end_date.strftime('%Y-%m-%d'))
if downloads is not None:
data["pypi_downloads"]["value_90_days"] = downloads

if rust_url:
pypi_package_name = list(pypi_url.split('https://pypi.org/project/'))[1].strip().strip('/')
downloads = get_pypi_downloads(pypi_package_name, headers)
if downloads is not None:
data["rust_downloads"]["value"] = downloads

end_date = datetime.now()
start_date = end_date - timedelta(days=90)
downloads = get_pypi_downloads_last_90(pypi_package_name, headers, start_date.strftime('%Y-%m-%d'), end_date.strftime('%Y-%m-%d'))
if downloads is not None:
data["rust_downloads"]["value_90_days"] = downloads

# Write the updated data back to the file
json_file.seek(0) # Rewind to the start of the file
Expand Down

0 comments on commit ed3537a

Please sign in to comment.