Skip to content

Commit

Permalink
add sort
Browse files Browse the repository at this point in the history
  • Loading branch information
BennyThink committed Dec 27, 2023
1 parent 0f5747a commit d9da767
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ jobs:
trivy image --no-progress --severity "HIGH,CRITICAL" yyetsbot:latest
- name: Comment on CVE PR
uses: thollander/actions-comment-pull-request@v1
uses: thollander/actions-comment-pull-request@v2
with:
message: |
```
${{ steps.trivy.outputs.stdout }}
```
comment_tag: cve
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion YYeTsFE
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
requests==2.31.0
pytelegrambotapi==4.14.0
pytelegrambotapi==4.14.1
beautifulsoup4==4.12.2
tgbot-ping==1.0.7
redis==5.0.1
apscheduler==3.10.4
pymongo==4.6.0
pymongo==4.6.1
tornado==6.4
captcha==0.5.0
passlib==1.7.4
Expand Down
7 changes: 6 additions & 1 deletion yyetsweb/databases/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ def get_comment(self, resource_id: int, page: int, size: int, **kwargs) -> dict:
self.inner_page = kwargs.get("inner_page", 1)
self.inner_size = kwargs.get("inner_size", 5)
comment_id = kwargs.get("comment_id")
sort = kwargs.get("sort")
if sort == "newest":
sort = pymongo.DESCENDING
else:
sort = pymongo.ASCENDING

condition = {
"resource_id": resource_id,
Expand All @@ -109,7 +114,7 @@ def get_comment(self, resource_id: int, page: int, size: int, **kwargs) -> dict:
.sort("_id", pymongo.DESCENDING)
.limit(size)
.skip((page - 1) * size)
)
).sort("_id", sort)
data = list(data)
self.find_children(data)
self.convert_objectid(data)
Expand Down
2 changes: 2 additions & 0 deletions yyetsweb/handlers/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def get_comment(self):
inner_size = int(self.get_argument("inner_size", "3"))
inner_page = int(self.get_argument("inner_page", "1"))
comment_id = self.get_argument("comment_id", None)
sort = self.get_argument("sort", "newest")

if not resource_id:
self.set_status(HTTPStatus.BAD_REQUEST)
Expand All @@ -33,6 +34,7 @@ def get_comment(self):
resource_id,
page,
size,
sort=sort,
inner_size=inner_size,
inner_page=inner_page,
comment_id=comment_id,
Expand Down

0 comments on commit d9da767

Please sign in to comment.