Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

906 B
Raw Blame
from django.db import models

from posthog.models.scoping.root_mixin import TeamScopedRootMixin
from posthog.models.utils import UUIDModel


class SignalRatedUsage(TeamScopedRootMixin, UUIDModel):
    # Keep the first delivery's identity even if its project moves or is deleted.
    team_id = models.BigIntegerField()
    organization_id = models.UUIDField()
    day = models.DateField(db_index=True)
    cents = models.PositiveBigIntegerField()
    reported_at = models.DateTimeField(null=True)

    class Meta:
        indexes = [
            models.Index(fields=["organization_id", "day"], name="signals_rated_usage_org_day"),
            models.Index(
                fields=["day"], condition=models.Q(reported_at__isnull=True), name="signals_rated_usage_pending"
            ),
        ]
        constraints = [models.UniqueConstraint(fields=["team_id", "day"], name="signals_rated_usage_team_day")]