Moved all entries to db

This commit is contained in:
a-ill
2023-07-28 17:49:29 +03:00
parent c0f60f5e68
commit 5bc0cb8c25
112 changed files with 3887 additions and 895 deletions

View File

@@ -18,14 +18,14 @@ function table_to_json(name,df)
end
end
function compile_groups()
df = select_from_table(["groups" => ["*"]])
table_to_json("groups",df)
function compile(name)
df = select_from_table([name => ["*"]])
table_to_json(name,df)
end
function move_requests()
df_requests = select_from_table(["groups_requests" => ["*"]], where_data=["verified" => true, "added" => false])
df = select_from_table(["groups" => ["*"]])
function move_requests(name)
df_requests = select_from_table(["$(name)_requests" => ["*"]], where_data=["verified" => true, "added" => false])
df = select_from_table([name => ["*"]])
latitudes = df.latitude
longitudes = df.longitude
for df_row in eachrow(df_requests)
@@ -35,11 +35,11 @@ function move_requests()
row_found = df[ind_id_given,Not(:id)]
dict = Dict(zip(names(row_found),values(row_found)))
dict["members"] += 1
update_table("groups",dict, where_data=["id" => id])
update_table(name,dict, where_data=["id" => id])
else
id = df_row.id
dict_update = Dict("added" => true)
update_table("groups_requests",dict_update, where_data=["id" => id])
update_table("$(name)_requests",dict_update, where_data=["id" => id])
df_row_to_add = df_row[Not(:id_given)]
df_row_to_add = df_row_to_add[Not(:verified)]
@@ -47,11 +47,20 @@ function move_requests()
df_row_to_add = df_row_to_add[Not(:id)]
dict = Dict(zip(names(df_row_to_add),values(df_row_to_add)))
dict["members"] = 1
insert_into_table("groups",dict)
insert_into_table(name,dict)
end
end
end
move_requests()
compile_groups()
move_requests("groups")
compile("groups")
move_requests("communes")
compile("communes")
compile("cooperatives")
compile("parties")
compile("partners")