Commit 6f35ea6c authored by Cristian Aguirre's avatar Cristian Aguirre

Update DashboardService

parent bfe18190
...@@ -4,6 +4,8 @@ import com.bytesw.bytebot.bean.*; ...@@ -4,6 +4,8 @@ import com.bytesw.bytebot.bean.*;
import com.bytesw.bytebot.jdbc.ActionJDBCRepository; import com.bytesw.bytebot.jdbc.ActionJDBCRepository;
import com.bytesw.bytebot.jdbc.MessageJDBCRepository; import com.bytesw.bytebot.jdbc.MessageJDBCRepository;
import com.bytesw.xdf.sql.beans.Pagination; import com.bytesw.xdf.sql.beans.Pagination;
import lombok.extern.java.Log;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -18,6 +20,7 @@ import java.util.HashMap; ...@@ -18,6 +20,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@Log4j2
@Service @Service
public class CustomerInteractionDashboardService extends DashboardService { public class CustomerInteractionDashboardService extends DashboardService {
...@@ -30,10 +33,11 @@ public class CustomerInteractionDashboardService extends DashboardService { ...@@ -30,10 +33,11 @@ public class CustomerInteractionDashboardService extends DashboardService {
@Override @Override
protected void completeData(OffsetDateTime startDate, OffsetDateTime endDate, Integer rangeMinutes,Map<String, Object> info) { protected void completeData(OffsetDateTime startDate, OffsetDateTime endDate, Integer rangeMinutes,Map<String, Object> info) {
List<RangeBean> rangeList = calculateRangeList(startDate, endDate); List<RangeBean> rangeList = calculateRangeList(startDate, endDate);
log.debug("PERIOD: "+rangeList);
info.put("sessionFlow", generateInteractionByCustomerData(startDate, endDate)); info.put("sessionFlow", generateInteractionByCustomerData(startDate, endDate));
info.put("summaryGoals", generateSummaryByGoals(startDate, endDate)); info.put("summaryGoals", generateSummaryByGoals(startDate, endDate));
info.put("intentAvgByCustomer", generateAverageIntentsByCustomer(rangeList)); info.put("intentAvgByCustomer", generateAverageIntentsByCustomer(rangeList));
info.put("summaryIntents", generateSummaryMessageByIntent(rangeList)); info.put("summaryIntents", generateSummaryMessageByIntent(rangeList,startDate,endDate));
} }
...@@ -48,17 +52,31 @@ public class CustomerInteractionDashboardService extends DashboardService { ...@@ -48,17 +52,31 @@ public class CustomerInteractionDashboardService extends DashboardService {
return actionByGoalList; return actionByGoalList;
} }
private Map<String, List<Object>> generateSummaryMessageByIntent(List<RangeBean> rangeList) { private Map<String, List<Object>> generateSummaryMessageByIntent(List<RangeBean> rangeList,OffsetDateTime startDate, OffsetDateTime endDate) {
List<MessageByIntentBean> total_list = messageJDBCRepository.countMessageByIntent(startDate,endDate);
Map<String, List<Object>> data = new HashMap<>(); Map<String, List<Object>> data = new HashMap<>();
rangeList.stream().forEach(x -> { rangeList.stream().forEach(x -> {
List<String> identifiers = new ArrayList<>();
log.debug("START: "+x.getStartDate());
log.debug(("END: "+x.getEndDate()));
List<MessageByIntentBean> list = messageJDBCRepository.countMessageByIntent(x.getStartDate(), x.getEndDate()); List<MessageByIntentBean> list = messageJDBCRepository.countMessageByIntent(x.getStartDate(), x.getEndDate());
list.stream().forEach(intentSummary -> { list.stream().forEach(intentSummary -> {
identifiers.add((intentSummary.getIdentifier()));
if (!data.containsKey(intentSummary.getIdentifier())){ if (!data.containsKey(intentSummary.getIdentifier())){
data.put(intentSummary.getIdentifier(), new ArrayList<>()); data.put(intentSummary.getIdentifier(), new ArrayList<>());
} }
data.get(intentSummary.getIdentifier()).add(new Object[]{getDayOnStart(x.getStartDate()).toInstant().toEpochMilli()/1000, intentSummary.getCount()}); data.get(intentSummary.getIdentifier()).add(new Object[]{getDayOnStart(x.getStartDate()).toInstant().toEpochMilli()/1000, intentSummary.getCount()});
}); });
total_list.stream().forEach(intentSummary -> {
if(!identifiers.contains(intentSummary.getIdentifier())){
if(!data.containsKey(intentSummary.getIdentifier())){
data.put(intentSummary.getIdentifier(),new ArrayList<>());
}
data.get(intentSummary.getIdentifier()).add(new Object[]{getDayOnStart(x.getStartDate()).toInstant().toEpochMilli()/1000, 0});
}
});
}); });
log.debug("DATA: "+data);
return data; return data;
} }
......
...@@ -80,9 +80,6 @@ public abstract class DashboardService { ...@@ -80,9 +80,6 @@ public abstract class DashboardService {
protected List<RangeBean> calculateMinutesRangeList(OffsetDateTime startDate, OffsetDateTime endDate, Integer range){ protected List<RangeBean> calculateMinutesRangeList(OffsetDateTime startDate, OffsetDateTime endDate, Integer range){
List<RangeBean> rangeList = new ArrayList<>(); List<RangeBean> rangeList = new ArrayList<>();
log.debug("START: "+startDate);
log.debug("END: "+endDate);
log.debug("PERIOD: "+range);
OffsetDateTime nextRange = startDate.plusMinutes(range); OffsetDateTime nextRange = startDate.plusMinutes(range);
OffsetDateTime startNextRange = startDate; OffsetDateTime startNextRange = startDate;
while(nextRange.isBefore(endDate)){ while(nextRange.isBefore(endDate)){
...@@ -92,7 +89,6 @@ public abstract class DashboardService { ...@@ -92,7 +89,6 @@ public abstract class DashboardService {
rangeList.add(rangeBean); rangeList.add(rangeBean);
startNextRange = nextRange; startNextRange = nextRange;
nextRange = nextRange.plusMinutes(range); nextRange = nextRange.plusMinutes(range);
//log.debug("DATE: "+rangeBean.getStartDate());
} }
RangeBean rangeBean = new RangeBean(); RangeBean rangeBean = new RangeBean();
rangeBean.setStartDate(startNextRange); rangeBean.setStartDate(startNextRange);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment