Files
website-v2/versions/management/commands/import_versions.py
Greg Kaleka 44829f1556 Add category override mapping and use it in library update method (#1411)
Fixes #1034

- Adds a `CATEGORY_OVERRIDES` mapping
- Uses the override in `update_libraries` management command

### Manual testing
- Ran `./manage.py import_versions`
- Ran `./manage.py update_libraries`
- Static String had the correct category
<img width="440" alt="Screenshot 2024-11-04 at 5 24 05 PM"
src="https://github.com/user-attachments/assets/4b0cf4cb-15e2-4337-9284-7659afd40643">

### Post-deploy tasks
- Ensure `update_libraries` is run
- Verify **Container** category is orphaned
- Delete **Container** category

Co-authored-by: Greg Kaleka <gkaleka@energy-solution.com>
2024-11-05 13:49:00 -05:00

39 lines
1.3 KiB
Python

import djclick as click
from versions.tasks import import_versions
@click.command()
@click.option("--delete-versions", is_flag=True, help="Delete all existing versions")
@click.option("--new", is_flag=True, help="Only import new versions")
@click.option("--token", is_flag=False, help="Github API token")
def command(
delete_versions,
new,
token,
):
"""Imports Boost release information from Github and updates the local database.
The function retrieves Boost tags from the main Github repo, excluding beta releases
and release candidates.
It then creates or updates a Version instance in the local database for each tag.
Args:
verbose (bool): Enable verbose output (show logging statements)
delete_versions (bool): If True, deletes all existing Version instances before
importing.
new (bool): If True, only imports versions that do not already exist in
the database.
token (str): Github API token, if you need to use something other than the
setting.
"""
click.secho("Importing versions...", fg="green")
import_versions.delay(
delete_versions=delete_versions,
new_versions_only=new,
token=token,
purge_after=True,
)
click.secho("Finished importing versions.", fg="green")