фиксация
This commit is contained in:
@@ -24,34 +24,14 @@ public class SchedulerService {
|
|||||||
private final CleanService cleanService;
|
private final CleanService cleanService;
|
||||||
private final DiscussionParser discussionParser;
|
private final DiscussionParser discussionParser;
|
||||||
|
|
||||||
@Scheduled(cron = "*/30 * * * * *")
|
@Scheduled(cron = "0 */1 * * * *")
|
||||||
public void newMergeRequest() {
|
public void newMergeRequest() {
|
||||||
mergeRequestParser.parsingNewMergeRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Scheduled(cron = "*/30 * * * * *")
|
|
||||||
public void oldMergeRequest() {
|
|
||||||
mergeRequestParser.parsingOldMergeRequest();
|
mergeRequestParser.parsingOldMergeRequest();
|
||||||
}
|
mergeRequestParser.parsingNewMergeRequest();
|
||||||
|
pipelineParser.scanOldPipeline();
|
||||||
@Scheduled(cron = "*/30 * * * * *")
|
pipelineParser.scanNewPipeline();
|
||||||
public void newDiscussion() {
|
|
||||||
discussionParser.scanOldDiscussions();
|
discussionParser.scanOldDiscussions();
|
||||||
discussionParser.scanNewDiscussion();
|
discussionParser.scanNewDiscussion();
|
||||||
}
|
|
||||||
|
|
||||||
@Scheduled(cron = "*/30 * * * * *")
|
|
||||||
public void newPipeline() {
|
|
||||||
pipelineParser.scanNewPipeline();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Scheduled(cron = "*/30 * * * * *")
|
|
||||||
public void oldPipeline() {
|
|
||||||
pipelineParser.scanOldPipeline();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Scheduled(cron = "0 */1 * * * *")
|
|
||||||
public void clean() {
|
|
||||||
cleanService.cleanOldPipelines();
|
cleanService.cleanOldPipelines();
|
||||||
cleanService.cleanMergedPullRequests();
|
cleanService.cleanMergedPullRequests();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import org.sadtech.haiti.context.page.Pagination;
|
|||||||
import org.sadtech.haiti.context.page.Sheet;
|
import org.sadtech.haiti.context.page.Sheet;
|
||||||
import org.sadtech.haiti.context.repository.SimpleManagerRepository;
|
import org.sadtech.haiti.context.repository.SimpleManagerRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* // TODO: 08.09.2020 Добавить описание.
|
* // TODO: 08.09.2020 Добавить описание.
|
||||||
*
|
*
|
||||||
@@ -13,6 +15,8 @@ import org.sadtech.haiti.context.repository.SimpleManagerRepository;
|
|||||||
*/
|
*/
|
||||||
public interface NoteRepository extends SimpleManagerRepository<Note, Long> {
|
public interface NoteRepository extends SimpleManagerRepository<Note, Long> {
|
||||||
|
|
||||||
|
List<Note> findAllByResponsibleIdAndResolved(@NonNull Long userId, boolean resolved);
|
||||||
|
|
||||||
Sheet<Note> findAllByResolved(boolean resolved, @NonNull Pagination pagination);
|
Sheet<Note> findAllByResolved(boolean resolved, @NonNull Pagination pagination);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,12 @@ import org.sadtech.haiti.context.page.Pagination;
|
|||||||
import org.sadtech.haiti.context.page.Sheet;
|
import org.sadtech.haiti.context.page.Sheet;
|
||||||
import org.sadtech.haiti.context.service.SimpleManagerService;
|
import org.sadtech.haiti.context.service.SimpleManagerService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface NoteService extends SimpleManagerService<Note, Long> {
|
public interface NoteService extends SimpleManagerService<Note, Long> {
|
||||||
|
|
||||||
|
List<Note> getAllPersonTask(@NonNull Long userId, boolean resolved);
|
||||||
|
|
||||||
Sheet<Note> getAllByResolved(boolean resolved, @NonNull Pagination pagination);
|
Sheet<Note> getAllByResolved(boolean resolved, @NonNull Pagination pagination);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import org.sadtech.bot.gitlab.context.domain.entity.Discussion;
|
|||||||
import org.sadtech.bot.gitlab.context.domain.entity.MergeRequest;
|
import org.sadtech.bot.gitlab.context.domain.entity.MergeRequest;
|
||||||
import org.sadtech.bot.gitlab.context.domain.entity.Note;
|
import org.sadtech.bot.gitlab.context.domain.entity.Note;
|
||||||
import org.sadtech.bot.gitlab.context.domain.notify.comment.CommentNotify;
|
import org.sadtech.bot.gitlab.context.domain.notify.comment.CommentNotify;
|
||||||
|
import org.sadtech.bot.gitlab.context.domain.notify.task.TaskCloseNotify;
|
||||||
import org.sadtech.bot.gitlab.context.repository.DiscussionRepository;
|
import org.sadtech.bot.gitlab.context.repository.DiscussionRepository;
|
||||||
import org.sadtech.bot.gitlab.context.service.DiscussionService;
|
import org.sadtech.bot.gitlab.context.service.DiscussionService;
|
||||||
import org.sadtech.bot.gitlab.context.service.NotifyService;
|
import org.sadtech.bot.gitlab.context.service.NotifyService;
|
||||||
@@ -85,11 +86,35 @@ public class DiscussionServiceImpl extends AbstractSimpleManagerService<Discussi
|
|||||||
if (noteMap.containsKey(note.getId())) {
|
if (noteMap.containsKey(note.getId())) {
|
||||||
final Note oldNote = noteMap.get(note.getId());
|
final Note oldNote = noteMap.get(note.getId());
|
||||||
note.setWebUrl(oldNote.getWebUrl());
|
note.setWebUrl(oldNote.getWebUrl());
|
||||||
|
|
||||||
|
if (note.isResolvable()) {
|
||||||
|
updateTask(note, oldNote);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
notificationPersonal(note);
|
notificationPersonal(note);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateTask(Note note, Note oldNote) {
|
||||||
|
if (isResolved(note, oldNote)) {
|
||||||
|
notifyService.send(
|
||||||
|
TaskCloseNotify.builder()
|
||||||
|
.authorName(oldNote.getAuthor().getName())
|
||||||
|
.messageTask(oldNote.getBody())
|
||||||
|
.url(oldNote.getWebUrl())
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isResolved(Note note, Note oldNote) {
|
||||||
|
return oldNote.getResolvedBy() == null
|
||||||
|
&& note.getResolvedBy() != null
|
||||||
|
&& personInformation.getId().equals(oldNote.getAuthor().getId())
|
||||||
|
&& !note.getResolvedBy().getId().equals(oldNote.getAuthor().getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void answer(@NonNull String discussionId, @NonNull String text) {
|
public void answer(@NonNull String discussionId, @NonNull String text) {
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import org.sadtech.haiti.context.page.Sheet;
|
|||||||
import org.sadtech.haiti.core.service.AbstractSimpleManagerService;
|
import org.sadtech.haiti.core.service.AbstractSimpleManagerService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class NoteServiceImpl extends AbstractSimpleManagerService<Note, Long> implements NoteService {
|
public class NoteServiceImpl extends AbstractSimpleManagerService<Note, Long> implements NoteService {
|
||||||
@@ -37,4 +39,9 @@ public class NoteServiceImpl extends AbstractSimpleManagerService<Note, Long> im
|
|||||||
return noteRepository.findAllByResolved(resolved, pagination);
|
return noteRepository.findAllByResolved(resolved, pagination);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Note> getAllPersonTask(@NonNull Long userId, boolean resolved) {
|
||||||
|
return noteRepository.findAllByResponsibleIdAndResolved(userId, resolved);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,13 +113,17 @@ public class DiscussionParser {
|
|||||||
final List<Discussion> discussions = discussionSheet.getContent();
|
final List<Discussion> discussions = discussionSheet.getContent();
|
||||||
|
|
||||||
for (Discussion discussion : discussions) {
|
for (Discussion discussion : discussions) {
|
||||||
final Discussion newDiscussion = HttpParse.request(MessageFormat.format(gitlabProperty.getUrlOneDiscussion(), discussion.getMergeRequest().getProjectId(), discussion.getMergeRequest().getTwoId(), discussion.getId()))
|
if (discussion.getMergeRequest() != null) {
|
||||||
.header(ACCEPT)
|
final Discussion newDiscussion = HttpParse.request(MessageFormat.format(gitlabProperty.getUrlOneDiscussion(), discussion.getMergeRequest().getProjectId(), discussion.getMergeRequest().getTwoId(), discussion.getId()))
|
||||||
.header(AUTHORIZATION, BEARER + personProperty.getToken())
|
.header(ACCEPT)
|
||||||
.execute(DiscussionJson.class)
|
.header(AUTHORIZATION, BEARER + personProperty.getToken())
|
||||||
.map(json -> conversionService.convert(json, Discussion.class))
|
.execute(DiscussionJson.class)
|
||||||
.orElseThrow(() -> new ConvertException("Ошибка парсинга дискуссии"));
|
.map(json -> conversionService.convert(json, Discussion.class))
|
||||||
discussionService.update(newDiscussion);
|
.orElseThrow(() -> new ConvertException("Ошибка парсинга дискуссии"));
|
||||||
|
discussionService.update(newDiscussion);
|
||||||
|
} else {
|
||||||
|
discussionService.deleteById(discussion.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
discussionSheet = discussionService.getAll(PaginationImpl.of(++page, 100));
|
discussionSheet = discussionService.getAll(PaginationImpl.of(++page, 100));
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import org.sadtech.haiti.database.repository.manager.AbstractSimpleManagerReposi
|
|||||||
import org.sadtech.haiti.database.util.Converter;
|
import org.sadtech.haiti.database.util.Converter;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* // TODO: 08.09.2020 Добавить описание.
|
* // TODO: 08.09.2020 Добавить описание.
|
||||||
*
|
*
|
||||||
@@ -32,4 +34,10 @@ public class NoteRepositoryImpl extends AbstractSimpleManagerRepository<Note, Lo
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Note> findAllByResponsibleIdAndResolved(@NonNull Long userId, boolean resolved) {
|
||||||
|
return repositoryJpa.findAllByDiscussionResponsibleIdAndResolved(userId, resolved);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,12 @@ import org.springframework.data.domain.Page;
|
|||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface NoteRepositoryJpa extends JpaRepository<Note, Long> {
|
public interface NoteRepositoryJpa extends JpaRepository<Note, Long> {
|
||||||
|
|
||||||
Page<Note> findAllByResolved(boolean resolved, Pageable pageable);
|
Page<Note> findAllByResolved(boolean resolved, Pageable pageable);
|
||||||
|
|
||||||
|
List<Note> findAllByDiscussionResponsibleIdAndResolved(Long responsibleId, boolean resolved);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import org.sadtech.bot.gitlab.context.domain.PersonInformation;
|
|||||||
import org.sadtech.bot.gitlab.context.domain.entity.MergeRequest;
|
import org.sadtech.bot.gitlab.context.domain.entity.MergeRequest;
|
||||||
import org.sadtech.bot.gitlab.context.domain.filter.MergeRequestFilter;
|
import org.sadtech.bot.gitlab.context.domain.filter.MergeRequestFilter;
|
||||||
import org.sadtech.bot.gitlab.context.service.AppSettingService;
|
import org.sadtech.bot.gitlab.context.service.AppSettingService;
|
||||||
import org.sadtech.bot.gitlab.context.service.DiscussionService;
|
|
||||||
import org.sadtech.bot.gitlab.context.service.MergeRequestsService;
|
import org.sadtech.bot.gitlab.context.service.MergeRequestsService;
|
||||||
|
import org.sadtech.bot.gitlab.context.service.NoteService;
|
||||||
import org.sadtech.bot.gitlab.core.config.properties.GitlabProperty;
|
import org.sadtech.bot.gitlab.core.config.properties.GitlabProperty;
|
||||||
import org.sadtech.bot.gitlab.core.service.parser.ProjectParser;
|
import org.sadtech.bot.gitlab.core.service.parser.ProjectParser;
|
||||||
import org.sadtech.haiti.context.page.Sheet;
|
import org.sadtech.haiti.context.page.Sheet;
|
||||||
@@ -129,36 +129,27 @@ public class MenuConfig {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public AnswerText getTasks(
|
public AnswerText getTasks(
|
||||||
DiscussionService discussionService,
|
|
||||||
AppSettingService settingService,
|
AppSettingService settingService,
|
||||||
PersonInformation personInformation
|
PersonInformation personInformation,
|
||||||
|
NoteService noteService
|
||||||
) {
|
) {
|
||||||
return AnswerText.builder()
|
return AnswerText.builder()
|
||||||
.boxAnswer(message ->
|
.boxAnswer(message ->
|
||||||
{
|
{
|
||||||
final Long userId = personInformation.getId();
|
final Long userId = personInformation.getId();
|
||||||
final String text = "test";
|
final String text = noteService.getAllPersonTask(userId, false).stream()
|
||||||
// taskService.getAllPersonTask(userId, false).stream()
|
.map(note -> MessageFormat.format("- [{0}]({1})", trim(note.getBody()).replace("\n", " "), note.getWebUrl()))
|
||||||
// .collect(Collectors.groupingBy(Task::getMergeRequest))
|
.collect(Collectors.joining("\n"));
|
||||||
// .entrySet()
|
|
||||||
// .stream()
|
|
||||||
// .map(node -> {
|
|
||||||
// final String mrTitle = node.getKey().getTitle();
|
|
||||||
// final String mrUrl = node.getKey().getWebUrl();
|
|
||||||
//
|
|
||||||
// final String taskText = node.getValue().stream()
|
|
||||||
// .map(task -> MessageFormat.format("[{0}]({1})", task.getBody(), task.getWebUrl()))
|
|
||||||
// .collect(Collectors.joining("\n"));
|
|
||||||
//
|
|
||||||
// return MessageFormat.format("- [{0}]({1}):\n{2}", mrTitle, mrUrl, taskText);
|
|
||||||
// })
|
|
||||||
// .collect(Collectors.joining("\n\n"));
|
|
||||||
return BoxAnswer.of("".equals(text) ? settingService.getMessage("ui.answer.no_task") : text);
|
return BoxAnswer.of("".equals(text) ? settingService.getMessage("ui.answer.no_task") : text);
|
||||||
})
|
})
|
||||||
.phrase(settingService.getMessage("ui.menu.task"))
|
.phrase(settingService.getMessage("ui.menu.task"))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String trim(String body) {
|
||||||
|
return body.length() > 31 ? body.substring(0, 30) : body;
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public AnswerText getAssigneeMergeRequest(
|
public AnswerText getAssigneeMergeRequest(
|
||||||
MergeRequestsService mergeRequestsService,
|
MergeRequestsService mergeRequestsService,
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class UnitConfig {
|
|||||||
message -> {
|
message -> {
|
||||||
Mail mail = (Mail) message;
|
Mail mail = (Mail) message;
|
||||||
final List<Mail> forwardMails = mail.getForwardMail();
|
final List<Mail> forwardMails = mail.getForwardMail();
|
||||||
if (forwardMails.size() == 1) {
|
if (forwardMails != null && forwardMails.size() == 1) {
|
||||||
final Mail forwardMail = forwardMails.get(0);
|
final Mail forwardMail = forwardMails.get(0);
|
||||||
return forwardMail.getAttachments().stream()
|
return forwardMail.getAttachments().stream()
|
||||||
.anyMatch(attachment -> AttachmentType.LINK.equals(attachment.getType()));
|
.anyMatch(attachment -> AttachmentType.LINK.equals(attachment.getType()));
|
||||||
|
|||||||
Reference in New Issue
Block a user