Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to limit history number of snapshots by count or by age #2722

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changedetectionio/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ class globalSettingsApplicationForm(commonSettingsForm):
global_ignore_text = StringListField('Ignore Text', [ValidateListRegex()])
global_subtractive_selectors = StringListField('Remove elements', [ValidateCSSJSONXPATHInput(allow_json=False)])
ignore_whitespace = BooleanField('Ignore whitespace')
keep_history_n = IntegerField('Number of snapshots to keep in history for each watch')
keep_history_seconds = IntegerField('Number of snapshots to keep - maximum age (todo/seconds)')
password = SaltyPasswordField()
pager_size = IntegerField('Pager size',
render_kw={"style": "width: 5em;"},
Expand Down
2 changes: 2 additions & 0 deletions changedetectionio/model/App.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class model(dict):
'global_ignore_text': [], # List of text to ignore when calculating the comparison checksum
'global_subtractive_selectors': [],
'ignore_whitespace': True,
'keep_history_n': None, # Number of snapshots to keep
'keep_history_seconds': None, # Or time ago back to keep
'notification_body': default_notification_body,
'notification_format': default_notification_format,
'notification_title': default_notification_title,
Expand Down
3 changes: 3 additions & 0 deletions changedetectionio/model/Watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,9 @@ def _prune_last_fetched_html_snapshots(self):
if index > 1 and os.path.isfile(filepath):
os.remove(filepath)

def post_process(self):

x=1

@property
def get_browsersteps_available_screenshots(self):
Expand Down
2 changes: 2 additions & 0 deletions changedetectionio/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def __init__(self, *arg, **kw):
'headers': {}, # Extra headers to send
'ignore_text': [], # List of text to ignore when calculating the comparison checksum
'in_stock_only': True, # Only trigger change on going to instock from out-of-stock
'keep_history_n': None, # Number of snapshots to keep
'keep_history_seconds': None, # Or time ago back to keep
'include_filters': [],
'last_checked': 0,
'last_error': False,
Expand Down
7 changes: 7 additions & 0 deletions changedetectionio/templates/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@
Note: Simply changing the User-Agent often does not defeat anti-robot technologies, it's important to consider <a href="https://changedetection.io/tutorial/what-are-main-types-anti-robot-mechanisms">all of the ways that the browser is detected</a>.
</span>
</div>
<div class="pure-control-group">
{{ render_field(form.application.form.keep_history_n) }}
<span class="pure-form-message-inline">Blank - keep all</span>
{{ render_field(form.application.form.keep_history_seconds) }}
<span class="pure-form-message-inline">Blank - keep all</span>
</div>

<div class="pure-control-group">
<br>
Tip: <a href="https://github.com/dgtlmoon/changedetection.io/wiki/Proxy-configuration#brightdata-proxy-support">Connect using Bright Data and Oxylabs Proxies, find out more here.</a>
Expand Down
6 changes: 6 additions & 0 deletions changedetectionio/update_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,12 @@ def run(self):
except Exception as e:
pass

try:
watch.post_process()
except Exception as e:
logger.critical(e)


self.datastore.update_watch(uuid=uuid, update_obj={'fetch_time': round(time.time() - now, 3),
'last_checked': round(time.time()),
'check_count': count
Expand Down