Skip to content

Commit a72192e

Browse files
author
Antonis Tsakiridis
authored
Sorting implementation for Logs/Messages and Recordings (#2992)
Sorting implementation for Logs/Messages, Logs/Recordings and Logs/Notifications
1 parent 5737d91 commit a72192e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2381
-470
lines changed

restcomm/restcomm.application/src/main/webapp/WEB-INF/scripts/mariadb/sql/call-detail-records.xml

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -119,60 +119,59 @@
119119
</if>
120120
<choose>
121121
<when test="sortByDate != null">
122-
<if test="sortByDate.name() == 'ASCENDING'">
122+
<if test="sortByDate.name() == 'ASC'">
123123
order by date_created ASC
124124
</if>
125-
<if test="sortByDate.name() == 'DESCENDING'">
125+
<if test="sortByDate.name() == 'DESC'">
126126
order by date_created DESC
127127
</if>
128128
</when>
129129
<when test="sortByFrom != null">
130-
<if test="sortByFrom.name() == 'ASCENDING'">
131-
order by sender ASC
130+
<if test="sortByFrom.name() == 'ASC'">
131+
order by sender ASC, date_created DESC
132132
</if>
133-
<if test="sortByFrom.name() == 'DESCENDING'">
134-
order by sender DESC
133+
<if test="sortByFrom.name() == 'DESC'">
134+
order by sender DESC, date_created DESC
135135
</if>
136136
</when>
137-
138137
<when test="sortByTo != null">
139-
<if test="sortByTo.name() == 'ASCENDING'">
140-
order by recipient ASC
138+
<if test="sortByTo.name() == 'ASC'">
139+
order by recipient ASC, date_created DESC
141140
</if>
142-
<if test="sortByTo.name() == 'DESCENDING'">
143-
order by recipient DESC
141+
<if test="sortByTo.name() == 'DESC'">
142+
order by recipient DESC, date_created DESC
144143
</if>
145144
</when>
146145
<when test="sortByDirection != null">
147-
<if test="sortByDirection.name() == 'ASCENDING'">
148-
order by direction ASC
146+
<if test="sortByDirection.name() == 'ASC'">
147+
order by direction ASC, date_created DESC
149148
</if>
150-
<if test="sortByDirection.name() == 'DESCENDING'">
151-
order by direction DESC
149+
<if test="sortByDirection.name() == 'DESC'">
150+
order by direction DESC, date_created DESC
152151
</if>
153152
</when>
154153
<when test="sortByStatus != null">
155-
<if test="sortByStatus.name() == 'ASCENDING'">
156-
order by status ASC
154+
<if test="sortByStatus.name() == 'ASC'">
155+
order by status ASC, date_created DESC
157156
</if>
158-
<if test="sortByStatus.name() == 'DESCENDING'">
159-
order by status DESC
157+
<if test="sortByStatus.name() == 'DESC'">
158+
order by status DESC, date_created DESC
160159
</if>
161160
</when>
162161
<when test="sortByDuration != null">
163-
<if test="sortByDuration.name() == 'ASCENDING'">
164-
order by duration ASC
162+
<if test="sortByDuration.name() == 'ASC'">
163+
order by duration ASC, date_created DESC
165164
</if>
166-
<if test="sortByDuration.name() == 'DESCENDING'">
167-
order by duration DESC
165+
<if test="sortByDuration.name() == 'DESC'">
166+
order by duration DESC, date_created DESC
168167
</if>
169168
</when>
170169
<when test="sortByPrice != null">
171-
<if test="sortByPrice.name() == 'ASCENDING'">
172-
order by cast(price as unsigned) ASC
170+
<if test="sortByPrice.name() == 'ASC'">
171+
order by cast(price as unsigned) ASC, date_created DESC
173172
</if>
174-
<if test="sortByPrice.name() == 'DESCENDING'">
175-
order by cast(price as unsigned) DESC
173+
<if test="sortByPrice.name() == 'DESC'">
174+
order by cast(price as unsigned) DESC, date_created DESC
176175
</if>
177176
</when>
178177

restcomm/restcomm.application/src/main/webapp/WEB-INF/scripts/mariadb/sql/notifications.xml

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,53 @@
121121
<if test="endTime != null">
122122
AND date_created &lt;= DATE_ADD(#{endTime},INTERVAL 1 DAY)
123123
</if>
124-
order by date_created
125-
LIMIT #{limit} OFFSET #{offset}
124+
<choose>
125+
<when test="sortByDate != null">
126+
<if test="sortByDate.name() == 'ASC'">
127+
order by date_created ASC
128+
</if>
129+
<if test="sortByDate.name() == 'DESC'">
130+
order by date_created DESC
131+
</if>
132+
</when>
133+
<when test="sortByLog != null">
134+
<if test="sortByLog.name() == 'ASC'">
135+
order by log ASC, date_created DESC
136+
</if>
137+
<if test="sortByLog.name() == 'DESC'">
138+
order by log DESC, date_created DESC
139+
</if>
140+
</when>
141+
<when test="sortByErrorCode != null">
142+
<if test="sortByErrorCode.name() == 'ASC'">
143+
order by error_code ASC, date_created DESC
144+
</if>
145+
<if test="sortByErrorCode.name() == 'DESC'">
146+
order by error_code DESC, date_created DESC
147+
</if>
148+
</when>
149+
<when test="sortByCallSid != null">
150+
<if test="sortByCallSid.name() == 'ASC'">
151+
order by call_sid ASC, date_created DESC
152+
</if>
153+
<if test="sortByCallSid.name() == 'DESC'">
154+
order by call_sid DESC, date_created DESC
155+
</if>
156+
</when>
157+
<when test="sortByMessageText != null">
158+
<if test="sortByMessageText.name() == 'ASC'">
159+
order by message_text ASC, date_created DESC
160+
</if>
161+
<if test="sortByMessageText.name() == 'DESC'">
162+
order by message_text DESC, date_created DESC
163+
</if>
164+
</when>
165+
<otherwise>
166+
order by date_created DESC
167+
</otherwise>
168+
</choose>
169+
<if test="limit != null">
170+
LIMIT #{limit} OFFSET #{offset}
171+
</if>
126172
</select>
127173
</mapper>

restcomm/restcomm.application/src/main/webapp/WEB-INF/scripts/mariadb/sql/recordings.xml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,37 @@
106106
<if test="endTime != null">
107107
AND date_created &lt;= DATE_ADD(#{endTime},INTERVAL 1 DAY)
108108
</if>
109-
order by date_created
110-
LIMIT #{limit} OFFSET #{offset}
109+
<choose>
110+
<when test="sortByDate != null">
111+
<if test="sortByDate.name() == 'ASC'">
112+
order by date_created ASC
113+
</if>
114+
<if test="sortByDate.name() == 'DESC'">
115+
order by date_created DESC
116+
</if>
117+
</when>
118+
<when test="sortByDuration != null">
119+
<if test="sortByDuration.name() == 'ASC'">
120+
order by duration ASC, date_created DESC
121+
</if>
122+
<if test="sortByDuration.name() == 'DESC'">
123+
order by duration DESC, date_created DESC
124+
</if>
125+
</when>
126+
<when test="sortByCallSid != null">
127+
<if test="sortByCallSid.name() == 'ASC'">
128+
order by call_sid ASC, date_created DESC
129+
</if>
130+
<if test="sortByCallSid.name() == 'DESC'">
131+
order by call_sid DESC, date_created DESC
132+
</if>
133+
</when>
134+
<otherwise>
135+
order by date_created DESC
136+
</otherwise>
137+
</choose>
138+
<if test="limit != null">
139+
LIMIT #{limit} OFFSET #{offset}
140+
</if>
111141
</select>
112142
</mapper>

restcomm/restcomm.application/src/main/webapp/WEB-INF/scripts/mariadb/sql/sms-messages.xml

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
-->
66
<mapper namespace="org.mobicents.servlet.sip.restcomm.dao.SmsMessagesDao">
77
<insert id="addSmsMessage" parameterType="map">
8-
INSERT INTO restcomm_sms_messages (sid, date_created, date_updated, date_sent,
8+
INSERT INTO restcomm_sms_messages (sid, date_created, date_updated, date_sent,
99
account_sid, sender, recipient, body, status, direction,
10-
price, api_version, uri, status_callback, status_callback_method) VALUES (#{sid},
10+
price, api_version, uri, status_callback, status_callback_method) VALUES (#{sid},
1111
#{date_created}, #{date_updated}, #{date_sent}, #{account_sid}, #{sender}, #{recipient}, #{body},
1212
#{status}, #{direction}, #{price}, #{api_version}, #{uri}, #{status_callback},
1313
#{status_callback_method});
@@ -76,7 +76,7 @@
7676
</if>
7777
<!-- select * from "restcomm_sms_messages" where "start_time" >= '2013-08-23' order by "start_time" ; -->
7878
<if test="startTime != null">
79-
AND date_created &gt;= #{startTime}
79+
AND date_created &gt;= #{startTime}
8080
</if>
8181
<if test="endTime != null">
8282
AND date_created &lt;= DATE_ADD(#{endTime},INTERVAL 1 DAY)
@@ -112,6 +112,9 @@
112112
<if test="sender != null">
113113
AND sender like #{sender}
114114
</if>
115+
<if test="status != null">
116+
AND status like #{status}
117+
</if>
115118
<if test="body != null">
116119
AND body like '%'|| #{body} ||'%'
117120
</if>
@@ -122,8 +125,70 @@
122125
<if test="endTime != null">
123126
AND date_created &lt;= DATE_ADD(#{endTime},INTERVAL 1 DAY)
124127
</if>
125-
order by date_created
126-
LIMIT #{limit} OFFSET #{offset}
128+
<choose>
129+
<when test="sortByDate != null">
130+
<if test="sortByDate.name() == 'ASC'">
131+
order by date_created ASC
132+
</if>
133+
<if test="sortByDate.name() == 'DESC'">
134+
order by date_created DESC
135+
</if>
136+
</when>
137+
<when test="sortByFrom != null">
138+
<if test="sortByFrom.name() == 'ASC'">
139+
order by sender ASC, date_created DESC
140+
</if>
141+
<if test="sortByFrom.name() == 'DESC'">
142+
order by sender DESC, date_created DESC
143+
</if>
144+
</when>
145+
<when test="sortByTo != null">
146+
<if test="sortByTo.name() == 'ASC'">
147+
order by recipient ASC, date_created DESC
148+
</if>
149+
<if test="sortByTo.name() == 'DESC'">
150+
order by recipient DESC, date_created DESC
151+
</if>
152+
</when>
153+
<when test="sortByDirection != null">
154+
<if test="sortByDirection.name() == 'ASC'">
155+
order by direction ASC, date_created DESC
156+
</if>
157+
<if test="sortByDirection.name() == 'DESC'">
158+
order by direction DESC, date_created DESC
159+
</if>
160+
</when>
161+
<when test="sortByStatus != null">
162+
<if test="sortByStatus.name() == 'ASC'">
163+
order by status ASC, date_created DESC
164+
</if>
165+
<if test="sortByStatus.name() == 'DESC'">
166+
order by status DESC, date_created DESC
167+
</if>
168+
</when>
169+
<when test="sortByBody != null">
170+
<if test="sortByBody.name() == 'ASC'">
171+
order by body ASC, date_created DESC
172+
</if>
173+
<if test="sortByBody.name() == 'DESC'">
174+
order by body DESC, date_created DESC
175+
</if>
176+
</when>
177+
<when test="sortByPrice != null">
178+
<if test="sortByPrice.name() == 'ASC'">
179+
order by cast(price as unsigned) ASC, date_created DESC
180+
</if>
181+
<if test="sortByPrice.name() == 'DESC'">
182+
order by cast(price as unsigned) DESC, date_created DESC
183+
</if>
184+
</when>
185+
<otherwise>
186+
order by date_created DESC
187+
</otherwise>
188+
</choose>
189+
<if test="limit != null and offset != null">
190+
LIMIT #{limit} OFFSET #{offset}
191+
</if>
127192
</select>
128193

129194
<select id="findBySmppMessageId" parameterType="map" resultType="hashmap">

restcomm/restcomm.application/src/main/webapp/WEB-INF/sql/call-detail-records.xml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -122,59 +122,59 @@
122122
</where>
123123
<choose>
124124
<when test="sortByDate != null">
125-
<if test="sortByDate.name() == 'ASCENDING'">
125+
<if test="sortByDate.name() == 'ASC'">
126126
order by "date_created" ASC
127127
</if>
128-
<if test="sortByDate.name() == 'DESCENDING'">
128+
<if test="sortByDate.name() == 'DESC'">
129129
order by "date_created" DESC
130130
</if>
131131
</when>
132132
<when test="sortByFrom != null">
133-
<if test="sortByFrom.name() == 'ASCENDING'">
134-
order by "sender" ASC
133+
<if test="sortByFrom.name() == 'ASC'">
134+
order by "sender" ASC, "date_created" DESC
135135
</if>
136-
<if test="sortByFrom.name() == 'DESCENDING'">
137-
order by "sender" DESC
136+
<if test="sortByFrom.name() == 'DESC'">
137+
order by "sender" DESC, "date_created" DESC
138138
</if>
139139
</when>
140140
<when test="sortByTo != null">
141-
<if test="sortByTo.name() == 'ASCENDING'">
142-
order by "recipient" ASC
141+
<if test="sortByTo.name() == 'ASC'">
142+
order by "recipient" ASC, "date_created" DESC
143143
</if>
144-
<if test="sortByTo.name() == 'DESCENDING'">
145-
order by "recipient" DESC
144+
<if test="sortByTo.name() == 'DESC'">
145+
order by "recipient" DESC, "date_created" DESC
146146
</if>
147147
</when>
148148
<when test="sortByDirection != null">
149-
<if test="sortByDirection.name() == 'ASCENDING'">
150-
order by "direction" ASC
149+
<if test="sortByDirection.name() == 'ASC'">
150+
order by "direction" ASC, "date_created" DESC
151151
</if>
152-
<if test="sortByDirection.name() == 'DESCENDING'">
153-
order by "direction" DESC
152+
<if test="sortByDirection.name() == 'DESC'">
153+
order by "direction" DESC, "date_created" DESC
154154
</if>
155155
</when>
156156
<when test="sortByStatus != null">
157-
<if test="sortByStatus.name() == 'ASCENDING'">
158-
order by "status" ASC
157+
<if test="sortByStatus.name() == 'ASC'">
158+
order by "status" ASC, "date_created" DESC
159159
</if>
160-
<if test="sortByStatus.name() == 'DESCENDING'">
161-
order by "status" DESC
160+
<if test="sortByStatus.name() == 'DESC'">
161+
order by "status" DESC, "date_created" DESC
162162
</if>
163163
</when>
164164
<when test="sortByDuration != null">
165-
<if test="sortByDuration.name() == 'ASCENDING'">
166-
order by "duration" ASC
165+
<if test="sortByDuration.name() == 'ASC'">
166+
order by "duration" ASC, "date_created" DESC
167167
</if>
168-
<if test="sortByDuration.name() == 'DESCENDING'">
169-
order by "duration" DESC
168+
<if test="sortByDuration.name() == 'DESC'">
169+
order by "duration" DESC, "date_created" DESC
170170
</if>
171171
</when>
172172
<when test="sortByPrice != null">
173-
<if test="sortByPrice.name() == 'ASCENDING'">
174-
order by cast("price" as int) ASC
173+
<if test="sortByPrice.name() == 'ASC'">
174+
order by cast("price" as int) ASC, "date_created" DESC
175175
</if>
176-
<if test="sortByPrice.name() == 'DESCENDING'">
177-
order by cast("price" as int) DESC
176+
<if test="sortByPrice.name() == 'DESC'">
177+
order by cast("price" as int) DESC, "date_created" DESC
178178
</if>
179179
</when>
180180
<otherwise>

0 commit comments

Comments
 (0)