# Generated by Django 4.2.24 on 2025-11-02 13:59

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    dependencies = [
        ("corpuses", "0022_add_agent_instructions"),
    ]

    operations = [
        migrations.CreateModel(
            name="CorpusEngagementMetrics",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "total_threads",
                    models.IntegerField(
                        default=0,
                        help_text="Total number of discussion threads in this corpus",
                    ),
                ),
                (
                    "active_threads",
                    models.IntegerField(
                        default=0,
                        help_text="Number of active (not locked/deleted) threads",
                    ),
                ),
                (
                    "total_messages",
                    models.IntegerField(
                        default=0,
                        help_text="Total number of messages across all threads",
                    ),
                ),
                (
                    "messages_last_7_days",
                    models.IntegerField(
                        default=0,
                        help_text="Number of messages posted in the last 7 days",
                    ),
                ),
                (
                    "messages_last_30_days",
                    models.IntegerField(
                        default=0,
                        help_text="Number of messages posted in the last 30 days",
                    ),
                ),
                (
                    "unique_contributors",
                    models.IntegerField(
                        default=0,
                        help_text="Total number of unique users who have posted messages",
                    ),
                ),
                (
                    "active_contributors_30_days",
                    models.IntegerField(
                        default=0,
                        help_text="Number of users who posted in the last 30 days",
                    ),
                ),
                (
                    "total_upvotes",
                    models.IntegerField(
                        default=0,
                        help_text="Total upvotes across all messages in this corpus",
                    ),
                ),
                (
                    "avg_messages_per_thread",
                    models.FloatField(
                        default=0.0, help_text="Average number of messages per thread"
                    ),
                ),
                (
                    "last_updated",
                    models.DateTimeField(
                        auto_now=True,
                        help_text="Timestamp when metrics were last calculated",
                    ),
                ),
                (
                    "corpus",
                    models.OneToOneField(
                        help_text="The corpus these metrics belong to",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="engagement_metrics",
                        to="corpuses.corpus",
                    ),
                ),
            ],
            options={
                "verbose_name": "Corpus Engagement Metrics",
                "verbose_name_plural": "Corpus Engagement Metrics",
                "indexes": [
                    models.Index(
                        fields=["corpus", "last_updated"],
                        name="corpuses_co_corpus__8a13d9_idx",
                    )
                ],
            },
        ),
    ]
