mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
The tree was a debranded snapshot of upstream taken around 2026-02-20, and upstream has moved about five months since. This replaces it with upstream master, mechanically re-derived: bin/debrand does the rename, and the pipeline and squashed migrations are restored from the shipped tree. Not a merge. The previous import replaced the tree wholesale in a single commit, so there is no shared content history to merge against. Reproducing the rename on the new tree is what actually converges. What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints, compose files, LLM.md, and insights/migrations. The squashed initial migration is load-bearing — the live database records it by name, so upstream's ~918 individual migrations cannot come back. Nine products are dropped as unreferenced. Twenty-one more that we do not run are kept anyway because the core app still imports them; unpicking those is a refactor and does not belong in a rebase. This base does not build yet, and the reasons are not in the rename: upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against our 4.2, and the dependency manifests still name upstream packages that we republish under our own names. Those are decisions, not renames.
68 lines
3.0 KiB
Python
68 lines
3.0 KiB
Python
from typing import Optional
|
|
|
|
from django.db import models
|
|
from django.utils import timezone
|
|
|
|
from django_deprecate_fields import deprecate_field
|
|
|
|
from insights.models.activity_logging.model_activity import ModelActivityMixin
|
|
|
|
|
|
class Annotation(ModelActivityMixin, models.Model):
|
|
class Scope(models.TextChoices):
|
|
INSIGHT = "dashboard_item", "insight"
|
|
DASHBOARD = "dashboard", "dashboard"
|
|
PROJECT = "project", "project"
|
|
ORGANIZATION = "organization", "organization"
|
|
RECORDING = "recording", "recording"
|
|
|
|
class CreationType(models.TextChoices):
|
|
USER = "USR", "user"
|
|
GITHUB = "GIT", "GitHub"
|
|
|
|
content = models.CharField(max_length=8192, null=True, blank=True)
|
|
created_at = models.DateTimeField(default=timezone.now, null=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
dashboard_item = models.ForeignKey("product_analytics.Insight", on_delete=models.SET_NULL, null=True, blank=True)
|
|
dashboard = models.ForeignKey("dashboards.Dashboard", on_delete=models.SET_NULL, null=True, blank=True)
|
|
team = models.ForeignKey("insights.Team", on_delete=models.CASCADE)
|
|
organization = models.ForeignKey("insights.Organization", on_delete=models.CASCADE, null=True)
|
|
created_by = models.ForeignKey("insights.User", on_delete=models.SET_NULL, null=True, blank=True)
|
|
scope = models.CharField(max_length=24, choices=Scope, default=Scope.INSIGHT)
|
|
# Optional emoji shown in place of the default badge when surfacing the annotation.
|
|
# Long enough to hold a single multi-codepoint grapheme (ZWJ sequences, skin-tone modifiers).
|
|
emoji = models.CharField(max_length=16, null=True, blank=True)
|
|
creation_type = models.CharField(max_length=3, choices=CreationType, default=CreationType.USER)
|
|
date_marker = models.DateTimeField(null=True, blank=True)
|
|
deleted = models.BooleanField(default=False)
|
|
hidden_in_user_interface = models.BooleanField(null=True, blank=True)
|
|
|
|
# DEPRECATED: replaced by scope
|
|
apply_all = models.BooleanField(null=True)
|
|
# DEPRECATED: moved to the comment model
|
|
recording_id = deprecate_field(models.UUIDField(null=True, blank=True))
|
|
# DEPRECATED: moved to the comment model
|
|
is_emoji = deprecate_field(models.BooleanField(default=False, null=True, blank=True))
|
|
|
|
class Meta:
|
|
db_table = "insights_annotation"
|
|
|
|
@property
|
|
def insight_short_id(self) -> Optional[str]:
|
|
return self.dashboard_item.short_id if self.dashboard_item is not None else None
|
|
|
|
@property
|
|
def insight_name(self) -> Optional[str]:
|
|
return self.dashboard_item.name if self.dashboard_item is not None else None
|
|
|
|
@property
|
|
def insight_derived_name(self) -> Optional[str]:
|
|
return self.dashboard_item.derived_name if self.dashboard_item is not None else None
|
|
|
|
@property
|
|
def dashboard_name(self) -> Optional[str]:
|
|
return self.dashboard.name if self.dashboard is not None else None
|
|
|
|
def get_analytics_metadata(self):
|
|
return {"scope": str(self.scope), "date_marker": self.date_marker}
|