Skip to content

Commit

Permalink
feat: Added TreeDepth function to extract depth
Browse files Browse the repository at this point in the history
  • Loading branch information
mireq committed Apr 15, 2024
1 parent f644cb5 commit ab24f77
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions common_utils/models.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from django.core.management.color import no_style
from django.db import models, connection
from django.db.models import Expression
from django.utils import timezone


Expand Down Expand Up @@ -32,3 +33,11 @@ def sql_sequence_reset(model_classes):
c.execute(statement)
finally:
c.close()


class TreeDepth(Expression):
def __init__(self):
super().__init__(output_field=models.IntegerField())

def as_sql(self, compiler, connection): # pylint: disable=unused-argument
return "__tree.tree_depth", []

0 comments on commit ab24f77

Please sign in to comment.