Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comments 02 12 2023 #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public ResponseEntity<ShortTopicResponseDto> create(@ModelAttribute @Valid Creat
return new ResponseEntity<>(responseDto, HttpStatus.CREATED);
}

// аннотация @IsAdmin ограничивает доступ только до 1-ого админа? а если завтра нужно будет через этот delete другим юзерас редачить свои записи?
@Operation(description = "Удаление топика")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "Топик удален"),
Expand Down
1 change: 1 addition & 0 deletions src/main/java/edu/tinkoff/ninjamireaclone/model/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void addDocument(Document document) {
document.getPosts().add(this);
}

// unused
public void removeDocument(Document document) {
this.documents.remove(document);
document.getPosts().remove(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,21 @@ public Post createPostWithAttachments(Post post, Long authorId, Long parentId, L
return postRepository.saveAndFlush(post);
}

/**
* Пусть возвращает агрегированную метрику того, сколько удалено.
* Перенести логику на сторону бд.
* Колоночка isRoot?
* Сделать N транзакций.
*/
@Transactional
public List<Post> cleanUpComments() {
var allTopics = topicRepository.findAll();
var deletedPosts = new ArrayList<Post>();
for (var topic : allTopics) {
var posts = topic.getPosts();
if (posts.isEmpty()) { continue; }
if (posts.isEmpty()) {
continue;
}
var openingPost = posts.get(0);
var oldPosts = posts.stream()
.filter(p -> p.getCreatedAt()
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spring:
jobStore:
driverDelegateClass: org.quartz.impl.jdbcjobstore.PostgreSQLDelegate #Указываем диалект для запросов к БД
useProperties: false #Указываем, что все данные в БД будут храниться в качестве строк, а не в двоичном формате
tablePrefix: QRTZ_ #Префикс таблиц в БД
tablePrefix: QRTZ_ #Префикс таблиц в БД (да он и так там дефотный по ммоей памяти)
clusterCheckinInterval: 5000 #Указываем частоту сверки инстанса Scheduler с остальными инстансами в кластере
isClustered: true #Включаем режим работы в кластере
threadPool: #Указываем настройки для создания пула поток, на котором будут выполняться джобы
Expand Down