From 7f1343c7591c5613f6e0ef02ac0e48b11dc27c45 Mon Sep 17 00:00:00 2001 From: a-ill Date: Wed, 2 Aug 2023 18:15:50 +0300 Subject: [PATCH] Fixed error if no requests --- .../app/resources/groups/GroupsController.jl | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Server/app/resources/groups/GroupsController.jl b/Server/app/resources/groups/GroupsController.jl index 9135e7e..605539e 100644 --- a/Server/app/resources/groups/GroupsController.jl +++ b/Server/app/resources/groups/GroupsController.jl @@ -248,15 +248,17 @@ end function add_verified_groups() groups_create_requests_verified = select_from_table("groups_requests" => ["*"], where_data = ["group_id" => nothing, "status" => 1]) data = Dict(zip(names(groups_create_requests_verified),groups_create_requests_verified[end,:])) - user_id = data["user_id"] - delete!(data,"group_id") - delete!(data,"user_id") - delete!(data,"id") - delete!(data,"status") - group_id = insert_into_table("groups",data, "RETURNING id")[1,1] - dict_users_groups = Dict("user_id" => user_id, "group_id" => group_id) - insert_into_table("users_groups",dict_users_groups) - delete_from_table("groups_requests",["user_id" => user_id]) + if size(data,1)!=0 + user_id = data["user_id"] + delete!(data,"group_id") + delete!(data,"user_id") + delete!(data,"id") + delete!(data,"status") + group_id = insert_into_table("groups",data, "RETURNING id")[1,1] + dict_users_groups = Dict("user_id" => user_id, "group_id" => group_id) + insert_into_table("users_groups",dict_users_groups) + delete_from_table("groups_requests",["user_id" => user_id]) + end compile("groups") end