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

Sorting implementation for Logs/Messages, Recordings and Notifications #2992

Merged
merged 20 commits into from
Jul 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
40da6af
FS-269: Added SQL, filter and unit tests for SMS Sorting
Jul 6, 2018
d7b55b8
FS-269: Fixed some query string issues, added documentation, updated …
Jul 9, 2018
fad30fd
FS-298: Fixed wildcarding for body attribute
Jul 9, 2018
a7f84b9
FS-269: Adding secondary sorting on date_created descending, when sor…
Jul 9, 2018
e08c27e
FS-269: Came up with common sorting facilities that any interested AP…
Jul 9, 2018
451dd0a
Revert "FS-298: Fixed wildcarding for body attribute"
Jul 10, 2018
a02b7e4
FS-270: Updated MyBatis mappers
Jul 10, 2018
a5d490d
Merge branch 'atsakiridis_FS-269' into atsakiridis_FS-270
Jul 10, 2018
8093d2e
FS-270: Added API and filter code
Jul 10, 2018
ab464ca
FS-270: Fixed syntax error in MyBatis mapper file for HSQL, introduce…
Jul 10, 2018
e9bd7d8
FS-270: Introduced http integration tests for Recordings' sorting
Jul 10, 2018
189bd35
FS-270: Add API documentation for recordings for new sorting facilities
Jul 10, 2018
0dce077
FS-271: Updated API documentation for sorting of Notifications
Jul 11, 2018
8b7ac82
FS-271: Updated MyBatis mapper files with sorting facilities for Noti…
Jul 11, 2018
d485f78
FS-271: Added API and filter code for Notifications
Jul 12, 2018
c4a2310
FS-271: Introduced Dao tests for Notifications and renamed level -> l…
Jul 12, 2018
fe6d3a7
FS-270: Added integration tests for Logs/Notifications, fixed all the…
Jul 13, 2018
c90a92d
FS-271: Added integration tests for Logs/Notifications, fixed all the…
Jul 13, 2018
73634be
Merge branch 'atsakiridis_FS-270' of https://github.com/RestComm/Rest…
Jul 16, 2018
dd547d3
Merge branch 'master' into atsakiridis_FS-270
Jul 16, 2018
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 @@ -119,60 +119,59 @@
</if>
<choose>
<when test="sortByDate != null">
<if test="sortByDate.name() == 'ASCENDING'">
<if test="sortByDate.name() == 'ASC'">
order by date_created ASC
</if>
<if test="sortByDate.name() == 'DESCENDING'">
<if test="sortByDate.name() == 'DESC'">
order by date_created DESC
</if>
</when>
<when test="sortByFrom != null">
<if test="sortByFrom.name() == 'ASCENDING'">
order by sender ASC
<if test="sortByFrom.name() == 'ASC'">
order by sender ASC, date_created DESC
</if>
<if test="sortByFrom.name() == 'DESCENDING'">
order by sender DESC
<if test="sortByFrom.name() == 'DESC'">
order by sender DESC, date_created DESC
</if>
</when>

<when test="sortByTo != null">
<if test="sortByTo.name() == 'ASCENDING'">
order by recipient ASC
<if test="sortByTo.name() == 'ASC'">
order by recipient ASC, date_created DESC
</if>
<if test="sortByTo.name() == 'DESCENDING'">
order by recipient DESC
<if test="sortByTo.name() == 'DESC'">
order by recipient DESC, date_created DESC
</if>
</when>
<when test="sortByDirection != null">
<if test="sortByDirection.name() == 'ASCENDING'">
order by direction ASC
<if test="sortByDirection.name() == 'ASC'">
order by direction ASC, date_created DESC
</if>
<if test="sortByDirection.name() == 'DESCENDING'">
order by direction DESC
<if test="sortByDirection.name() == 'DESC'">
order by direction DESC, date_created DESC
</if>
</when>
<when test="sortByStatus != null">
<if test="sortByStatus.name() == 'ASCENDING'">
order by status ASC
<if test="sortByStatus.name() == 'ASC'">
order by status ASC, date_created DESC
</if>
<if test="sortByStatus.name() == 'DESCENDING'">
order by status DESC
<if test="sortByStatus.name() == 'DESC'">
order by status DESC, date_created DESC
</if>
</when>
<when test="sortByDuration != null">
<if test="sortByDuration.name() == 'ASCENDING'">
order by duration ASC
<if test="sortByDuration.name() == 'ASC'">
order by duration ASC, date_created DESC
</if>
<if test="sortByDuration.name() == 'DESCENDING'">
order by duration DESC
<if test="sortByDuration.name() == 'DESC'">
order by duration DESC, date_created DESC
</if>
</when>
<when test="sortByPrice != null">
<if test="sortByPrice.name() == 'ASCENDING'">
order by cast(price as unsigned) ASC
<if test="sortByPrice.name() == 'ASC'">
order by cast(price as unsigned) ASC, date_created DESC
</if>
<if test="sortByPrice.name() == 'DESCENDING'">
order by cast(price as unsigned) DESC
<if test="sortByPrice.name() == 'DESC'">
order by cast(price as unsigned) DESC, date_created DESC
</if>
</when>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,53 @@
<if test="endTime != null">
AND date_created &lt;= DATE_ADD(#{endTime},INTERVAL 1 DAY)
</if>
order by date_created
LIMIT #{limit} OFFSET #{offset}
<choose>
<when test="sortByDate != null">
<if test="sortByDate.name() == 'ASC'">
order by date_created ASC
</if>
<if test="sortByDate.name() == 'DESC'">
order by date_created DESC
</if>
</when>
<when test="sortByLog != null">
<if test="sortByLog.name() == 'ASC'">
order by log ASC, date_created DESC
</if>
<if test="sortByLog.name() == 'DESC'">
order by log DESC, date_created DESC
</if>
</when>
<when test="sortByErrorCode != null">
<if test="sortByErrorCode.name() == 'ASC'">
order by error_code ASC, date_created DESC
</if>
<if test="sortByErrorCode.name() == 'DESC'">
order by error_code DESC, date_created DESC
</if>
</when>
<when test="sortByCallSid != null">
<if test="sortByCallSid.name() == 'ASC'">
order by call_sid ASC, date_created DESC
</if>
<if test="sortByCallSid.name() == 'DESC'">
order by call_sid DESC, date_created DESC
</if>
</when>
<when test="sortByMessageText != null">
<if test="sortByMessageText.name() == 'ASC'">
order by message_text ASC, date_created DESC
</if>
<if test="sortByMessageText.name() == 'DESC'">
order by message_text DESC, date_created DESC
</if>
</when>
<otherwise>
order by date_created DESC
</otherwise>
</choose>
<if test="limit != null">
LIMIT #{limit} OFFSET #{offset}
</if>
</select>
</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,37 @@
<if test="endTime != null">
AND date_created &lt;= DATE_ADD(#{endTime},INTERVAL 1 DAY)
</if>
order by date_created
LIMIT #{limit} OFFSET #{offset}
<choose>
<when test="sortByDate != null">
<if test="sortByDate.name() == 'ASC'">
order by date_created ASC
</if>
<if test="sortByDate.name() == 'DESC'">
order by date_created DESC
</if>
</when>
<when test="sortByDuration != null">
<if test="sortByDuration.name() == 'ASC'">
order by duration ASC, date_created DESC
</if>
<if test="sortByDuration.name() == 'DESC'">
order by duration DESC, date_created DESC
</if>
</when>
<when test="sortByCallSid != null">
<if test="sortByCallSid.name() == 'ASC'">
order by call_sid ASC, date_created DESC
</if>
<if test="sortByCallSid.name() == 'DESC'">
order by call_sid DESC, date_created DESC
</if>
</when>
<otherwise>
order by date_created DESC
</otherwise>
</choose>
<if test="limit != null">
LIMIT #{limit} OFFSET #{offset}
</if>
</select>
</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
-->
<mapper namespace="org.mobicents.servlet.sip.restcomm.dao.SmsMessagesDao">
<insert id="addSmsMessage" parameterType="map">
INSERT INTO restcomm_sms_messages (sid, date_created, date_updated, date_sent,
INSERT INTO restcomm_sms_messages (sid, date_created, date_updated, date_sent,
account_sid, sender, recipient, body, status, direction,
price, api_version, uri, status_callback, status_callback_method) VALUES (#{sid},
price, api_version, uri, status_callback, status_callback_method) VALUES (#{sid},
#{date_created}, #{date_updated}, #{date_sent}, #{account_sid}, #{sender}, #{recipient}, #{body},
#{status}, #{direction}, #{price}, #{api_version}, #{uri}, #{status_callback},
#{status_callback_method});
Expand Down Expand Up @@ -76,7 +76,7 @@
</if>
<!-- select * from "restcomm_sms_messages" where "start_time" >= '2013-08-23' order by "start_time" ; -->
<if test="startTime != null">
AND date_created &gt;= #{startTime}
AND date_created &gt;= #{startTime}
</if>
<if test="endTime != null">
AND date_created &lt;= DATE_ADD(#{endTime},INTERVAL 1 DAY)
Expand Down Expand Up @@ -112,6 +112,9 @@
<if test="sender != null">
AND sender like #{sender}
</if>
<if test="status != null">
AND status like #{status}
</if>
<if test="body != null">
AND body like '%'|| #{body} ||'%'
</if>
Expand All @@ -122,8 +125,70 @@
<if test="endTime != null">
AND date_created &lt;= DATE_ADD(#{endTime},INTERVAL 1 DAY)
</if>
order by date_created
LIMIT #{limit} OFFSET #{offset}
<choose>
<when test="sortByDate != null">
<if test="sortByDate.name() == 'ASC'">
order by date_created ASC
</if>
<if test="sortByDate.name() == 'DESC'">
order by date_created DESC
</if>
</when>
<when test="sortByFrom != null">
<if test="sortByFrom.name() == 'ASC'">
order by sender ASC, date_created DESC
</if>
<if test="sortByFrom.name() == 'DESC'">
order by sender DESC, date_created DESC
</if>
</when>
<when test="sortByTo != null">
<if test="sortByTo.name() == 'ASC'">
order by recipient ASC, date_created DESC
</if>
<if test="sortByTo.name() == 'DESC'">
order by recipient DESC, date_created DESC
</if>
</when>
<when test="sortByDirection != null">
<if test="sortByDirection.name() == 'ASC'">
order by direction ASC, date_created DESC
</if>
<if test="sortByDirection.name() == 'DESC'">
order by direction DESC, date_created DESC
</if>
</when>
<when test="sortByStatus != null">
<if test="sortByStatus.name() == 'ASC'">
order by status ASC, date_created DESC
</if>
<if test="sortByStatus.name() == 'DESC'">
order by status DESC, date_created DESC
</if>
</when>
<when test="sortByBody != null">
<if test="sortByBody.name() == 'ASC'">
order by body ASC, date_created DESC
</if>
<if test="sortByBody.name() == 'DESC'">
order by body DESC, date_created DESC
</if>
</when>
<when test="sortByPrice != null">
<if test="sortByPrice.name() == 'ASC'">
order by cast(price as unsigned) ASC, date_created DESC
</if>
<if test="sortByPrice.name() == 'DESC'">
order by cast(price as unsigned) DESC, date_created DESC
</if>
</when>
<otherwise>
order by date_created DESC
</otherwise>
</choose>
<if test="limit != null and offset != null">
LIMIT #{limit} OFFSET #{offset}
</if>
</select>

<select id="findBySmppMessageId" parameterType="map" resultType="hashmap">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,59 +122,59 @@
</where>
<choose>
<when test="sortByDate != null">
<if test="sortByDate.name() == 'ASCENDING'">
<if test="sortByDate.name() == 'ASC'">
order by "date_created" ASC
</if>
<if test="sortByDate.name() == 'DESCENDING'">
<if test="sortByDate.name() == 'DESC'">
order by "date_created" DESC
</if>
</when>
<when test="sortByFrom != null">
<if test="sortByFrom.name() == 'ASCENDING'">
order by "sender" ASC
<if test="sortByFrom.name() == 'ASC'">
order by "sender" ASC, "date_created" DESC
</if>
<if test="sortByFrom.name() == 'DESCENDING'">
order by "sender" DESC
<if test="sortByFrom.name() == 'DESC'">
order by "sender" DESC, "date_created" DESC
</if>
</when>
<when test="sortByTo != null">
<if test="sortByTo.name() == 'ASCENDING'">
order by "recipient" ASC
<if test="sortByTo.name() == 'ASC'">
order by "recipient" ASC, "date_created" DESC
</if>
<if test="sortByTo.name() == 'DESCENDING'">
order by "recipient" DESC
<if test="sortByTo.name() == 'DESC'">
order by "recipient" DESC, "date_created" DESC
</if>
</when>
<when test="sortByDirection != null">
<if test="sortByDirection.name() == 'ASCENDING'">
order by "direction" ASC
<if test="sortByDirection.name() == 'ASC'">
order by "direction" ASC, "date_created" DESC
</if>
<if test="sortByDirection.name() == 'DESCENDING'">
order by "direction" DESC
<if test="sortByDirection.name() == 'DESC'">
order by "direction" DESC, "date_created" DESC
</if>
</when>
<when test="sortByStatus != null">
<if test="sortByStatus.name() == 'ASCENDING'">
order by "status" ASC
<if test="sortByStatus.name() == 'ASC'">
order by "status" ASC, "date_created" DESC
</if>
<if test="sortByStatus.name() == 'DESCENDING'">
order by "status" DESC
<if test="sortByStatus.name() == 'DESC'">
order by "status" DESC, "date_created" DESC
</if>
</when>
<when test="sortByDuration != null">
<if test="sortByDuration.name() == 'ASCENDING'">
order by "duration" ASC
<if test="sortByDuration.name() == 'ASC'">
order by "duration" ASC, "date_created" DESC
</if>
<if test="sortByDuration.name() == 'DESCENDING'">
order by "duration" DESC
<if test="sortByDuration.name() == 'DESC'">
order by "duration" DESC, "date_created" DESC
</if>
</when>
<when test="sortByPrice != null">
<if test="sortByPrice.name() == 'ASCENDING'">
order by cast("price" as int) ASC
<if test="sortByPrice.name() == 'ASC'">
order by cast("price" as int) ASC, "date_created" DESC
</if>
<if test="sortByPrice.name() == 'DESCENDING'">
order by cast("price" as int) DESC
<if test="sortByPrice.name() == 'DESC'">
order by cast("price" as int) DESC, "date_created" DESC
</if>
</when>
<otherwise>
Expand Down
Loading