Skip to content

Commit

Permalink
order get projects
Browse files Browse the repository at this point in the history
  • Loading branch information
khansadaoudi committed Jan 2, 2025
1 parent 078b59f commit 787aae8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions app/projects/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import werkzeug

from app import db
from app import cache
from app.utils.grew_utils import GrewService
from app.utils.logging_utils import log_request
from app.user.service import UserService
Expand Down Expand Up @@ -49,7 +48,7 @@ def get(self)-> dict:
if languages is not None or name is not None:
projects = ProjectService.filter_project_by_name_or_language(name, languages)
else:
projects = Project.query.all()
projects = ProjectService.get_all()

grew_projects = GrewService.get_projects()
extended_project_list, total_pages = ProjectService.get_projects_info(projects, grew_projects, page, 12, projects_type)
Expand Down
5 changes: 3 additions & 2 deletions app/projects/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from flask import abort, current_app
from flask_login import current_user
from sqlalchemy import desc

from app import db
from .interface import ProjectInterface, ProjectExtendedInterface
Expand All @@ -16,12 +17,12 @@ class ProjectService:

@staticmethod
def get_all() -> List[Project]:
"""Get all list of project in db
"""Get all list of project in db ordered by last access value
Returns:
List[Project]
"""
return Project.query.all()
return Project.query.join(LastAccess).order_by(desc(LastAccess.last_read)).all()

@staticmethod
def create(new_attrs: ProjectInterface) -> Project:
Expand Down

0 comments on commit 787aae8

Please sign in to comment.