Media find is now sorted by created date
This commit is contained in:
parent
8cf78f4409
commit
29ef2cfe2b
@ -13,6 +13,7 @@ from modules.scheduler import scheduler
|
||||
from modules.security import User, get_current_active_user
|
||||
from modules.app import app
|
||||
from modules.database import col_photos, col_albums, col_tokens
|
||||
from pymongo import DESCENDING
|
||||
from bson.objectid import ObjectId
|
||||
from bson.errors import InvalidId
|
||||
|
||||
@ -200,7 +201,7 @@ async def photo_find(album: str, q: Union[str, None] = None, page: int = 1, page
|
||||
db_query = {"user": current_user.user, "album": album, "filename": re.compile(q)}
|
||||
db_query_count = {"user": current_user.user, "album": album, "filename": re.compile(q)}
|
||||
|
||||
images = list(col_photos.find(db_query, limit=page_size, skip=skip))
|
||||
images = list(col_photos.find(db_query, limit=page_size, skip=skip).sort('dates.uploaded', DESCENDING))
|
||||
|
||||
for image in images:
|
||||
output["results"].append({"id": image["_id"].__str__(), "filename": image["filename"]})
|
||||
|
@ -12,6 +12,7 @@ from modules.app import app
|
||||
from modules.database import col_videos, col_albums, col_tokens
|
||||
from bson.objectid import ObjectId
|
||||
from bson.errors import InvalidId
|
||||
from pymongo import DESCENDING
|
||||
|
||||
from fastapi import HTTPException, UploadFile, Security
|
||||
from fastapi.responses import UJSONResponse, Response
|
||||
@ -156,7 +157,7 @@ async def video_find(q: str, album: str, page: int = 1, page_size: int = 100, cu
|
||||
|
||||
output = {"results": []}
|
||||
skip = (page-1)*page_size
|
||||
videos = list(col_videos.find({"user": current_user.user, "album": album, "filename": re.compile(q)}, limit=page_size, skip=skip))
|
||||
videos = list(col_videos.find({"user": current_user.user, "album": album, "filename": re.compile(q)}, limit=page_size, skip=skip).sort('dates.uploaded', DESCENDING))
|
||||
|
||||
for video in videos:
|
||||
output["results"].append({"id": video["_id"].__str__(), "filename": video["filename"]})
|
||||
|
Loading…
Reference in New Issue
Block a user