Skip to content

Commit ee4c711

Browse files
tytalustytalus
authored andcommitted
last activity end
1 parent 24dd42a commit ee4c711

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
@@ -318,6 +318,9 @@ def export_labels(self,
318318
last_activity_start (str): Will include all labels that have had any updates to
319319
data rows, issues, comments, metadata, or reviews since this timestamp.
320320
formatted "YYYY-MM-DD" or "YYYY-MM-DD hh:mm:ss"
321+
last_activity_end (str): Will include all labels that do not have any updates to
322+
data rows, issues, comments, metadata, or reviews after this timestamp.
323+
formatted "YYYY-MM-DD" or "YYYY-MM-DD hh:mm:ss"
321324
322325
Returns:
323326
URL of the data file with this Project's labels. If the server didn't
@@ -364,11 +367,21 @@ def _validate_datetime(string_date: str) -> bool:
364367
filter_param_dict["labelCreatedAt"] = "{%s}" % _string_from_dict(
365368
created_at_dict, value_with_quotes=True)
366369

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

373386
if filter_param_dict:
374387
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)