Also add Kick to dataset
This commit is contained in:
parent
60ac907163
commit
563266d8cc
3 changed files with 22 additions and 12 deletions
|
|
@ -645,8 +645,8 @@ def dataset_backups_view(request: HttpRequest) -> HttpResponse:
|
|||
datasets.sort(key=operator.itemgetter("updated_at"), reverse=True)
|
||||
|
||||
seo_context: dict[str, Any] = _build_seo_context(
|
||||
page_title="Twitch Dataset",
|
||||
page_description="Database backups and datasets available for download.",
|
||||
page_title="Twitch/Kick drop data",
|
||||
page_description="Twitch/Kick datasets available for download, including historical drop campaign data and more.",
|
||||
)
|
||||
context: dict[str, Any] = {
|
||||
"datasets": datasets,
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ if TYPE_CHECKING:
|
|||
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""Create a compressed SQL dump of the Twitch dataset tables."""
|
||||
"""Create a compressed SQL dump of the Twitch and Kick dataset tables."""
|
||||
|
||||
help = "Create a compressed SQL dump of the Twitch dataset tables."
|
||||
help = "Create a compressed SQL dump of the Twitch and Kick dataset tables."
|
||||
|
||||
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||
"""Define arguments for the backup command."""
|
||||
|
|
@ -59,9 +59,14 @@ class Command(BaseCommand):
|
|||
timestamp: str = timezone.localtime(timezone.now()).strftime("%Y%m%d-%H%M%S")
|
||||
output_path: Path = output_dir / f"{prefix}-{timestamp}.sql.zst"
|
||||
|
||||
allowed_tables = _get_allowed_tables("twitch_")
|
||||
allowed_tables = sorted({
|
||||
*_get_allowed_tables("twitch_"),
|
||||
*_get_allowed_tables("kick_"),
|
||||
})
|
||||
if not allowed_tables:
|
||||
self.stdout.write(self.style.WARNING("No twitch tables found to back up."))
|
||||
self.stdout.write(
|
||||
self.style.WARNING("No twitch or kick tables found to back up."),
|
||||
)
|
||||
return
|
||||
|
||||
if django_connection.vendor == "postgresql":
|
||||
|
|
|
|||
|
|
@ -84,34 +84,39 @@ class TestBackupCommand:
|
|||
assert "twitch_game" in content
|
||||
assert "Test Org" in content
|
||||
|
||||
def test_backup_excludes_non_twitch_tables(self, tmp_path: Path) -> None:
|
||||
"""Test that backup only includes twitch_ prefixed tables."""
|
||||
def test_backup_excludes_non_app_tables(self, tmp_path: Path) -> None:
|
||||
"""Test that backup includes app tables and excludes non-app tables."""
|
||||
_skip_if_pg_dump_missing()
|
||||
# Create test data so tables exist
|
||||
Organization.objects.create(twitch_id="test001", name="Test Org")
|
||||
|
||||
output_dir = tmp_path / "backups"
|
||||
output_dir: Path = tmp_path / "backups"
|
||||
output_dir.mkdir()
|
||||
|
||||
call_command("backup_db", output_dir=str(output_dir), prefix="test")
|
||||
|
||||
backup_file = next(iter(output_dir.glob("test-*.sql.zst")))
|
||||
backup_file: Path = next(iter(output_dir.glob("test-*.sql.zst")))
|
||||
|
||||
with (
|
||||
backup_file.open("rb") as raw_handle,
|
||||
zstd.open(raw_handle, "r") as compressed,
|
||||
io.TextIOWrapper(compressed, encoding="utf-8") as handle,
|
||||
):
|
||||
content = handle.read()
|
||||
content: str = handle.read()
|
||||
|
||||
# Should NOT contain django admin, silk, or debug toolbar tables
|
||||
assert "django_session" not in content
|
||||
assert "django_migrations" not in content
|
||||
assert "django_content_type" not in content
|
||||
assert "silk_" not in content
|
||||
assert "debug_toolbar_" not in content
|
||||
assert "django_admin_log" not in content
|
||||
assert "auth_" not in content
|
||||
assert "youtube_" not in content
|
||||
|
||||
# Should contain twitch tables
|
||||
# Should contain twitch and kick tables
|
||||
assert "twitch_" in content
|
||||
assert "kick_" in content
|
||||
|
||||
def test_backup_with_custom_prefix(self, tmp_path: Path) -> None:
|
||||
"""Test that custom prefix is used in filename."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue