|
@@ -924,41 +924,6 @@ class ContentApi(object):
|
924
|
924
|
|
925
|
925
|
return resultset.all()
|
926
|
926
|
|
927
|
|
- def get_last_active(self, parent_id: int, content_type: str, workspace: Workspace=None, limit=10) -> typing.List[Content]:
|
928
|
|
- assert parent_id is None or isinstance(parent_id, int) # DYN_REMOVE
|
929
|
|
- assert content_type is not None# DYN_REMOVE
|
930
|
|
- assert isinstance(content_type, str) # DYN_REMOVE
|
931
|
|
-
|
932
|
|
- resultset = self._base_query(workspace) \
|
933
|
|
- .filter(Content.workspace_id == Workspace.workspace_id) \
|
934
|
|
- .filter(Workspace.is_deleted.is_(False)) \
|
935
|
|
- .order_by(desc(Content.updated))
|
936
|
|
-
|
937
|
|
- if content_type!=ContentType.Any:
|
938
|
|
- resultset = resultset.filter(Content.type==content_type)
|
939
|
|
-
|
940
|
|
- if parent_id:
|
941
|
|
- resultset = resultset.filter(Content.parent_id==parent_id)
|
942
|
|
-
|
943
|
|
- result = []
|
944
|
|
- for item in resultset:
|
945
|
|
- new_item = None
|
946
|
|
- if ContentType.Comment == item.type:
|
947
|
|
- new_item = item.parent
|
948
|
|
- else:
|
949
|
|
- new_item = item
|
950
|
|
-
|
951
|
|
- # INFO - D.A. - 2015-05-20
|
952
|
|
- # We do not want to show only one item if the last 10 items are
|
953
|
|
- # comments about one thread for example
|
954
|
|
- if new_item not in result:
|
955
|
|
- result.append(new_item)
|
956
|
|
-
|
957
|
|
- if len(result) >= limit:
|
958
|
|
- break
|
959
|
|
-
|
960
|
|
- return result
|
961
|
|
-
|
962
|
927
|
def get_last_unread(self, parent_id: int, content_type: str,
|
963
|
928
|
workspace: Workspace=None, limit=10) -> typing.List[Content]:
|
964
|
929
|
assert parent_id is None or isinstance(parent_id, int) # DYN_REMOVE
|
|
@@ -989,7 +954,7 @@ class ContentApi(object):
|
989
|
954
|
self,
|
990
|
955
|
workspace: Workspace=None,
|
991
|
956
|
limit: typing.Optional[int]=None,
|
992
|
|
- before_datetime: typing.Optional[datetime.datetime]= None,
|
|
957
|
+ before_content: typing.Optional[Content]= None,
|
993
|
958
|
content_ids: typing.Optional[typing.List[int]] = None,
|
994
|
959
|
) -> typing.List[Content]:
|
995
|
960
|
"""
|
|
@@ -1021,6 +986,7 @@ class ContentApi(object):
|
1021
|
986
|
|
1022
|
987
|
active_contents = []
|
1023
|
988
|
too_recent_content = []
|
|
989
|
+ before_content_find = False
|
1024
|
990
|
for content in resultset:
|
1025
|
991
|
related_active_content = None
|
1026
|
992
|
if ContentType.Comment == content.type:
|
|
@@ -1028,18 +994,16 @@ class ContentApi(object):
|
1028
|
994
|
else:
|
1029
|
995
|
related_active_content = content
|
1030
|
996
|
|
1031
|
|
- if not before_datetime:
|
1032
|
|
- before_datetime = datetime.datetime.now()
|
1033
|
|
- # INFO - D.A. - 2015-05-20
|
1034
|
|
- # We do not want to show only one item if the last 10 items are
|
1035
|
|
- # comments about one thread for example
|
1036
|
997
|
if related_active_content not in active_contents and related_active_content not in too_recent_content: # nopep8
|
1037
|
|
- # we verify that content is old enough
|
1038
|
|
- if content.updated < before_datetime:
|
|
998
|
+
|
|
999
|
+ if not before_content or before_content_find:
|
1039
|
1000
|
active_contents.append(related_active_content)
|
1040
|
1001
|
else:
|
1041
|
1002
|
too_recent_content.append(related_active_content)
|
1042
|
1003
|
|
|
1004
|
+ if before_content and related_active_content == before_content:
|
|
1005
|
+ before_content_find = True
|
|
1006
|
+
|
1043
|
1007
|
if limit and len(active_contents) >= limit:
|
1044
|
1008
|
break
|
1045
|
1009
|
|