@@ -9,10 +9,17 @@ const RouteLocations = (props) => {
99
1010 if ( communicationsData . length > 0 && communicationsData [ 0 ] [ "_id" ] ) {
1111 //Sort the communication array from latest to earliest document
12- communicationsData . sort ( ( a , b ) => { new Date ( a . timeSent ) - new Date ( b . timeSent ) } )
12+ // communicationsData.sort((a,b)=>{ new Date(a.timeSent) - new Date(b.timeSent)})
13+ communicationsData . sort ( ( a , b ) => {
14+ if ( new Date ( a . timeSent ) > new Date ( b . timeSent ) ) return 1 ;
15+ if ( new Date ( a . timeSent ) < new Date ( b . timeSent ) ) return - 1 ;
16+ return 0 ;
17+ } ) ;
18+
19+
1320
1421 //Iterate over sorted communicationsData array from the end to the beginning
15- for ( let i = communicationsData . length - 1 ; i >= 0 ; i -- ) {
22+ for ( let i = 0 ; i < communicationsData . length ; i += 1 ) {
1623 //declare a constant element and initialize it as the object at index i of the communicationsData array
1724 const element = communicationsData [ i ] ;
1825 //Pushes the microservice name into the object
@@ -34,9 +41,10 @@ const RouteLocations = (props) => {
3441
3542 //use object values to destructure locations
3643 const tracePoints = Object . values ( resObj ) ;
37- let position = tracePoints . length - 1 ;
44+ let position = communicationsData [ 0 ] . correlatingid ? 0 : tracePoints . length - 1 ;
3845
3946 const resArray = [ ] ;
47+
4048 for ( let i = 0 ; i < tracePoints [ position ] . length ; i += 1 ) {
4149 resArray . push (
4250 < div className = "RouteCircle" key = { i } >
@@ -53,3 +61,4 @@ const RouteLocations = (props) => {
5361} ;
5462
5563export default RouteLocations ;
64+
0 commit comments