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

Cache Changes #1617

Open
wants to merge 1 commit into
base: Rel_8.0.0_PreProd_GS
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 @@ -33,9 +33,13 @@ public List<HierarchyLevel> getTopHierarchyLevels() {
public List<HierarchyLevel> getFullHierarchyLevels(boolean isKanban) {
List<HierarchyLevel> hierarchyLevels = new ArrayList<>();
List<HierarchyLevel> topHierarchyLevels = getTopHierarchyLevels();
log.info("GS List of hierarchy {}", topHierarchyLevels);
HierarchyLevel projectHierarchyLevel = getProjectHierarchyLevel();
log.info("GS List of projectHierarchyLevel {}", projectHierarchyLevel);
HierarchyLevel sprintHierarchyLevel = getSprintHierarchyLevel();
log.info("GS List of sprintHierarchyLevel {}", sprintHierarchyLevel);
HierarchyLevel releaseHierarchyLevel = getReleaseHierarchyLevel();
log.info("GS List of releaseHierarchyLevel {}", releaseHierarchyLevel);
hierarchyLevels.addAll(topHierarchyLevels);
hierarchyLevels.add(projectHierarchyLevel);
if (!isKanban) {
Expand All @@ -44,6 +48,7 @@ public List<HierarchyLevel> getFullHierarchyLevels(boolean isKanban) {
hierarchyLevels.add(releaseHierarchyLevel);
List<AdditionalFilterCategory> additionalFilterCategories = filterCategoryLevelService
.getAdditionalFilterCategories();
log.info("GS additionalFilterCategories {}", additionalFilterCategories);
if (CollectionUtils.isNotEmpty(additionalFilterCategories)) {

for (AdditionalFilterCategory additionalFilterCategory : additionalFilterCategories) {
Expand All @@ -58,7 +63,7 @@ public List<HierarchyLevel> getFullHierarchyLevels(boolean isKanban) {
hierarchyLevels.add(bottomHierarchyLevel);
}
}

log.info("GS additionalFilterCategories {}", hierarchyLevels);
return hierarchyLevels;
}

Expand All @@ -83,11 +88,14 @@ private HierarchyLevel createProjectHierarchyLevel(List<HierarchyLevel> topHiera
hierarchyLevel.setHierarchyLevelId(CommonConstant.HIERARCHY_LEVEL_ID_PROJECT);
hierarchyLevel.setHierarchyLevelName(CommonConstant.HIERARCHY_LEVEL_NAME_PROJECT);
if (CollectionUtils.isNotEmpty(topHierarchies)) {
log.info("GS topHierarchies", topHierarchies);
HierarchyLevel parent = topHierarchies.get(topHierarchies.size() - 1);
hierarchyLevel.setLevel(parent.getLevel() + 1);
} else {
log.info("GS topHierarchies", topHierarchies);
hierarchyLevel.setLevel(1);
}
log.info("GS hierarchyLevel", hierarchyLevel);
return hierarchyLevel;

}
Expand All @@ -98,11 +106,14 @@ private HierarchyLevel createSprintHierarchyLevel(List<HierarchyLevel> topHierar
hierarchyLevel.setHierarchyLevelId(CommonConstant.HIERARCHY_LEVEL_ID_SPRINT);
hierarchyLevel.setHierarchyLevelName(CommonConstant.HIERARCHY_LEVEL_NAME_SPRINT);
if (CollectionUtils.isNotEmpty(topHierarchies)) {
log.info("GS topHierarchies {}", topHierarchies);
HierarchyLevel parent = getProjectHierarchyLevel();
hierarchyLevel.setLevel(parent.getLevel() + 1);
} else {
log.info("GS topHierarchies {}", topHierarchies);
hierarchyLevel.setLevel(2);
}
log.info("GS hierarchyLevel", hierarchyLevel);
return hierarchyLevel;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public List<AccountHierarchyData> filterProjects(List<AccountHierarchyData> filt
public String[] getProjectKey(List<AccountHierarchyData> filteredAccountDataList, KpiRequest kpiRequest) {

Set<String> projects = getProjectNodesForRequest(filteredAccountDataList);
log.info("GS getProjectKey {}", projects);
List<String> ids = Arrays.asList(kpiRequest.getIds());
List<String> keys = Stream.concat(projects.stream(), ids.stream()).collect(Collectors.toList());
if(kpiRequest.getSelectedMap().get(Constant.DATE) != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public Object cacheProjectToolConfigMapData() {
@Override
public void setIntoApplicationCache(String key, String value) {
Cache cache = cacheManager.getCache(CommonUtils.getCacheName(Constant.KPI_REQUEST_TRACKER_ID_KEY));
log.info("GS1 cache {}", cache);
if (null != cache) {
cache.put(key, value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.function.Function;
import java.util.stream.Collectors;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.SerializationUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -57,6 +58,7 @@
* @author pkum34
*/
@Service
@Slf4j
public class AccountHierarchyServiceImpl
implements AccountHierarchyService<List<AccountHierarchyData>, Set<AccountFilteredData>> {

Expand Down Expand Up @@ -93,6 +95,7 @@ public Set<AccountFilteredData> getFilteredList(AccountFilterRequest request) {
hierarchyDataAll = filterHelperService
.getAccountHierarchyDataForRequest(new HashSet<>(request.getSprintIncluded()), hierarchyDataAll);
Set<String> basicProjectConfigIds = tokenAuthenticationService.getUserProjects();
log.info("GS List of sprintHierarchyLevel {}", basicProjectConfigIds);
if (!authorizedProjectsService.ifSuperAdminUser() && CollectionUtils.isNotEmpty(hierarchyDataAll)) {
hierarchyDataAll = hierarchyDataAll.stream()
.filter(data -> basicProjectConfigIds.contains(data.getBasicProjectConfigId().toHexString()))
Expand Down Expand Up @@ -139,11 +142,13 @@ private AccountFilteredData getAccountFilteredResponse(AccountHierarchy acc, int
public List<AccountHierarchyData> createHierarchyData() {

List<AccountHierarchy> filterDataList = accountHierarchyRepository.findAll();
log.info("GS filterDataList {}", filterDataList);
Map<String, List<AccountHierarchy>> parentWiseMap = filterDataList.stream()
.filter(fd -> fd.getParentId() != null).collect(Collectors.groupingBy(AccountHierarchy::getParentId));

List<AccountHierarchyData> listHierarchyData = new ArrayList<>();
String firstLevel = filterHelperService.getFirstHierarachyLevel();
log.info("GS firstLevel {}", firstLevel);

Map<String, Integer> hierarchyLevelIdMap = filterHelperService.getHierarchyIdLevelMap(false);

Expand All @@ -153,6 +158,7 @@ public List<AccountHierarchyData> createHierarchyData() {
List<String> sprintIds = filterDataList.stream()
.filter(x -> CommonConstant.HIERARCHY_LEVEL_ID_SPRINT.equalsIgnoreCase(x.getLabelName()))
.map(AccountHierarchy::getNodeId).collect(Collectors.toList());
log.info("GS sprintIds {}", sprintIds);
Map<String, SprintDetails> sprintDetailsMap = fetchSprintDetailsOf(sprintIds);

parentWiseSprintMap = filterDataList.stream()
Expand Down Expand Up @@ -188,7 +194,7 @@ public List<AccountHierarchyData> createHierarchyData() {
hierarchyLevelIdMap, limitedDisplayMap, sprintDetailsMap);
});
}

log.info("GS List of listHierarchyData {}", listHierarchyData);
return listHierarchyData;
}

Expand Down Expand Up @@ -360,6 +366,7 @@ private void setValuesInAccountHierarchyData(AccountHierarchy hierarchy, Account
if (sprintDetails != null) {
hierarchy.setSprintState(sprintDetails.getState());
}
log.info("GS setValuesInAccountHierarchyData ");
Node node = new Node(0, hierarchy.getNodeId(), hierarchy.getNodeName(), hierarchy.getParentId(),
hierarchy.getLabelName(), hierarchy);
node.setLevel(hierarchyLevelIdMap.getOrDefault(hierarchy.getLabelName(), 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ private List<AccountHierarchyData> filter(List<AccountHierarchyData> dataList, S

/**
* filter data based on sprint state
*
* @param sprintStateRequestList
* sprintStateList
*
* @param hierarchyDataAll
* hierarchyDataAll
* @return List<AccountHierarchyData>
Expand Down Expand Up @@ -292,11 +290,6 @@ private Map<Pair<String, String>, AccountHierarchy> getExistingAccountHierarchy(

/**
* clean filter data
*
* @param basicProjectConfigId
* id
* @param isKanban
* kanban or scrum
*/
public void cleanFilterData(ProjectBasicConfigDTO basicConfig) {
ObjectId basicProjectConfigId = basicConfig.getId();
Expand Down Expand Up @@ -581,27 +574,34 @@ private List<KanbanAccountHierarchy> findAccountHierarchiesAboveProvidedForDelet

public Map<String, HierarchyLevel> getHierarchyLevelMap(boolean isKanban) {
if (isKanban) {
log.info("GS For Kanban");
return cacheService.getFullKanbanHierarchyLevelMap();
} else {
log.info("GS For Scrum");
return cacheService.getFullHierarchyLevelMap();
}
}

public String getHierarachyLevelId(int level, String label, boolean isKanban) {
String hierarchyId = CommonConstant.HIERARCHY_LEVEL_ID_PROJECT;
Map<String, HierarchyLevel> map = getHierarchyLevelMap(isKanban);
log.info("GS Hierarachy LevelId method");
if (MapUtils.isNotEmpty(map)) {
if (StringUtils.isNotEmpty(label)) {
log.info("GS label");
hierarchyId = map.values().stream().filter(hlevel -> (hlevel.getLevel() == level)
&& (StringUtils.isNotEmpty(label) && hlevel.getHierarchyLevelId().equalsIgnoreCase(label)))
.map(HierarchyLevel::getHierarchyLevelId).findFirst()
.orElse(CommonConstant.HIERARCHY_LEVEL_ID_PROJECT);
log.info("hierarchyId {}", hierarchyId);
} else {
hierarchyId = map.values().stream().filter(hlevel -> (hlevel.getLevel() == level))
.map(HierarchyLevel::getHierarchyLevelId).findFirst()
.orElse(CommonConstant.HIERARCHY_LEVEL_ID_PROJECT);
log.info("hierarchyId {}", hierarchyId);
}
}
log.info("hierarchyId {}", hierarchyId);
return hierarchyId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public ResponseEntity<List<KpiElement>> getJiraAggregatedMetrics(@NotNull @Reque

List<KpiElement> responseList = jiraService.process(kpiRequest);
MDC.put("TotalJiraRequestTime", String.valueOf(System.currentTimeMillis() - jiraRequestStartTime));

log.info("GS1 Response List {}", responseList);
log.info("");
MDC.clear();
if (responseList.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,15 @@ public List<KpiElement> process(KpiRequest kpiRequest) throws EntityNotFoundExce
log.info("Processing KPI calculation for data {}", kpiRequest.getKpiList());
List<KpiElement> origRequestedKpis = kpiRequest.getKpiList().stream().map(KpiElement::new)
.collect(Collectors.toList());
log.info("GS List of OrigRequestedKPIs");
List<KpiElement> responseList = new ArrayList<>();
String[] projectKeyCache = null;
try {
Integer groupId = kpiRequest.getKpiList().get(0).getGroupId();
log.info("GS groupId {}", groupId);
String groupName = filterHelperService.getHierarachyLevelId(kpiRequest.getLevel(), kpiRequest.getLabel(),
false);
log.info("GS groupName {}", groupName);
if (null != groupName) {
kpiRequest.setLabel(groupName.toUpperCase());
} else {
Expand Down Expand Up @@ -222,10 +225,12 @@ private void updateJiraIssueList(KpiRequest kpiRequest, List<KpiElement> origReq
fetchSprintDetails(kpiRequest.getSelectedMap().get(CommonConstant.SPRINT));
String basicConfigId = filteredAccountDataList.get(0).getBasicProjectConfigId().toString();
List<String> sprintIssuesList = createIssuesList(basicConfigId);
log.info("GS sprintIssuesList {}", sprintIssuesList);
fetchJiraIssues(kpiRequest, basicConfigId, sprintIssuesList);
fetchJiraIssuesCustomHistory(basicConfigId);
} else if (origRequestedKpis.get(0).getKpiCategory().equalsIgnoreCase(CommonConstant.RELEASE)) {
releaseList = getReleaseList(treeAggregatorDetail);
log.info("GS sprintIssuesList {}", releaseList);
fetchJiraIssues(filteredAccountDataList.get(0).getBasicProjectConfigId().toString(), releaseList,
CommonConstant.RELEASE);
fetchJiraIssuesCustomHistory(filteredAccountDataList.get(0).getBasicProjectConfigId().toString(),
Expand Down Expand Up @@ -309,6 +314,7 @@ private void setIntoApplicationCache(KpiRequest kpiRequest, List<KpiElement> res
String[] projects) {
Integer sprintLevel = filterHelperService.getHierarchyIdLevelMap(false)
.get(CommonConstant.HIERARCHY_LEVEL_ID_SPRINT);
log.info("GS getProjectKey {}", sprintLevel);

if (!kpiRequest.getRequestTrackerId().toLowerCase().contains(KPISource.EXCEL.name().toLowerCase())
&& sprintLevel >= kpiRequest.getLevel() && isLeadTimeDuration(kpiRequest.getKpiList())) {
Expand Down Expand Up @@ -347,6 +353,7 @@ public void fetchJiraIssues(KpiRequest kpiRequest, String basicConfigId, List<St
uniqueProjectMap.put(basicConfigId, mapOfFilter);
jiraIssueList = jiraIssueRepository.findIssueByNumberWithAdditionalFilter(new HashSet<>(sprintIssuesList),
uniqueProjectMap);
log.info("GS jiraIssueList {}", jiraIssueList);
}

public void fetchJiraIssues(String basicProjectConfigId, List<String> sprintIssuesList, String board) {
Expand Down Expand Up @@ -403,6 +410,7 @@ public Set<JiraIssue> getSubTaskDefects() {

public void fetchJiraIssuesCustomHistory(String basicProjectConfigId) {
List<String> issueList = jiraIssueList.stream().map(JiraIssue::getNumber).collect(Collectors.toList());
log.info("GS sprintIssuesList {}", issueList);
jiraIssueCustomHistoryList = jiraIssueCustomHistoryRepository
.findByStoryIDInAndBasicProjectConfigIdIn(issueList, Collections.singletonList(basicProjectConfigId));

Expand Down