mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2026-09-25 06:46:11 +00:00
Merge branch '2877-update-checked-time' into only-call-send_content_changed_notification-on-change
This commit is contained in:
@@ -253,11 +253,11 @@ class update_worker(threading.Thread):
|
||||
pass
|
||||
|
||||
else:
|
||||
fetch_start_time = time.time()
|
||||
uuid = queued_item_data.item.get('uuid')
|
||||
self.current_uuid = uuid
|
||||
if uuid in list(self.datastore.data['watching'].keys()) and self.datastore.data['watching'][uuid].get('url'):
|
||||
changed_detected = False
|
||||
fetch_start_time = round(time.time()) # Also used a key in history.txt
|
||||
contents = b''
|
||||
process_changedetection_results = True
|
||||
update_obj = {}
|
||||
@@ -286,6 +286,11 @@ class update_worker(threading.Thread):
|
||||
)
|
||||
|
||||
update_handler.call_browser()
|
||||
|
||||
# In reality, the actual time of when the change was detected could be a few seconds after this
|
||||
# For example it should include when the page stopped rendering if using a playwright/chrome type fetch
|
||||
fetch_start_time = time.time()
|
||||
|
||||
changed_detected, update_obj, contents = update_handler.run_changedetection(watch=watch)
|
||||
|
||||
# Re #342
|
||||
@@ -538,6 +543,7 @@ class update_worker(threading.Thread):
|
||||
|
||||
# Small hack so that we sleep just enough to allow 1 second between history snapshots
|
||||
# this is because history.txt indexes/keys snapshots by epoch seconds and we dont want dupe keys
|
||||
# @also - the keys are one per second at the most (for now)
|
||||
if watch.newest_history_key and int(fetch_start_time) == int(watch.newest_history_key):
|
||||
logger.warning(
|
||||
f"Timestamp {fetch_start_time} already exists, waiting 1 seconds so we have a unique key in history.txt")
|
||||
@@ -545,14 +551,14 @@ class update_worker(threading.Thread):
|
||||
time.sleep(1)
|
||||
|
||||
watch.save_history_text(contents=contents,
|
||||
timestamp=fetch_start_time,
|
||||
timestamp=int(fetch_start_time),
|
||||
snapshot_id=update_obj.get('previous_md5', 'none'))
|
||||
|
||||
|
||||
empty_pages_are_a_change = self.datastore.data['settings']['application'].get('empty_pages_are_a_change', False)
|
||||
if update_handler.fetcher.content or (not update_handler.fetcher.content and empty_pages_are_a_change):
|
||||
# attribute .last_changed is then based on this data
|
||||
watch.save_last_fetched_html(contents=update_handler.fetcher.content, timestamp=fetch_start_time)
|
||||
watch.save_last_fetched_html(contents=update_handler.fetcher.content, timestamp=int(fetch_start_time))
|
||||
|
||||
# Notifications should only trigger on the second time (first time, we gather the initial snapshot)
|
||||
if watch.history_n >= 2:
|
||||
@@ -580,7 +586,7 @@ class update_worker(threading.Thread):
|
||||
pass
|
||||
|
||||
self.datastore.update_watch(uuid=uuid, update_obj={'fetch_time': round(time.time() - fetch_start_time, 3),
|
||||
'last_checked': fetch_start_time,
|
||||
'last_checked': int(fetch_start_time),
|
||||
'check_count': count
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user