diff --git a/swh/search/journal_client.py b/swh/search/journal_client.py --- a/swh/search/journal_client.py +++ b/swh/search/journal_client.py @@ -59,7 +59,12 @@ logging.debug("processing origin visit statuses %r", visit_statuses) full_visit_status = [ - {"url": (visit_status["origin"]), "has_visits": True,} + { + "url": (visit_status["origin"]), + "has_visits": True, + "nb_visit": visit_status["visit"], + "last_visit_date": str(visit_status["date"]), + } for visit_status in visit_statuses if visit_status["status"] == "full" ] diff --git a/swh/search/tests/test_cli.py b/swh/search/tests/test_cli.py --- a/swh/search/tests/test_cli.py +++ b/swh/search/tests/test_cli.py @@ -4,9 +4,11 @@ # See top-level LICENSE file for more information import copy +from datetime import datetime import tempfile from click.testing import CliRunner +from click.types import DateTime from confluent_kafka import Producer import pytest import yaml @@ -179,6 +181,7 @@ { "origin": origin_foobar["url"], "visit": 1, + "date": datetime.now(), "snapshot": None, "status": "full", } diff --git a/swh/search/tests/test_journal_client.py b/swh/search/tests/test_journal_client.py --- a/swh/search/tests/test_journal_client.py +++ b/swh/search/tests/test_journal_client.py @@ -3,6 +3,7 @@ # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information +from datetime import datetime import functools from unittest.mock import MagicMock @@ -42,23 +43,45 @@ search_mock = MagicMock() worker_fn = functools.partial(process_journal_objects, search=search_mock,) + current_datetime = datetime.now() worker_fn( { "origin_visit_status": [ - {"origin": "http://foobar.baz", "status": "full"} # full visits ok + { + "origin": "http://foobar.baz", + "status": "full", + "visit": 5, + "date": current_datetime, + } # full visits ok ] } ) search_mock.origin_update.assert_called_once_with( - [{"url": "http://foobar.baz", "has_visits": True},] + [ + { + "url": "http://foobar.baz", + "has_visits": True, + "nb_visit": 5, + "last_visit_date": str(current_datetime), + }, + ] ) search_mock.reset_mock() # non-full visits are filtered out worker_fn( - {"origin_visit_status": [{"origin": "http://foobar.baz", "status": "partial"}]} + { + "origin_visit_status": [ + { + "origin": "http://foobar.baz", + "status": "partial", + "visit": 5, + "date": current_datetime, + } + ] + } ) search_mock.origin_update.assert_not_called()