Skip to content

Commit

Permalink
Updated names
Browse files Browse the repository at this point in the history
  • Loading branch information
theognis1002 committed Oct 13, 2022
1 parent 5012b70 commit 01d3623
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 217 deletions.
6 changes: 3 additions & 3 deletions apps/visualize/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.db import models
from django.utils.translation import gettext as _

from .visualizer import MigrationRenderer
from .visualizer import MigrationHistoryUtil
from django.conf import settings


Expand Down Expand Up @@ -145,10 +145,10 @@ def _record_snapshot(self):
file_name = f"{file_loc}.{self.output_format}"

try:
visualizer = MigrationRenderer(
visualizer = MigrationHistoryUtil(
None, filename=None, output_format=self.output_format
)
visualizer.render(save_loc=file_loc)
visualizer.create_snapshot(save_loc=file_loc)
self.graph_source = str(visualizer.source)
with open(file_name, "rb") as f:
self.output_file.save(file_name, File(f))
Expand Down
12 changes: 6 additions & 6 deletions apps/visualize/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def build_graph(self) -> None:
self.graph.ensure_not_cyclic()


class MigrationRenderer:
class MigrationHistoryUtil:
def __init__(
self,
*,
Expand Down Expand Up @@ -177,7 +177,7 @@ def _add_deps(self, node: Node) -> None:
else:
self._add_edges(dep, self._get_node_details(node))

def render(
def create_snapshot(
self, *, view: bool = False, temp_file: bool = False, **kwargs: Union[bool, str]
) -> None:
self._construct_digraph()
Expand All @@ -189,13 +189,13 @@ def render(


"""
from visualize.visualizer import MigrationRenderer
file = MigrationRenderer().render(temp_file=True)
from visualize.visualizer import MigrationHistoryUtil
file = MigrationHistoryUtil().create_snapshot(temp_file=True)
"""
"""
from datetime import timedelta
from django.utils import timezone
from visualize.visualizer import MigrationRenderer
from visualize.visualizer import MigrationHistoryUtil
date_end = timezone.now() - timedelta(days=365)
file = MigrationRenderer(date_end=date_end).render(temp_file=True)
file = MigrationHistoryUtil(date_end=date_end).create_snapshot(temp_file=True)
"""
4 changes: 2 additions & 2 deletions scripts/visualize.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from utils.visualizer import MigrationRenderer
from utils.visualizer import MigrationHistoryUtil


def run():
v = MigrationRenderer(output_format="jpg")
v = MigrationHistoryUtil(output_format="jpg")
print(v)
206 changes: 0 additions & 206 deletions utils/visualizer.py

This file was deleted.

0 comments on commit 01d3623

Please sign in to comment.