Skip to content

Commit

Permalink
Compute branch statistic when branch is created
Browse files Browse the repository at this point in the history
  • Loading branch information
byronantak committed Jan 2, 2025
1 parent 2f6aa60 commit 1968b16
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private PollableFuture<Asset> addOrUpdateAssetAndProcessIfNeeded(
FilterConfigIdOverride filterConfigIdOverride,
List<String> filterOptions,
@InjectCurrentTask PollableTask currentTask)
throws InterruptedException, ExecutionException, UnsupportedAssetFilterTypeException {
throws InterruptedException, UnsupportedAssetFilterTypeException {

PollableFutureTaskResult<Asset> pollableFutureTaskResult = new PollableFutureTaskResult<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.box.l10n.mojito.quartz.QuartzPollableTaskScheduler;
import com.box.l10n.mojito.service.pollableTask.PollableFuture;
import com.box.l10n.mojito.service.tm.BranchSourceRepository;
import com.box.l10n.mojito.service.tm.textunitdtocache.UpdateType;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import java.text.MessageFormat;
Expand Down Expand Up @@ -42,6 +43,8 @@ public class BranchService {

@Autowired BranchSourceConfig branchSourceConfig;

@Autowired BranchStatisticService branchStatisticService;

@Value("${l10n.branchService.quartz.schedulerName:" + DEFAULT_SCHEDULER_NAME + "}")
String schedulerName;

Expand All @@ -56,9 +59,11 @@ public Branch createBranch(
branch.setCreatedByUser(createdByUser);
branch.setNotifiers(branchNotifierIds);
branch = branchRepository.save(branch);

addBranchSource(branch);

branchStatisticService.computeAndSaveBranchStatistics(
repository.getId(), branchName, UpdateType.ALWAYS);

return branch;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ public class BranchStatisticService {
/** logger */
static Logger logger = getLogger(BranchStatisticService.class);

@Autowired BranchService branchService;

@Autowired BranchRepository branchRepository;

@Autowired BranchStatisticRepository branchStatisticRepository;
Expand Down Expand Up @@ -146,7 +144,7 @@ void computeAndSaveBranchStatistics(
ImmutableSet<String> branchNamesToCheck =
branches.stream().map(Branch::getName).collect(ImmutableSet.toImmutableSet());

logger.info("Computing branch stastistics");
logger.info("Computing branch statistics");

Map<String, ImmutableMap<Long, ForTranslationCountForTmTextUnitId>>
mapBranchNameToTranslationCountForTextUnitId =
Expand Down

0 comments on commit 1968b16

Please sign in to comment.