aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2012-11-04 22:54:16 +0700
committerGravatar Ugnich Anton2012-11-04 22:54:16 +0700
commitac4323e6d01264e9830f952ceacb192795845455 (patch)
treebc9288cdf23b2b6ff9caa05ee99bf4d5e6ea26a9 /src
parent83a82852057e48ef595057987b057496d5b562c6 (diff)
getMessage improvement
Diffstat (limited to 'src')
-rw-r--r--src/com/juick/server/MessagesQueries.java30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/com/juick/server/MessagesQueries.java b/src/com/juick/server/MessagesQueries.java
index f7625a19..7b4b800d 100644
--- a/src/com/juick/server/MessagesQueries.java
+++ b/src/com/juick/server/MessagesQueries.java
@@ -100,7 +100,7 @@ public class MessagesQueries {
PreparedStatement stmt = null;
ResultSet rs = null;
try {
- stmt = sql.prepareStatement("SELECT messages.user_id,users.nick,messages.ts,messages.readonly,messages.attach,messages.place_id,messages.lat,messages.lon FROM messages INNER JOIN users ON messages.user_id=users.id WHERE messages.message_id=?");
+ stmt = sql.prepareStatement("SELECT messages.user_id,users.nick,TIMESTAMPDIFF(MINUTE,messages.ts,NOW()),messages.ts,messages.readonly,messages.privacy,messages.replies,messages.attach,messages.place_id,messages.lat,messages.lon FROM messages INNER JOIN users ON messages.user_id=users.id WHERE messages.message_id=?");
stmt.setInt(1, mid);
rs = stmt.executeQuery();
if (rs.first()) {
@@ -109,16 +109,19 @@ public class MessagesQueries {
msg.User = new com.juick.User();
msg.User.UID = rs.getInt(1);
msg.User.UName = rs.getString(2);
- msg.TimestampString = rs.getString(3);
- msg.ReadOnly = rs.getBoolean(4);
- msg.AttachmentType = rs.getString(5);
- if (rs.getInt(6) > 0) {
- msg.Place = PlacesQueries.getPlace(sql, rs.getInt(6));
+ msg.TimeAgo = rs.getInt(3);
+ msg.TimestampString = rs.getString(4);
+ msg.ReadOnly = rs.getBoolean(5);
+ msg.Privacy = rs.getInt(6);
+ msg.Replies = rs.getInt(7);
+ msg.AttachmentType = rs.getString(8);
+ if (rs.getInt(9) > 0) {
+ msg.Place = PlacesQueries.getPlace(sql, rs.getInt(9));
}
- if (rs.getDouble(7) != 0) {
+ if (rs.getDouble(10) != 0) {
msg.Place = new com.juick.Place();
- msg.Place.lat = rs.getDouble(7);
- msg.Place.lon = rs.getDouble(8);
+ msg.Place.lat = rs.getDouble(10);
+ msg.Place.lon = rs.getDouble(11);
}
}
} catch (SQLException e) {
@@ -132,12 +135,15 @@ public class MessagesQueries {
}
try {
- stmt = sql.prepareStatement("SELECT messages_txt.tags,messages_txt.txt FROM messages_txt WHERE message_id=?");
+ stmt = sql.prepareStatement("SELECT tags,repliesby,txt FROM messages_txt WHERE message_id=?");
stmt.setInt(1, mid);
rs = stmt.executeQuery();
if (rs.first()) {
- msg.parseTags(rs.getString(1));
- msg.Text = rs.getString(2);
+ if (rs.getString(1) != null) {
+ msg.parseTags(rs.getString(1));
+ }
+ msg.RepliesBy = rs.getString(2);
+ msg.Text = rs.getString(3);
}
} catch (SQLException e) {
System.err.println(e);