Skip to content

Commit

Permalink
redo giant community list case sql
Browse files Browse the repository at this point in the history
  • Loading branch information
mjsalerno committed Dec 23, 2024
1 parent d34567b commit fd053eb
Showing 1 changed file with 39 additions and 16 deletions.
55 changes: 39 additions & 16 deletions Arrowgene.Ddon.Database/Sql/Core/DdonSqlDbContactList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,45 @@ public abstract partial class DdonSqlDb<TCon, TCom, TReader> : SqlDb<TCon, TCom,

private static readonly string SqlUpdateContactByCharIds = $"UPDATE \"{ContactListTableName}\" SET \"status\"=@status, \"type\"=@type, \"requester_favorite\"=@requester_favorite, \"requested_favorite\"=@requested_favorite WHERE \"requester_character_id\"=@requester_character_id and \"requested_character_id\"=@requested_character_id;";

private static readonly string SqlSelectFullContactsByCharacterId = @"SELECT ""ddon_contact_list"".*,
""ddon_character"".""first_name"", ""ddon_character"".""last_name"",
""ddon_character_job_data"".""job"", ""ddon_character_job_data"".""lv"",
""ddon_character_matching_profile"".""comment"",
CASE WHEN CASE WHEN ""ddon_contact_list"".""requester_character_id"" = @character_id THEN ""ddon_contact_list"".""requested_character_id"" ELSE ""ddon_contact_list"".""requester_character_id"" END NOT IN (SELECT ""character_id"" FROM ""ddon_clan_membership"") THEN """"
ELSE (SELECT ""ddon_clan_param"".""name"" as ""clan_name"" FROM ""ddon_clan_param"" INNER JOIN ""ddon_clan_membership"" ON ""ddon_clan_membership"".""clan_id"" = ""ddon_clan_param"".""clan_id"" WHERE ""ddon_clan_membership"".""character_id"" = CASE WHEN ""ddon_contact_list"".""requester_character_id"" = @character_id THEN ""ddon_contact_list"".""requested_character_id"" ELSE ""ddon_contact_list"".""requester_character_id"" END)
END AS ""clan_name"",
CASE WHEN ""ddon_contact_list"".""requester_character_id"" = @character_id THEN ""ddon_contact_list"".""requested_character_id""
ELSE ""ddon_contact_list"".""requester_character_id""
END AS ""other_id""
FROM ""ddon_contact_list""
INNER JOIN ""ddon_character"" ON ""ddon_character"".""character_id"" = ""other_id""
INNER JOIN ""ddon_character_common"" ON ""ddon_character_common"".""character_common_id"" = ""ddon_character"".""character_common_id""
INNER JOIN ""ddon_character_job_data"" ON ""ddon_character_job_data"".""character_common_id"" = ""ddon_character"".""character_common_id"" AND ""ddon_character_job_data"".""job"" = ""ddon_character_common"".""job""
INNER JOIN ""ddon_character_matching_profile"" ON ""ddon_character_matching_profile"".""character_id"" = ""other_id""
WHERE ""requested_character_id"" = @character_id OR ""requester_character_id"" = @character_id;";
private static readonly string SqlSelectFullContactsByCharacterId = @"SELECT
cl.*,
c.first_name,
c.last_name,
j.job,
j.lv,
mp.comment,
CASE
WHEN cl.requester_character_id = @character_id THEN
(SELECT cp.name FROM ddon_clan_param cp
INNER JOIN ddon_clan_membership cm ON cm.clan_id = cp.clan_id
WHERE cm.character_id = cl.requested_character_id)
ELSE
(SELECT cp.name FROM ddon_clan_param cp
INNER JOIN ddon_clan_membership cm ON cm.clan_id = cp.clan_id
WHERE cm.character_id = cl.requester_character_id)
END AS clan_name,
CASE
WHEN cl.requester_character_id = @character_id THEN
cl.requested_character_id
ELSE
cl.requester_character_id
END AS other_id
FROM
ddon_contact_list cl
INNER JOIN ddon_character c ON c.character_id =
CASE
WHEN cl.requester_character_id = @character_id THEN cl.requested_character_id
ELSE cl.requester_character_id
END
INNER JOIN ddon_character_common cc ON cc.character_common_id = c.character_common_id
INNER JOIN ddon_character_job_data j ON j.character_common_id = cc.character_common_id AND j.job = cc.job
INNER JOIN ddon_character_matching_profile mp ON mp.character_id =
CASE
WHEN cl.requester_character_id = @character_id THEN cl.requested_character_id
ELSE cl.requester_character_id
END
WHERE
cl.requested_character_id = @character_id OR cl.requester_character_id = @character_id;";

public int InsertContact(uint requestingCharacterId, uint requestedCharacterId, ContactListStatus status, ContactListType type, bool requesterFavorite, bool requestedFavorite)
{
Expand Down

0 comments on commit fd053eb

Please sign in to comment.