Coverage for functions \ flipdare \ generated \ shared \ backend \ app_job_type.py: 100%
0 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
1#!/usr/bin/env python
2#
3# Copyright (c) 2026 Flipdare Pty Ltd. All rights reserved.
4#
5# This file is part of Flipdare's proprietary software and contains
6# confidential and copyrighted material. Unauthorised copying,
7# modification, distribution, or use of this file is strictly
8# prohibited without prior written permission from Flipdare Pty Ltd.
9#
10# This software includes third-party components licensed under MIT,
11# BSD, and Apache 2.0 licences. See THIRD_PARTY_NOTICES for details.
12#
13# NOTE: THIS FILE IS AUTO GENERATED. DO NOT EDIT.
14#
15# Generated by codegen_models.py
16#
17# Modify 'codegen_models.py'
18# and re-run the script above to update.
19#
21# pragma: no cover
23from enum import StrEnum
24from flipdare.generated.shared.backend.app_report_priority import AppReportPriority
25from flipdare.generated.shared.app_log_category import AppLogCategory
26from flipdare.generated.shared.backend.app_job_group import AppJobGroup
27from flipdare.generated.shared.firestore_collections import FirestoreCollections
30class AppJobType(StrEnum):
31 """App Job Type"""
33 # Declared here so type-checkers know these attributes exist.
34 # They are populated per-member inside __new__.
35 _description: str
36 _priority: AppReportPriority
37 _category: AppLogCategory
38 _job_group: AppJobGroup
39 _default_collection: FirestoreCollections
41 def __new__(
42 cls,
43 code: str,
44 description: str | None = None,
45 priority: AppReportPriority | None = None,
46 category: AppLogCategory | None = None,
47 job_group: AppJobGroup | None = None,
48 default_collection: FirestoreCollections | None = None,
49 ) -> "AppJobType":
50 obj = str.__new__(cls, code)
51 obj._value_ = code
52 # Only set attributes if they are provided (during member definition)
53 if description is not None:
54 obj._description = description
55 if priority is not None:
56 obj._priority = priority
57 if category is not None:
58 obj._category = category
59 if job_group is not None:
60 obj._job_group = job_group
61 if default_collection is not None:
62 obj._default_collection = default_collection
63 return obj
65 # ---- Members --------------------------------------------------------
66 # fmt: off
67 SCHED_TWO_MINS = ("fn_two_minutes", "Scheduled 2 mins cron.", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.SCHEDULED, FirestoreCollections.APP_JOB)
68 SCHED_FIVE_MINS = ("fn_five_minutes", "Scheduled 5 mins cron.", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.SCHEDULED, FirestoreCollections.APP_JOB)
69 SCHED_FIFTEEN_MINS = ("fn_fifteen_minutes", "Scheduled 15 mins cron.", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.SCHEDULED, FirestoreCollections.APP_JOB)
70 SCHED_ONE_HOUR = ("fn_one_hour", "Scheduled 1 hour cron.", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.SCHEDULED, FirestoreCollections.APP_JOB)
71 SCHED_TWO_HOURS = ("fn_two_hours", "Scheduled 2 hours cron.", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.SCHEDULED, FirestoreCollections.APP_JOB)
72 SCHED_FOUR_HOURS = ("fn_four_hours", "Scheduled 4 hours cron.", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.SCHEDULED, FirestoreCollections.APP_JOB)
73 SCHED_SIX_HOURS = ("fn_six_hours", "Scheduled 6 hours cron.", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.SCHEDULED, FirestoreCollections.APP_JOB)
74 SCHED_TWELVE_HOURS = ("fn_twelve_hours", "Scheduled 12 hours cron.", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.SCHEDULED, FirestoreCollections.APP_JOB)
75 SCHED_ONE_DAY = ("fn_one_day", "Scheduled 1 day cron.", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.SCHEDULED, FirestoreCollections.APP_JOB)
76 SCHED_THREE_DAYS = ("fn_three_days", "Scheduled 3 days cron.", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.SCHEDULED, FirestoreCollections.APP_JOB)
77 SCHED_ONE_WEEK = ("fn_one_week", "Scheduled 1 week cron.", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.SCHEDULED, FirestoreCollections.APP_JOB)
78 TR_USER = ("tr_user", "Trigger related to user actions (e.g. registration, profile update, etc)", AppReportPriority.HIGH, AppLogCategory.TRIGGER, AppJobGroup.USER_TRIGGER, FirestoreCollections.USER)
79 TR_USER_ANONYMIZE = ("tr_user_anonymize", "Trigger for anonymizing user data (e.g. due to GDPR request)", AppReportPriority.HIGH, AppLogCategory.COMPLIANCE, AppJobGroup.COMPLIANCE_CRON, FirestoreCollections.COMPLIANCE)
80 TR_INVITE = ("tr_invite", "Trigger related to invites (e.g. invite sent, invite accepted, etc)", AppReportPriority.LOW, AppLogCategory.TRIGGER, AppJobGroup.USER_TRIGGER, FirestoreCollections.USER)
81 TR_GROUP = ("tr_group", "Trigger related to group actions (e.g. group creation, group update, etc)", AppReportPriority.HIGH, AppLogCategory.TRIGGER, AppJobGroup.GROUP_TRIGGER, FirestoreCollections.GROUP)
82 TR_GROUP_MEMBER = ("tr_group_member", "Trigger related to group member actions (e.g. member added, member removed, etc)", AppReportPriority.HIGH, AppLogCategory.TRIGGER, AppJobGroup.GROUP_TRIGGER, FirestoreCollections.GROUP)
83 TR_CONTENT = ("tr_content", "Trigger related to content actions (e.g. content created, content updated, etc)", AppReportPriority.HIGH, AppLogCategory.CONTENT, AppJobGroup.CONTENT_TRIGGER, FirestoreCollections.CONTENT)
84 TR_CONTENT_DELETE = ("tr_content_delete", "Trigger related to content deletion actions (e.g. content deleted, content removed, etc)", AppReportPriority.HIGH, AppLogCategory.COMPLIANCE, AppJobGroup.COMPLIANCE_CRON, FirestoreCollections.COMPLIANCE)
85 TR_FRIEND = ("tr_friend", "Trigger related to friend actions (e.g. friend request sent, friend request accepted, etc)", AppReportPriority.MEDIUM, AppLogCategory.TRIGGER, AppJobGroup.FRIEND_TRIGGER, FirestoreCollections.FRIEND)
86 TR_CHAT = ("tr_chat", "Trigger related to chat actions (e.g. chat message sent, chat message received, etc)", AppReportPriority.MEDIUM, AppLogCategory.TRIGGER, AppJobGroup.CHAT_TRIGGER, FirestoreCollections.CHAT)
87 TR_CHAT_DELETE = ("tr_chat_delete", "Trigger related to chat deletion actions (e.g. chat message deleted, chat conversation deleted, etc)", AppReportPriority.MEDIUM, AppLogCategory.COMPLIANCE, AppJobGroup.COMPLIANCE_CRON, FirestoreCollections.COMPLIANCE)
88 TR_DARE = ("tr_dare", "Trigger related to dare actions (e.g. dare created, dare updated, etc)", AppReportPriority.HIGH, AppLogCategory.TRIGGER, AppJobGroup.DARE_TRIGGER, FirestoreCollections.DARE)
89 TR_DARE_DELETE = ("tr_dare_delete", "Trigger related to dare deletion actions (e.g. dare deleted, dare removed, etc)", AppReportPriority.HIGH, AppLogCategory.COMPLIANCE, AppJobGroup.COMPLIANCE_CRON, FirestoreCollections.COMPLIANCE)
90 TR_PLEDGE = ("tr_pledge", "Trigger related to pledge actions (e.g. pledge created, pledge updated, etc)", AppReportPriority.CRITICAL, AppLogCategory.PAYMENT, AppJobGroup.PLEDGE_TRIGGER, FirestoreCollections.PLEDGE)
91 TR_PLEDGE_DELETE = ("tr_pledge_delete", "Trigger related to pledge deletion actions (e.g. pledge deleted, pledge removed, etc)", AppReportPriority.CRITICAL, AppLogCategory.COMPLIANCE, AppJobGroup.COMPLIANCE_CRON, FirestoreCollections.COMPLIANCE)
92 TR_FLAG = ("tr_flag", "Trigger related to flag actions (e.g. flag created, flag updated, etc)", AppReportPriority.CRITICAL, AppLogCategory.TRIGGER, AppJobGroup.FLAG_TRIGGER, FirestoreCollections.FLAG)
93 CR_USER_UNPROCESSED = ("cr_user_unprocessed", "Cron job for processing unprocessed users", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.USER_CRON, FirestoreCollections.USER)
94 CR_USER_DAILY_SUMMARY = ("cr_user_daily_summary", "Daily email containing user activity summary", AppReportPriority.HIGH, AppLogCategory.REPORTING, AppJobGroup.USER_CRON, FirestoreCollections.USER_SUMMARY)
95 CR_USER_DECAY_REPUTATION = ("cr_user_decay_reputation", "Gradually restore reputation scores toward baseline", AppReportPriority.HIGH, AppLogCategory.SAFETY, AppJobGroup.USER_CRON, FirestoreCollections.USER)
96 CR_GROUP_UNPROCESSED = ("cr_group_unprocessed", "Cron job for processing unprocessed groups", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.GROUP_CRON, FirestoreCollections.GROUP)
97 CR_GROUP_MEMBER_UNPROCESSED = ("cr_group_member_unprocessed", "Cron job for processing unprocessed group members", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.GROUP_CRON, FirestoreCollections.GROUP_MEMBER)
98 CR_GROUP_MEMBER_STATUS_UNPROCESSED = ("cr_group_member_status_unprocessed", "Cron job for processing unprocessed group member statuses", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.GROUP_CRON, FirestoreCollections.GROUP_MEMBER)
99 CR_CONTENT_UNPROCESSED = ("cr_content_unprocessed", "Cron job for processing unprocessed content", AppReportPriority.HIGH, AppLogCategory.CONTENT, AppJobGroup.CONTENT_CRON, FirestoreCollections.CONTENT)
100 CR_INVITE_UNPROCESSED = ("cr_invite_unprocessed", "Cron job for processing unprocessed invites", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.USER_CRON, FirestoreCollections.INVITE)
101 CR_INVITE_REMINDER = ("cr_invite_reminder", "Cron job for sending invite reminders", AppReportPriority.LOW, AppLogCategory.CRON, AppJobGroup.USER_CRON, FirestoreCollections.INVITE)
102 CR_FRIEND_UNPROCESSED = ("cr_friend_unprocessed", "Cron job for processing unprocessed friends", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.FRIEND_CRON, FirestoreCollections.FRIEND)
103 CR_DARE_VOTE = ("cr_dare_vote", "Determine whether votes can be accepted, rejected, or auto-processed", AppReportPriority.CRITICAL, AppLogCategory.CRON, AppJobGroup.DARE_CRON, FirestoreCollections.DARE)
104 CR_DARE_UNPROCESSED = ("cr_dare_unprocessed", "Cron job for processing unprocessed dares", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.DARE_CRON, FirestoreCollections.DARE)
105 CR_PAYMENT_UNPROCESSED = ("cr_payment_unprocessed", "Cron job for processing unprocessed new payments if required", AppReportPriority.CRITICAL, AppLogCategory.PAYMENT, AppJobGroup.PAYMENT_CRON, FirestoreCollections.PLEDGE)
106 CR_REFUND_UNPROCESSED = ("cr_refund_unprocessed", "Cron job for processing unprocessed pledge refunds if required", AppReportPriority.CRITICAL, AppLogCategory.PAYMENT, AppJobGroup.PAYMENT_CRON, FirestoreCollections.PLEDGE)
107 CR_PAYMENT_REAUTHORIZE = ("cr_payment_reauthorize", "Cron job for reauthorizing payments.", AppReportPriority.CRITICAL, AppLogCategory.PAYMENT, AppJobGroup.PAYMENT_CRON, FirestoreCollections.PLEDGE)
108 CR_PAYMENT_CAPTURE = ("cr_payment_capture", "Cron job for capturing payments.", AppReportPriority.CRITICAL, AppLogCategory.PAYMENT, AppJobGroup.PAYMENT_CRON, FirestoreCollections.PLEDGE)
109 CR_PAYMENT_TRANSFER = ("cr_payment_transfer", "Cron job for transferring payments.", AppReportPriority.CRITICAL, AppLogCategory.PAYMENT, AppJobGroup.PAYMENT_CRON, FirestoreCollections.PLEDGE)
110 CR_PAYMENT_REFUND = ("cr_payment_refund", "Cron job for refunding payments.", AppReportPriority.CRITICAL, AppLogCategory.PAYMENT, AppJobGroup.PAYMENT_CRON, FirestoreCollections.PLEDGE)
111 CR_FLAG_UNPROCESSED = ("cr_flag_unprocessed", "Cron job for processing unprocessed flags", AppReportPriority.CRITICAL, AppLogCategory.SAFETY, AppJobGroup.FLAG_CRON, FirestoreCollections.FLAG)
112 CR_RESTRICT_INACTIVE = ("cr_restrict_inactive", "Cron job for processing inactive restrictions", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.RESTRICTION_CRON, FirestoreCollections.RESTRICTION)
113 CR_RESTRICT_EXPIRED = ("cr_restrict_expired", "Cron job for notifying users and lifting expired restrictions", AppReportPriority.HIGH, AppLogCategory.CRON, AppJobGroup.RESTRICTION_CRON, FirestoreCollections.RESTRICTION)
114 COMMAND_UPDATE_EXCHANGE_RATE = ("command_update_exchange_rate", "Update currency exchange rates for dare calculations", AppReportPriority.HIGH, AppLogCategory.API, AppJobGroup.SYSTEM_CRON, FirestoreCollections.EXCHANGE_RATE)
115 COMMAND_TYPESENSE_COMPACT = ("command_typesense_compact", "Typesense Compact - Remove deleted records from Typesense indexes", AppReportPriority.HIGH, AppLogCategory.CONFIG, AppJobGroup.SYSTEM_CRON, FirestoreCollections.APP_LOG)
116 COMMAND_TYPESENSE_REINDEX = ("command_typesense_reindex", "Typesense Reindex - Rebuild Typesense indexes for improved search performance", AppReportPriority.HIGH, AppLogCategory.CONFIG, AppJobGroup.SYSTEM_CRON, FirestoreCollections.APP_LOG)
117 COMMAND_FIREBASE_CLEANUP = ("command_firebase_cleanup", "Cleanup Firebase - Remove old or orphaned data from Firebase collections", AppReportPriority.HIGH, AppLogCategory.CONFIG, AppJobGroup.SYSTEM_CRON, FirestoreCollections.APP_LOG)
118 REPORT_DARE_REVIEW_REQUIRED = ("report_dare_review_required", "Recent dares needing admin review (e.g. due to content flag or other issue)", AppReportPriority.HIGH, AppLogCategory.SAFETY, AppJobGroup.DARE_CRON, FirestoreCollections.DARE)
119 REPORT_DARE_AUTO_RESTRICTED = ("report_dare_auto_restricted", "Recent dares automatically restricted by the system (e.g. due to multiple flags) needing admin review", AppReportPriority.HIGH, AppLogCategory.SAFETY, AppJobGroup.DARE_CRON, FirestoreCollections.DARE)
120 REPORT_ISSUE_WAITING_ADMIN = ("report_issue_waiting_admin", "Recent issues waiting for admin review", AppReportPriority.HIGH, AppLogCategory.SAFETY, AppJobGroup.ISSUE_CRON, FirestoreCollections.ISSUE)
121 REPORT_PAYMENT_ISSUE_WAITING_ADMIN = ("report_payment_issue_waiting_admin", "Recent payment issues waiting for admin review", AppReportPriority.HIGH, AppLogCategory.PAYMENT, AppJobGroup.ISSUE_CRON, FirestoreCollections.PAYMENT_ISSUE)
122 REPORT_RESTRICT_AUTO_NOT_PERMANENT = ("report_restrict_auto_not_permanent", "Report users auto-restricted due to multiple flags but not permanently and not acknowledged by admin", AppReportPriority.MEDIUM, AppLogCategory.SAFETY, AppJobGroup.RESTRICTION_CRON, FirestoreCollections.RESTRICTION)
123 REPORT_RESTRICT_AUTO_PERMANENT = ("report_restrict_auto_permanent", "Report users permanently auto-restricted but not acknowledged by admin", AppReportPriority.HIGH, AppLogCategory.SAFETY, AppJobGroup.RESTRICTION_CRON, FirestoreCollections.RESTRICTION)
124 REPORT_RESTRICT_INACTIVE = ("report_restrict_inactive", "Report users with inactive restrictions needing admin review for potential lifting", AppReportPriority.HIGH, AppLogCategory.SAFETY, AppJobGroup.RESTRICTION_CRON, FirestoreCollections.RESTRICTION)
125 REPORT_FLAG_UNACKNOWLEDGED = ("report_flag_unacknowledged", "Recent unacknowledged flags needing admin review", AppReportPriority.HIGH, AppLogCategory.SAFETY, AppJobGroup.FLAG_CRON, FirestoreCollections.FLAG)
126 REPORT_FLAG_DISPUTED_WAITING_ADMIN = ("report_flag_disputed_waiting_admin", "Recent disputed flags waiting for admin review", AppReportPriority.HIGH, AppLogCategory.SAFETY, AppJobGroup.FLAG_CRON, FirestoreCollections.FLAG)
127 REPORT_PAYMENT_STATS = ("report_payment_stats", "Recent payments with issues (e.g. failed reauthorization, failed capture, failed release, failed refund, etc) needing admin review", AppReportPriority.CRITICAL, AppLogCategory.PAYMENT, AppJobGroup.PAYMENT_CRON, FirestoreCollections.PLEDGE)
128 REPORT_PAYMENT_CRITICAL_ISSUES = ("report_payment_critical_issues", "Every 4 hours, report critical payment issues such as failed refunds or potential loss of funds", AppReportPriority.CRITICAL, AppLogCategory.PAYMENT, AppJobGroup.REPORT_CRON, FirestoreCollections.PAYMENT_ISSUE)
129 REPORT_LOG_STATS = ("report_log_stats", "Daily stats for the log_db.", AppReportPriority.HIGH, AppLogCategory.REPORTING, AppJobGroup.REPORT_CRON, FirestoreCollections.APP_STAT)
130 REPORT_ERROR_STATS = ("report_error_stats", "Daily error statistics for models.", AppReportPriority.HIGH, AppLogCategory.REPORTING, AppJobGroup.REPORT_CRON, FirestoreCollections.APP_STAT)
131 REPORT_JOB_TYPE_STATS = ("report_job_type_stats", "Weekly performance statistics by AppJobType.", AppReportPriority.HIGH, AppLogCategory.REPORTING, AppJobGroup.REPORT_CRON, FirestoreCollections.APP_STAT)
132 # fmt: on
133 # ---- Properties -----------------------------------------------------
134 @property
135 def description(self) -> str:
136 return self._description
138 @property
139 def priority(self) -> AppReportPriority:
140 return self._priority
142 @property
143 def category(self) -> AppLogCategory:
144 return self._category
146 @property
147 def job_group(self) -> AppJobGroup:
148 return self._job_group
150 @property
151 def default_collection(self) -> FirestoreCollections:
152 return self._default_collection
154 # ---- Convenience predicates -----------------------------------------
156 @property
157 def short_description(self) -> str:
158 flds = self.name.lower().split("_")
159 return " ".join([fld.capitalize() for fld in flds])
161 @property
162 def label(self) -> str:
163 return self.short_description
165 @property
166 def is_scheduled(self) -> bool:
167 from flipdare.job_types import is_scheduled_job
169 return is_scheduled_job(self)
171 @property
172 def is_trigger(self) -> bool:
173 from flipdare.job_types import is_trigger_job
175 return is_trigger_job(self)
177 @property
178 def is_task(self) -> bool:
179 from flipdare.job_types import is_cron_job, is_command_job, is_report_job
181 return is_cron_job(self) or is_command_job(self) or is_report_job(self)
183 @property
184 def is_cron(self) -> bool:
185 from flipdare.job_types import is_cron_job
187 return is_cron_job(self)
189 @property
190 def is_command(self) -> bool:
191 from flipdare.job_types import is_command_job
193 return is_command_job(self)
195 @property
196 def is_report(self) -> bool:
197 from flipdare.job_types import is_report_job
199 return is_report_job(self)