This commit is contained in:
@@ -111,7 +111,7 @@ public class GlobalSearchAsyncProcessor {
|
|||||||
globalSearchTaskRepository.save(task);
|
globalSearchTaskRepository.save(task);
|
||||||
|
|
||||||
} catch (InsufficientTokensException e) {
|
} catch (InsufficientTokensException e) {
|
||||||
log.warn("Insufficient tokens for user {}, stopping task: {}", userId, taskId);
|
log.warn("Insufficient tokens for user {}, stopping task: {}", userId, taskId, e);
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error processing file {} in task {}", file.getId(), taskId, e);
|
log.error("Error processing file {} in task {}", file.getId(), taskId, e);
|
||||||
@@ -124,6 +124,14 @@ public class GlobalSearchAsyncProcessor {
|
|||||||
task.setUpdatedAt(LocalDateTime.now());
|
task.setUpdatedAt(LocalDateTime.now());
|
||||||
globalSearchTaskRepository.save(task);
|
globalSearchTaskRepository.save(task);
|
||||||
|
|
||||||
|
} catch (InsufficientTokensException e) {
|
||||||
|
log.error("Task {} failed due to insufficient tokens for user {}", taskId, userId, e);
|
||||||
|
|
||||||
|
GlobalSearchTask task = globalSearchTaskRepository.findById(taskId).orElseThrow();
|
||||||
|
task.setStatus(SearchStatus.FAILED.name());
|
||||||
|
task.setUpdatedAt(LocalDateTime.now());
|
||||||
|
globalSearchTaskRepository.save(task);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Global search failed for task: {}", taskId, e);
|
log.error("Global search failed for task: {}", taskId, e);
|
||||||
|
|
||||||
@@ -134,7 +142,8 @@ public class GlobalSearchAsyncProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private GlobalSearchResult processFile(FileEntity file, String taskId, Long userId) throws MessagingException, IOException {
|
private GlobalSearchResult processFile(FileEntity file, String taskId, Long userId) throws MessagingException,
|
||||||
|
IOException, InsufficientTokensException {
|
||||||
GlobalSearchResult result = new GlobalSearchResult();
|
GlobalSearchResult result = new GlobalSearchResult();
|
||||||
result.setTaskId(taskId);
|
result.setTaskId(taskId);
|
||||||
result.setFileId(file.getId());
|
result.setFileId(file.getId());
|
||||||
@@ -147,8 +156,9 @@ public class GlobalSearchAsyncProcessor {
|
|||||||
TariffInfo activeTariffInfo = user.getActiveTariffInfo();
|
TariffInfo activeTariffInfo = user.getActiveTariffInfo();
|
||||||
int currentTokens = activeTariffInfo.getTokens() + activeTariffInfo.getBoughtTokens();
|
int currentTokens = activeTariffInfo.getTokens() + activeTariffInfo.getBoughtTokens();
|
||||||
|
|
||||||
|
log.info("Before sending email for user: {}", user.getEmail());
|
||||||
emailService.sendTokensNotFoundEmail(user, currentTokens, TariffConstants.TOKEN_VALUE_FOR_SEARCH);
|
emailService.sendTokensNotFoundEmail(user, currentTokens, TariffConstants.TOKEN_VALUE_FOR_SEARCH);
|
||||||
|
log.info("Email sent successfully to user: {}", user.getEmail());
|
||||||
result.setFileStatus(SearchStatus.FAILED.name());
|
result.setFileStatus(SearchStatus.FAILED.name());
|
||||||
|
|
||||||
globalSearchResultRepository.save(result);
|
globalSearchResultRepository.save(result);
|
||||||
|
|||||||
Reference in New Issue
Block a user