Skip to content

Commit

Permalink
Feat: 뉴스 날짜로 정렬 (#144)
Browse files Browse the repository at this point in the history
* Feat: Change date field to NOT NULLABLE.

* Feat: Change to sort by date, not createdat.

* Test: Fix test.

* Test: Move news test dir.

---------

Co-authored-by: Junhyeong Kim <indiv0227@snu.ac.kr>
  • Loading branch information
huGgW and leeeryboy authored Sep 19, 2023
1 parent 9693473 commit 70eef9c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class NewsEntity(
@Column(columnDefinition = "mediumtext")
var plainTextDescription: String,

var date: LocalDateTime?,
var date: LocalDateTime,
var isPrivate: Boolean,
var isSlide: Boolean,
var isImportant: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class NewsRepositoryImpl(
}

val newsEntityList = jpaQuery
.orderBy(newsEntity.createdAt.desc())
.orderBy(newsEntity.date.desc())
.offset(pageRequest.offset)
.limit(pageRequest.pageSize.toLong())
.distinct()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class NewsDto(
val tags: List<String>,
val createdAt: LocalDateTime?,
val modifiedAt: LocalDateTime?,
val date: LocalDateTime?,
val date: LocalDateTime,
val isPrivate: Boolean,
val isSlide: Boolean,
val isImportant: Boolean,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.wafflestudio.csereal.core.notice.news
package com.wafflestudio.csereal.core.news

import com.wafflestudio.csereal.core.news.database.NewsEntity
import com.wafflestudio.csereal.core.news.database.NewsRepository
Expand All @@ -9,6 +9,7 @@ import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.data.repository.findByIdOrNull
import java.time.LocalDateTime

@SpringBootTest
class NewsServiceTest(
Expand All @@ -34,7 +35,7 @@ class NewsServiceTest(
tags = emptyList(),
createdAt = null,
modifiedAt = null,
date = null,
date = LocalDateTime.now(),
isPrivate = false,
isSlide = false,
isImportant = false,
Expand Down Expand Up @@ -72,7 +73,7 @@ class NewsServiceTest(
<h3>Goodbye, World!</h3>
""".trimIndent(),
plainTextDescription = "Hello, World! This is news description. Goodbye, World!",
date = null,
date = LocalDateTime.now(),
isPrivate = false,
isSlide = false,
isImportant = false,
Expand Down Expand Up @@ -103,7 +104,8 @@ class NewsServiceTest(
<h3>Goodbye, World!</h3>
<p>This is additional description.</p>
""".trimIndent()
updatedNewsEntity.plainTextDescription shouldBe "Hello, World! This is modified news description. Goodbye, World! This is additional description."
updatedNewsEntity.plainTextDescription shouldBe "Hello, World! This is modified news description." +
" Goodbye, World! This is additional description."
}
}
}
Expand Down

0 comments on commit 70eef9c

Please sign in to comment.