Skip to content

Commit

Permalink
fix: duplicate method
Browse files Browse the repository at this point in the history
  • Loading branch information
astappiev committed Jul 10, 2024
1 parent 7f89365 commit ca229c2
Showing 1 changed file with 2 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@ public Map<String, UsagePrice> models() {
return chatService.getModels();
}

@GET
@Authenticated
public Uni<List<Chat>> chats(
@QueryParam("sort") @DefaultValue("-created") String order,
@QueryParam("page") @DefaultValue("1") Integer page,
@QueryParam("perPage") @DefaultValue("20") Integer perPage
) {
Token token = securityIdentity.getCredential(Token.class);

return Chat.listByUser(token, null, order, page, perPage).call(ChatResource::ensureChatsTitle);
}

@GET
@Authenticated
public Uni<List<Chat>> chats(
Expand All @@ -59,11 +47,8 @@ public Uni<List<Chat>> chats(
) {
Token token = securityIdentity.getCredential(Token.class);

return Chat.listByUser(token, user, order, page, perPage).call(ChatResource::ensureChatsTitle);
}

private static Uni<List<Uni<List<ChatMessage>>>> ensureChatsTitle(List<Chat> chats) {
return Multi.createFrom().iterable(chats).filter(chat -> chat.title == null).map(ChatResource::createChatTitle).collect().asList();
return Chat.listByUser(token, user, order, page, perPage)
.call(chats -> Multi.createFrom().iterable(chats).filter(chat -> chat.title == null).map(ChatResource::createChatTitle).collect().asList());
}

private static Uni<List<ChatMessage>> createChatTitle(Chat chat) {
Expand Down

0 comments on commit ca229c2

Please sign in to comment.