Skip to content

Commit

Permalink
optimize: list api default order for attachment and subject episode a…
Browse files Browse the repository at this point in the history
…nd attachment ref. (#508)
  • Loading branch information
chivehao authored Nov 12, 2023
1 parent 4d77b25 commit 43a4fa3
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 13 deletions.
24 changes: 16 additions & 8 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

更新日志文档,版本顺序从新到旧,最新版本在最前(上)面。

# 0.11.7

## 优化

- [WIP] 条目收藏形式优化,一次性提交收藏类型和标签

## 插件

### 番组计划

- [WIP] 拉取条目时,转换对应的标签

# 0.11.6

## 新特性
Expand All @@ -13,14 +25,10 @@
## 优化

- 条目详情页,给番组集合平台加上对应的条目详情URL前缀
- [WIP] 列表接口排序优化#506
- [WIP] 条目收藏形式优化,一次性提交收藏类型和标签

## 插件

### 番组计划

- [WIP] 拉取条目时,转换对应的标签
- 列表接口排序优化 #506 指定默认排序规则
- 附件列表接口,按类型、名称、大小、更新时间依次升序
- 条目剧集列表接口,按分组降序,序号、放送时间、创建时间依次升序
- 剧集附件引用列表接口,在根据参数放送时间排序后,按名称、类型、NSFW依次升序

# 0.11.5

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ public Mono<PagingWrap<AttachmentEntity>> listEntitiesByCondition(
}

Query query = Query.query(criteria)
.sort(Sort.by(Sort.Order.by("type")))
.sort(Sort.by(Sort.Order.asc("type")))
.sort(Sort.by(Sort.Order.asc("name")))
.sort(Sort.by(Sort.Order.asc("size")))
.sort(Sort.by(Sort.Order.asc("update_time")))
.with(pageRequest);

Flux<AttachmentEntity> attachmentEntityFlux =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import jakarta.annotation.Nonnull;
import jakarta.validation.constraints.NotBlank;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -106,9 +105,12 @@ public Mono<Subject> findById(Long id) {
.flatMap(subjectEntity -> copyProperties(subjectEntity, new Subject()))
.checkpoint("FindSubjectEntityById")

.flatMap(subject -> episodeRepository.findAllBySubjectId(subject.getId())
.flatMap(subject -> episodeRepository
.findAllBySubjectIdOrderByGroupDescSequenceAscAirTimeAscCreateTimeAsc(
subject.getId())
.flatMap(episodeEntity -> copyProperties(episodeEntity, new Episode()))
.flatMap(episode -> attachmentReferenceRepository.findAllByTypeAndReferenceId(
.flatMap(episode -> attachmentReferenceRepository
.findAllByTypeAndReferenceIdOrderByTypeAscAttachmentIdAsc(
AttachmentReferenceType.EPISODE, episode.getId())
.flatMap(attachmentReferenceEntity ->
attachmentRepository.findById(attachmentReferenceEntity.getAttachmentId())
Expand All @@ -122,7 +124,6 @@ public Mono<Subject> findById(Long id) {
.build())
).collectList()
.map(episode::setResources))
.sort(Comparator.comparingDouble(Episode::getSequence))
.collectList()
.map(episodes -> subject
.setTotalEpisodes((long) episodes.size())
Expand Down Expand Up @@ -374,6 +375,9 @@ public Mono<PagingWrap<SubjectMeta>> listEntitiesByCondition(FindSubjectConditio
.sort(Sort.by(airTimeDesc
? Sort.Order.desc("air_time")
: Sort.Order.asc("air_time")))
.sort(Sort.by(Sort.Order.asc("name")))
.sort(Sort.by(Sort.Order.asc("type")))
.sort(Sort.by(Sort.Order.asc("nsfw")))
.with(pageRequest);

Flux<SubjectEntity> subjectEntityFlux = template.select(query, SubjectEntity.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ Mono<AttachmentReferenceEntity> findByTypeAndAttachmentIdAndReferenceId(
Flux<AttachmentReferenceEntity> findAllByTypeAndReferenceId(AttachmentReferenceType type,
Long referenceId);

Flux<AttachmentReferenceEntity> findAllByTypeAndReferenceIdOrderByTypeAscAttachmentIdAsc(
AttachmentReferenceType type, Long referenceId);

Mono<Void> deleteByTypeAndAttachmentIdAndReferenceId(
AttachmentReferenceType type, Long attachmentId, Long referenceId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
public interface EpisodeRepository extends R2dbcRepository<EpisodeEntity, Long> {
Flux<EpisodeEntity> findAllBySubjectId(Long subjectId);

Flux<EpisodeEntity> findAllBySubjectIdOrderByGroupDescSequenceAscAirTimeAscCreateTimeAsc(
Long subjectId);

Mono<Void> deleteAllBySubjectId(Long subjectId);

Mono<EpisodeEntity> findBySubjectIdAndGroupAndSequence(Long subjectId, EpisodeGroup group,
Expand Down

0 comments on commit 43a4fa3

Please sign in to comment.