void purgeAnalyses(List<IdUuidPair> analysisUuids) { List<List<String>> analysisUuidsPartitions = Lists.partition(IdUuidPairs.uuids(analysisUuids), MAX_SNAPSHOTS_PER_QUERY); deleteAnalysisDuplications(analysisUuidsPartitions); profiler.start("deleteSnapshotWastedMeasures (project_measures)"); List<Long> metricIdsWithoutHistoricalData = purgeMapper.selectMetricIdsWithoutHistoricalData(); if (!metricIdsWithoutHistoricalData.isEmpty()) { analysisUuidsPartitions .forEach(analysisUuidsPartition -> purgeMapper.deleteAnalysisWastedMeasures(analysisUuidsPartition, metricIdsWithoutHistoricalData)); session.commit(); } profiler.stop(); profiler.start("updatePurgeStatusToOne (snapshots)"); analysisUuidsPartitions.forEach(purgeMapper::updatePurgeStatusToOne); session.commit(); profiler.stop(); }
void deleteComponentMeasures(List<String> analysisUuids, List<String> componentUuids) { if (analysisUuids.isEmpty() || componentUuids.isEmpty()) { return; } List<List<String>> analysisUuidsPartitions = Lists.partition(analysisUuids, MAX_SNAPSHOTS_PER_QUERY); List<List<String>> componentUuidsPartitions = Lists.partition(componentUuids, MAX_RESOURCES_PER_QUERY); profiler.start("deleteComponentMeasures"); for (List<String> analysisUuidsPartition : analysisUuidsPartitions) { for (List<String> componentUuidsPartition : componentUuidsPartitions) { purgeMapper.deleteComponentMeasures(analysisUuidsPartition, componentUuidsPartition); } } session.commit(); profiler.stop(); }
void deleteFileSources(String rootUuid) { profiler.start("deleteFileSources (file_sources)"); purgeMapper.deleteFileSourcesByProjectUuid(rootUuid); session.commit(); profiler.stop(); }
private static void deleteOldClosedIssues(PurgeConfiguration conf, PurgeMapper mapper, PurgeListener listener) { Date toDate = conf.maxLiveDateOfClosedIssues(); String rootUuid = conf.rootProjectIdUuid().getUuid(); List<String> issueKeys = mapper.selectOldClosedIssueKeys(rootUuid, dateToLong(toDate)); executeLargeInputs(issueKeys, input -> { mapper.deleteIssueChangesFromIssueKeys(input); return emptyList(); }); executeLargeInputs(issueKeys, input -> { mapper.deleteIssuesFromKeys(input); return emptyList(); }); listener.onIssuesRemoval(rootUuid, issueKeys); }
private void purgeDisabledComponents(DbSession session, PurgeConfiguration conf, PurgeListener listener) { PurgeMapper mapper = mapper(session); executeLargeInputs(conf.getDisabledComponentUuids(), input -> { mapper.deleteFileSourcesByFileUuid(input); mapper.resolveComponentIssuesNotAlreadyResolved(input, system2.now()); mapper.deleteLiveMeasuresByComponentUuids(input); return emptyList(); }); listener.onComponentsDisabling(conf.rootProjectIdUuid().getUuid(), conf.getDisabledComponentUuids()); session.commit(); }
List<IdUuidPair> selectSnapshotIdUuids(PurgeSnapshotQuery query) { return purgeMapper.selectAnalysisIdsAndUuids(query); }
void deleteAnalyses(String rootComponentUuid) { profiler.start("deleteAnalyses (event_component_changes)"); purgeMapper.deleteEventComponentChangesByComponentUuid(rootComponentUuid); session.commit(); profiler.stop(); profiler.start("deleteAnalyses (events)"); purgeMapper.deleteEventsByComponentUuid(rootComponentUuid); session.commit(); profiler.stop(); List<List<String>> analysisUuidsPartitions = Lists.partition(IdUuidPairs.uuids( purgeMapper.selectAnalysisIdsAndUuids(new PurgeSnapshotQuery().setComponentUuid(rootComponentUuid))), MAX_SNAPSHOTS_PER_QUERY); deleteAnalysisDuplications(analysisUuidsPartitions); profiler.start("deleteAnalyses (project_measures)"); analysisUuidsPartitions.forEach(purgeMapper::deleteAnalysisMeasures); session.commit(); profiler.stop(); profiler.start("deleteAnalyses (snapshots)"); analysisUuidsPartitions.forEach(purgeMapper::deleteAnalyses); session.commit(); profiler.stop(); profiler.start("deleteAnalyses (analysis_properties)"); analysisUuidsPartitions.forEach(purgeMapper::deleteAnalysisProperties); session.commit(); profiler.stop(); }
private void purgeDisabledComponents(DbSession session, Collection<String> uuids, PurgeListener listener) { PurgeMapper mapper = mapper(session); executeLargeInputs(uuids, input -> { mapper.deleteFileSourcesByUuid(input); mapper.resolveComponentIssuesNotAlreadyResolved(input, system2.now()); return emptyList(); }); for (String componentUuid : uuids) { listener.onComponentDisabling(componentUuid); } session.commit(); }
void deleteWebhookDeliveries(String rootUuid) { profiler.start("deleteWebhookDeliveries (webhook_deliveries)"); purgeMapper.deleteWebhookDeliveriesByProjectUuid(rootUuid); session.commit(); profiler.stop(); }
private static void deleteOldClosedIssues(PurgeConfiguration conf, PurgeMapper mapper, PurgeListener listener) { Date toDate = conf.maxLiveDateOfClosedIssues(); String rootUuid = conf.rootProjectIdUuid().getUuid(); List<String> issueKeys = mapper.selectOldClosedIssueKeys(rootUuid, dateToLong(toDate)); executeLargeInputs(issueKeys, input -> { mapper.deleteIssueChangesFromIssueKeys(input); return emptyList(); }); executeLargeInputs(issueKeys, input -> { mapper.deleteIssuesFromKeys(input); return emptyList(); }); listener.onIssuesRemoval(rootUuid, issueKeys); }
List<String> selectSnapshotUuids(PurgeSnapshotQuery query) { return purgeMapper.selectAnalysisIdsAndUuids(query).stream().map(IdUuidPair::getUuid).collect(Collectors.toList()); }
public void deleteWebhookDeliveries(String rootUuid) { profiler.start("deleteWebhookDeliveries (webhook_deliveries)"); purgeMapper.deleteWebhookDeliveriesByProjectUuid(rootUuid); session.commit(); profiler.stop(); } }
public void purgeAnalyses(List<IdUuidPair> analysisUuids) { List<List<String>> analysisUuidsPartitions = Lists.partition(IdUuidPairs.uuids(analysisUuids), MAX_SNAPSHOTS_PER_QUERY); deleteAnalysisDuplications(analysisUuidsPartitions); profiler.start("deleteSnapshotWastedMeasures (project_measures)"); List<Long> metricIdsWithoutHistoricalData = purgeMapper.selectMetricIdsWithoutHistoricalData(); analysisUuidsPartitions.stream() .forEach(analysisUuidsPartition -> purgeMapper.deleteAnalysisWastedMeasures(analysisUuidsPartition, metricIdsWithoutHistoricalData)); session.commit(); profiler.stop(); profiler.start("updatePurgeStatusToOne (snapshots)"); analysisUuidsPartitions.forEach(purgeMapper::updatePurgeStatusToOne); session.commit(); profiler.stop(); }
void deleteAnalyses(PurgeSnapshotQuery... queries) { List<IdUuidPair> snapshotIds = Arrays.stream(queries) .flatMap(q -> purgeMapper.selectAnalysisIdsAndUuids(q).stream()) .collect(Collectors.toList()); deleteAnalyses(snapshotIds); }
public void deleteFileSources(String rootUuid) { profiler.start("deleteFileSources (file_sources)"); purgeMapper.deleteFileSourcesByProjectUuid(rootUuid); session.commit(); profiler.stop(); }
public void deleteComponentMeasures(List<String> analysisUuids, List<String> componentUuids) { if (analysisUuids.isEmpty() || componentUuids.isEmpty()) { return; } List<List<String>> analysisUuidsPartitions = Lists.partition(analysisUuids, MAX_SNAPSHOTS_PER_QUERY); List<List<String>> componentUuidsPartitions = Lists.partition(componentUuids, MAX_RESOURCES_PER_QUERY); profiler.start("deleteComponentMeasures"); for (List<String> analysisUuidsPartition : analysisUuidsPartitions) { for (List<String> componentUuidsPartition : componentUuidsPartitions) { purgeMapper.deleteComponentMeasures(analysisUuidsPartition, componentUuidsPartition); } } session.commit(); profiler.stop(); }
List<IdUuidPair> selectSnapshotIdUuids(PurgeSnapshotQuery query) { return purgeMapper.selectAnalysisIdsAndUuids(query); }
List<String> selectSnapshotUuids(PurgeSnapshotQuery query) { return purgeMapper.selectAnalysisIdsAndUuids(query).stream().map(IdUuidPair::getUuid).collect(Collectors.toList()); }
void deleteAnalyses(String rootUuid) { deleteAnalyses(purgeMapper.selectAnalysisIdsAndUuids(new PurgeSnapshotQuery().setComponentUuid(rootUuid))); }