Skip to content

Commit

Permalink
fix(article): use id instead of created_at for order_by
Browse files Browse the repository at this point in the history
  • Loading branch information
retroinspect committed Jan 23, 2024
1 parent 06fc587 commit b05dbda
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ class Migration(migrations.Migration):
migrations.AddIndex(
model_name="article",
index=models.Index(
fields=["created_at", "parent_board_id"],
name="created_at_parent_board_id_idx",
fields=["id", "parent_board_id"], name="id_parent_board_id_idx"
),
),
]
4 changes: 2 additions & 2 deletions apps/core/models/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ class Meta(MetaDataModel.Meta):

indexes = [
models.Index(
fields=["created_at", "parent_board_id"],
name="created_at_parent_board_id_idx",
fields=["id", "parent_board_id"],
name="id_parent_board_id_idx",
)
]

Expand Down
2 changes: 1 addition & 1 deletion apps/core/views/viewsets/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ArticleViewSet(viewsets.ModelViewSet, ActionAPIViewSet):
queryset = Article.objects.all()

filterset_class = ArticleFilter
ordering_fields = ["created_at", "positive_vote_count"]
ordering_fields = ["id", "positive_vote_count"]

serializer_class = ArticleSerializer
action_serializer_class = {
Expand Down

0 comments on commit b05dbda

Please sign in to comment.