aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstuppie2026-10-26 11:16:51 -0600
committerstuppie2026-10-26 11:16:51 -0600
commitbcb4a8e9bdb310a9edd7574f5ecdc90de53026c6 (patch)
treef1ce81216467ee4c5b8e0dfaec3c4664f0d0181a
parent427c8a9aa364378ea65644a6b4d8d0349ad0e777 (diff)
downloadgeneralresearch-bcb4a8e9bdb310a9edd7574f5ecdc90de53026c6.tar.gz
generalresearch-bcb4a8e9bdb310a9edd7574f5ecdc90de53026c6.zip
new timestamp fields on user table
-rw-r--r--generalresearch/thl_django/common/models.py38
1 files changed, 32 insertions, 6 deletions
diff --git a/generalresearch/thl_django/common/models.py b/generalresearch/thl_django/common/models.py
index afbe722..6f8f813 100644
--- a/generalresearch/thl_django/common/models.py
+++ b/generalresearch/thl_django/common/models.py
@@ -305,14 +305,25 @@ class THLUser(models.Model):
# This will be useful for looking at signups per country globally.
created = models.DateTimeField(null=False)
- # This will be useful as our Daily Active User metric (DAU) that a lot
- # of marketplaces want reported on. We'll be able to change the
- # logic for when this is updated, but keeping it in a table will
- # make queries much easier.
- # We'll force null=True, and his will be the same as created
- # until they're "seen again".
+ # The most recent time the user started a task or returned from a marketplace
+ # redirect. This is initialized to `created` and can be used to report users
+ # who were recently active in tasks.
last_seen = models.DateTimeField(null=False)
+ # The time the user most recently completed a task.
+ last_task_completed_at = models.DateTimeField(null=True)
+
+ # The time of the user's most recent offerwall request. Database writes are
+ # rate-limited through Redis to at most once per minute to reduce table churn,
+ # so this value may lag the latest request by up to one minute.
+ last_offerwall_requested_at = models.DateTimeField(null=True)
+
+ # The time the user most recently submitted profiling answers, either during
+ # a GRS session or directly through the API. Database writes are rate-limited
+ # through Redis to at most once per minute, so this value may lag the latest
+ # submission by up to one minute.
+ last_profiling_submission_at = models.DateTimeField(null=True)
+
# this isn't used for any security measures, but we have an increasing
# need to provide a "live panel book" to describe our user base. This
# will help immediately filter users down by "after users from X country
@@ -352,6 +363,21 @@ class THLUser(models.Model):
# models.Index(fields=["product_id", "product_user_id"]),
models.Index(fields=["created"]),
models.Index(fields=["last_seen"]),
+ models.Index(
+ fields=["last_task_completed_at"],
+ name="thl_user_last_task_comp_nn",
+ condition=Q(last_task_completed_at__isnull=False),
+ ),
+ models.Index(
+ fields=["last_offerwall_requested_at"],
+ name="thl_user_last_offerwall_nn",
+ condition=Q(last_offerwall_requested_at__isnull=False),
+ ),
+ models.Index(
+ fields=["last_profiling_submission_at"],
+ name="thl_user_last_profile_nn",
+ condition=Q(last_profiling_submission_at__isnull=False),
+ ),
models.Index(fields=["last_country_iso"]),
]