diff --git a/changedetectionio/blueprint/ui/__init__.py b/changedetectionio/blueprint/ui/__init__.py index 52488684..ce4bb716 100644 --- a/changedetectionio/blueprint/ui/__init__.py +++ b/changedetectionio/blueprint/ui/__init__.py @@ -159,12 +159,20 @@ def construct_blueprint(datastore: ChangeDetectionStore, update_q, worker_handle def mark_all_viewed(): # Save the current newest history as the most recently viewed with_errors = request.args.get('with_errors') == "1" + tag_limit = request.args.get('tag') + logger.debug(f"Limiting to tag {tag_limit}") + now = int(time.time()) for watch_uuid, watch in datastore.data['watching'].items(): if with_errors and not watch.get('last_error'): continue - datastore.set_last_viewed(watch_uuid, int(time.time())) - return redirect(url_for('watchlist.index')) + if tag_limit and ( not watch.get('tags') or tag_limit not in watch['tags'] ): + logger.debug(f"Skipping watch {watch_uuid}") + continue + + datastore.set_last_viewed(watch_uuid, now) + + return redirect(url_for('watchlist.index', tag=tag_limit)) @ui_blueprint.route("/delete", methods=['GET']) @login_optionally_required diff --git a/changedetectionio/blueprint/watchlist/templates/watch-overview.html b/changedetectionio/blueprint/watchlist/templates/watch-overview.html index 60fdddbf..af98d416 100644 --- a/changedetectionio/blueprint/watchlist/templates/watch-overview.html +++ b/changedetectionio/blueprint/watchlist/templates/watch-overview.html @@ -214,9 +214,14 @@ document.addEventListener('DOMContentLoaded', function() { + {%- if active_tag_uuid -%} +
  • + Mark all viewed in '{{active_tag.title}}' +
  • + {%- endif -%}
  • Recheck - all {%- if active_tag_uuid-%} in "{{active_tag.title}}"{%endif%} + all {% if active_tag_uuid %} in '{{active_tag.title}}'{%endif%}
  • RSS Feed diff --git a/changedetectionio/tests/test_group.py b/changedetectionio/tests/test_group.py index e166a8da..f8791da8 100644 --- a/changedetectionio/tests/test_group.py +++ b/changedetectionio/tests/test_group.py @@ -236,39 +236,41 @@ def test_group_tag_notification(client, live_server, measure_memory_usage): assert b'Deleted' in res.data def test_limit_tag_ui(client, live_server, measure_memory_usage): - - test_url = url_for('test_endpoint', _external=True) - urls=[] + test_url = url_for('test_random_content_endpoint', _external=True) - for i in range(20): - urls.append(test_url+"?x="+str(i)+" test-tag") - - for i in range(20): - urls.append(test_url+"?non-grouped="+str(i)) - - res = client.post( + # A space can label the tag, only the first one will have a tag + client.post( url_for("imports.import_page"), - data={"urls": "\r\n".join(urls)}, + data={"urls": f"{test_url} test-tag\r\n{test_url}"}, follow_redirects=True ) - - assert b"40 Imported" in res.data + tag_uuid = get_UUID_for_tag_name(client, name="test-tag") + assert tag_uuid res = client.get(url_for("watchlist.index")) assert b'test-tag' in res.data + client.get(url_for("ui.form_watch_checknow"), follow_redirects=True) + wait_for_all_checks(client) + client.get(url_for("ui.form_watch_checknow"), follow_redirects=True) + wait_for_all_checks(client) - # All should be here - assert res.data.count(b'processor-text_json_diff') == 40 + # Should be both unviewed + res = client.get(url_for("watchlist.index")) + assert res.data.count(b' unviewed ') == 2 - tag_uuid = get_UUID_for_tag_name(client, name="test-tag") - res = client.get(url_for("watchlist.index", tag=tag_uuid)) + # Now we recheck only the tag + client.get(url_for('ui.mark_all_viewed', tag=tag_uuid), follow_redirects=True) + wait_for_all_checks(client) + + with open('/tmp/fuck.html', 'wb') as f: + f.write(res.data) + # Should be only 1 unviewed + res = client.get(url_for("watchlist.index")) + assert res.data.count(b' unviewed ') == 1 + - # Just a subset should be here - assert b'test-tag' in res.data - assert res.data.count(b'processor-text_json_diff') == 20 - assert b"object at" not in res.data res = client.get(url_for("ui.form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data res = client.get(url_for("tags.delete_all"), follow_redirects=True)