Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ejercicio2-framework-back
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Josue
ejercicio2-framework-back
Commits
6f35ea6c
Commit
6f35ea6c
authored
Nov 25, 2021
by
Cristian Aguirre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update DashboardService
parent
bfe18190
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
6 deletions
+20
-6
CustomerInteractionDashboardService.java
...ervice/dashboard/CustomerInteractionDashboardService.java
+20
-2
DashboardService.java
...om/bytesw/bytebot/service/dashboard/DashboardService.java
+0
-4
No files found.
src/main/java/com/bytesw/bytebot/service/dashboard/CustomerInteractionDashboardService.java
View file @
6f35ea6c
...
...
@@ -4,6 +4,8 @@ import com.bytesw.bytebot.bean.*;
import
com.bytesw.bytebot.jdbc.ActionJDBCRepository
;
import
com.bytesw.bytebot.jdbc.MessageJDBCRepository
;
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.stereotype.Service
;
...
...
@@ -18,6 +20,7 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
@Log4j2
@Service
public
class
CustomerInteractionDashboardService
extends
DashboardService
{
...
...
@@ -30,10 +33,11 @@ public class CustomerInteractionDashboardService extends DashboardService {
@Override
protected
void
completeData
(
OffsetDateTime
startDate
,
OffsetDateTime
endDate
,
Integer
rangeMinutes
,
Map
<
String
,
Object
>
info
)
{
List
<
RangeBean
>
rangeList
=
calculateRangeList
(
startDate
,
endDate
);
log
.
debug
(
"PERIOD: "
+
rangeList
);
info
.
put
(
"sessionFlow"
,
generateInteractionByCustomerData
(
startDate
,
endDate
));
info
.
put
(
"summaryGoals"
,
generateSummaryByGoals
(
startDate
,
endDate
));
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 {
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
<>();
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
.
stream
().
forEach
(
intentSummary
->
{
identifiers
.
add
((
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
,
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
;
}
...
...
src/main/java/com/bytesw/bytebot/service/dashboard/DashboardService.java
View file @
6f35ea6c
...
...
@@ -80,9 +80,6 @@ public abstract class DashboardService {
protected
List
<
RangeBean
>
calculateMinutesRangeList
(
OffsetDateTime
startDate
,
OffsetDateTime
endDate
,
Integer
range
){
List
<
RangeBean
>
rangeList
=
new
ArrayList
<>();
log
.
debug
(
"START: "
+
startDate
);
log
.
debug
(
"END: "
+
endDate
);
log
.
debug
(
"PERIOD: "
+
range
);
OffsetDateTime
nextRange
=
startDate
.
plusMinutes
(
range
);
OffsetDateTime
startNextRange
=
startDate
;
while
(
nextRange
.
isBefore
(
endDate
)){
...
...
@@ -92,7 +89,6 @@ public abstract class DashboardService {
rangeList
.
add
(
rangeBean
);
startNextRange
=
nextRange
;
nextRange
=
nextRange
.
plusMinutes
(
range
);
//log.debug("DATE: "+rangeBean.getStartDate());
}
RangeBean
rangeBean
=
new
RangeBean
();
rangeBean
.
setStartDate
(
startNextRange
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment