properly return "No comments" when there are no comments

This commit is contained in:
Jecket 2024-02-03 17:08:21 +01:00
parent 49d8c9d1a5
commit 5087d70bff
3 changed files with 12 additions and 0 deletions

View File

@ -38,6 +38,10 @@ CrystalGauntlet.endpoints["/getGJCommentHistory.php"] = ->(context : HTTP::Serve
amount = DATABASE.scalar("select count(*) from comments where user_id = ?", params["userID"].to_i).as(Int64)
if amount == 0
return "-2"
end
comments_str = [] of String
DATABASE.query("select comments.id, comment, comments.created_at, likes, level_id, users.username, users.icon_type, users.color1, users.color2, users.cube, users.ship, users.ball, users.ufo, users.wave, users.robot, users.spider, users.special from comments join users on users.id = user_id where user_id = ? order by comments.created_at desc limit #{comments_per_page} offset #{comment_offset}", params["userID"]) do |rs|

View File

@ -14,6 +14,10 @@ CrystalGauntlet.endpoints["/getGJComments21.php"] = ->(context : HTTP::Server::C
amount = DATABASE.scalar("select count(*) from comments where level_id = ?", level_id)
if amount == 0
return "-2"
end
comments_str = [] of String
users_str = [] of String
has_users_str = false

View File

@ -14,6 +14,10 @@ CrystalGauntlet.endpoints["/getGJAccountComments20.php"] = ->(context : HTTP::Se
amount = DATABASE.scalar("select count(*) from account_comments where account_id = ?", account_id)
if amount == 0
return "-2"
end
users_str = [] of String
DATABASE.query("select id, comment, created_at, likes from account_comments where account_id = ? order by created_at desc limit #{comments_per_page} offset #{comment_offset}", account_id) do |rs|