Skip to content

Commit

Permalink
Added sorting of star projects
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed Jan 22, 2024
1 parent 6baa159 commit 57963e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## [0.7.1] -- 2023-01-22
- Fixed bug in Stars annotation
- SQL efficiency improvements
- Added sort by date in stared projects

## [0.7.0] -- 2023-01-17
- Added `pop` to project table and annotation model [#107](https://github.com/pepkit/pepdbagent/issues/107)
Expand Down
9 changes: 7 additions & 2 deletions pepdbagent/db_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Projects(Base):
number_of_stars: Mapped[int] = mapped_column(default=0)
submission_date: Mapped[datetime.datetime]
last_update_date: Mapped[Optional[datetime.datetime]] = mapped_column(
onupdate=deliver_update_date, default=deliver_update_date
default=deliver_update_date, # onupdate=deliver_update_date, # This field should not be updated, while we are adding project to favorites
)
pep_schema: Mapped[Optional[str]]
pop: Mapped[Optional[bool]] = mapped_column(default=False)
Expand Down Expand Up @@ -168,7 +168,9 @@ class User(Base):
id: Mapped[int] = mapped_column(primary_key=True)
namespace: Mapped[str]
stars_mapping: Mapped[List["Stars"]] = relationship(
back_populates="user_mapping", cascade="all, delete-orphan"
back_populates="user_mapping",
cascade="all, delete-orphan",
order_by="Stars.star_date.desc()",
)


Expand All @@ -183,6 +185,9 @@ class Stars(Base):
project_id = mapped_column(ForeignKey("projects.id", ondelete="CASCADE"), primary_key=True)
user_mapping: Mapped[List["User"]] = relationship(back_populates="stars_mapping")
project_mapping: Mapped["Projects"] = relationship(back_populates="stars_mapping")
star_date: Mapped[datetime.datetime] = mapped_column(
onupdate=deliver_update_date, default=deliver_update_date
)


class Views(Base):
Expand Down

0 comments on commit 57963e6

Please sign in to comment.