Skip to content

Commit

Permalink
fix: update query for after paint (#289)
Browse files Browse the repository at this point in the history
* fix: update query

* fix: add thread head paint
  • Loading branch information
210-reverof authored Feb 22, 2024
1 parent 2dc7fc1 commit eafc0ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,18 @@ public interface PaintRepository extends Neo4jRepository<Paint, Long> {
"WHERE a.pid = $pid " +
"WITH b " +
"MATCH (b)<-[r]->(neighbors) " +
"WHERE NOT type(r) = 'REPLIES' " +
"WHERE type(r) <> 'REPLIES' AND type(r) <> 'QUOTES' " +
"RETURN b, r, neighbors")
List<Paint> findAllAfterPaintByPid(@Param("pid") Long pid);

@Query("MATCH (a:Paint)<-[:REPLIES*]-(b:Paint)" +
@Query("MATCH path=(a:Paint)<-[:REPLIES*]-(b:Paint) " +
"WHERE a.pid = $pid " +
"WITH b " +
"WITH path " +
"ORDER BY b.pid DESC " +
"LIMIT 1 " +
"UNWIND nodes(path) as b " +
"MATCH (b)<-[r]->(neighbors) " +
"WHERE NOT type(r) = 'REPLIES' " +
"WHERE type(r) <> 'REPLIES' AND type(r) <> 'REPAINTS' AND type(r) <> 'QUOTES' " +
"RETURN b, r, neighbors")
List<Paint> findAllAfterPaintsByPid(@Param("pid") Long pid);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public List<PaintResponse> getAllPaintsByPid(final List<Long> paintIds) {
private ThreadResponse getThreadGroup(final Integer threadId, final Long userId, final Paint paint) {
checkAndSetQuotePaint(paint);
List<Paint> subPaints = distinctPaintsByPid(paintRepository.findAllAfterPaintsByPid(paint.getPid()));
subPaints.add(0, paint);
return new ThreadResponse(threadId, paintEntityConverter.convertToPaintResponse(userId, subPaints));
}

Expand Down

0 comments on commit eafc0ad

Please sign in to comment.