mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-18 00:55:50 +00:00
refactor(tasks): Add is_catchup and catchup_days fields to Stream processing logic. Update existing stream queries and conditions to handle new catch-up properties, ensuring accurate updates and memory management for bulk operations.
This commit is contained in:
parent
931f4dc50f
commit
ec8594cd0a
1 changed files with 16 additions and 4 deletions
|
|
@ -1089,7 +1089,7 @@ def process_xc_category_direct(account_id, batch, groups, hash_keys):
|
|||
existing_streams = {
|
||||
s.stream_hash: s
|
||||
for s in Stream.objects.filter(stream_hash__in=stream_hashes.keys()).select_related('m3u_account').only(
|
||||
'id', 'stream_hash', 'name', 'url', 'logo_url', 'tvg_id', 'custom_properties', 'last_seen', 'updated_at', 'm3u_account', 'stream_id', 'stream_chno', 'channel_group_id'
|
||||
'id', 'stream_hash', 'name', 'url', 'logo_url', 'tvg_id', 'custom_properties', 'last_seen', 'updated_at', 'm3u_account', 'stream_id', 'stream_chno', 'channel_group_id', 'is_catchup', 'catchup_days'
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -1106,9 +1106,15 @@ def process_xc_category_direct(account_id, batch, groups, hash_keys):
|
|||
obj.is_adult != stream_props["is_adult"] or
|
||||
obj.stream_id != stream_props["stream_id"] or
|
||||
obj.stream_chno != stream_props["stream_chno"] or
|
||||
obj.channel_group_id != stream_props["channel_group_id"]
|
||||
obj.channel_group_id != stream_props["channel_group_id"] or
|
||||
obj.is_catchup != stream_props["is_catchup"] or
|
||||
obj.catchup_days != stream_props["catchup_days"]
|
||||
)
|
||||
|
||||
# Keep denormalized catch-up columns in memory (bulk_update reads them).
|
||||
obj.is_catchup = stream_props["is_catchup"]
|
||||
obj.catchup_days = stream_props["catchup_days"]
|
||||
|
||||
if changed:
|
||||
for key, value in stream_props.items():
|
||||
setattr(obj, key, value)
|
||||
|
|
@ -1322,7 +1328,7 @@ def process_m3u_batch_direct(account_id, batch, groups, hash_keys):
|
|||
existing_streams = {
|
||||
s.stream_hash: s
|
||||
for s in Stream.objects.filter(stream_hash__in=stream_hashes.keys()).select_related('m3u_account').only(
|
||||
'id', 'stream_hash', 'name', 'url', 'logo_url', 'tvg_id', 'custom_properties', 'last_seen', 'updated_at', 'm3u_account', 'stream_id', 'stream_chno', 'channel_group_id'
|
||||
'id', 'stream_hash', 'name', 'url', 'logo_url', 'tvg_id', 'custom_properties', 'last_seen', 'updated_at', 'm3u_account', 'stream_id', 'stream_chno', 'channel_group_id', 'is_catchup', 'catchup_days'
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -1339,9 +1345,15 @@ def process_m3u_batch_direct(account_id, batch, groups, hash_keys):
|
|||
obj.is_adult != stream_props["is_adult"] or
|
||||
obj.stream_id != stream_props["stream_id"] or
|
||||
obj.stream_chno != stream_props["stream_chno"] or
|
||||
obj.channel_group_id != stream_props["channel_group_id"]
|
||||
obj.channel_group_id != stream_props["channel_group_id"] or
|
||||
obj.is_catchup != stream_props["is_catchup"] or
|
||||
obj.catchup_days != stream_props["catchup_days"]
|
||||
)
|
||||
|
||||
# Keep denormalized catch-up columns in memory (bulk_update reads them).
|
||||
obj.is_catchup = stream_props["is_catchup"]
|
||||
obj.catchup_days = stream_props["catchup_days"]
|
||||
|
||||
# Always update last_seen
|
||||
obj.last_seen = timezone.now()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue