Skip to content

Commit 857607e

Browse files
authored
[AL-5044] Last activity end
[AL-5044] Last activity end
2 parents 8ffa9da + ee4c711 commit 857607e

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

labelbox/schema/project.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@ def export_labels(self,
333333
last_activity_start (str): Will include all labels that have had any updates to
334334
data rows, issues, comments, metadata, or reviews since this timestamp.
335335
formatted "YYYY-MM-DD" or "YYYY-MM-DD hh:mm:ss"
336+
last_activity_end (str): Will include all labels that do not have any updates to
337+
data rows, issues, comments, metadata, or reviews after this timestamp.
338+
formatted "YYYY-MM-DD" or "YYYY-MM-DD hh:mm:ss"
336339
337340
Returns:
338341
URL of the data file with this Project's labels. If the server didn't
@@ -366,11 +369,21 @@ def _string_from_dict(dictionary: dict, value_with_quotes=False) -> str:
366369
filter_param_dict["labelCreatedAt"] = "{%s}" % _string_from_dict(
367370
created_at_dict, value_with_quotes=True)
368371

369-
if "last_activity_start" in kwargs:
370-
last_activity_start = kwargs['last_activity_start']
371-
_validate_datetime(last_activity_start)
372+
if "last_activity_start" in kwargs or "last_activity_end" in kwargs:
373+
last_activity_start = kwargs.get('last_activity_start')
374+
last_activity_end = kwargs.get('last_activity_end')
375+
376+
if last_activity_start:
377+
_validate_datetime(str(last_activity_start))
378+
if last_activity_end:
379+
_validate_datetime(str(last_activity_end))
380+
372381
filter_param_dict["lastActivityAt"] = "{%s}" % _string_from_dict(
373-
{"start": last_activity_start}, value_with_quotes=True)
382+
{
383+
"start": last_activity_start,
384+
"end": last_activity_end
385+
},
386+
value_with_quotes=True)
374387

375388
if filter_param_dict:
376389
filter_param = """, filters: {%s }""" % (_string_from_dict(

tests/integration/test_export.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,11 @@ def test_export_filtered_activity(client,
129129
regular_export = project.export_labels(download=True)
130130
assert len(regular_export) == 1
131131

132-
filtered_export = project.export_labels(download=True,
133-
last_activity_start="2020-01-01")
132+
filtered_export = project.export_labels(
133+
download=True,
134+
last_activity_start="2020-01-01",
135+
last_activity_end=(datetime.datetime.now() +
136+
datetime.timedelta(days=1)).strftime("%Y-%m-%d"))
134137
assert len(filtered_export) == 1
135138

136139
filtered_export_with_time = project.export_labels(
@@ -142,4 +145,9 @@ def test_export_filtered_activity(client,
142145
last_activity_start=(datetime.datetime.now() +
143146
datetime.timedelta(days=1)).strftime("%Y-%m-%d"),
144147
)
148+
149+
empty_export = project.export_labels(
150+
download=True,
151+
last_activity_end=(datetime.datetime.now() -
152+
datetime.timedelta(days=1)).strftime("%Y-%m-%d"))
145153
assert len(empty_export) == 0

0 commit comments

Comments
 (0)