From c227a71e03769f223dc3a16a5972d057233ad54f Mon Sep 17 00:00:00 2001 From: pingpingy1 Date: Tue, 28 Nov 2023 21:35:07 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20=EB=B9=84=EB=A1=80=EB=8C=80=ED=91=9C=20?= =?UTF-8?q?=EA=B5=AD=ED=9A=8C=EC=9D=98=EC=9B=90=EA=B9=8C=EC=A7=80=20?= =?UTF-8?q?=ED=95=A8=EA=BB=98=20=EA=B3=84=EC=82=B0=EC=97=90=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- analysis/diversity_db.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/analysis/diversity_db.py b/analysis/diversity_db.py index 31454bf..f6e67c8 100644 --- a/analysis/diversity_db.py +++ b/analysis/diversity_db.py @@ -277,9 +277,12 @@ def save_to_mongo_national(factor: str, stair=0, opts=True) -> None: data = [ councilor[factor_field[factor]] for councilor in client["council"]["national_councilor"].find() + ] + [ + councilor[factor_field[factor]] + for councilor in client["council"]["national_councilor_global"].find() ] - # print(f"{metroId} {factor}") - # print(data) + print(f"National {factor}") + print(data) client["stats"].get_collection("diversity_index").update_one( {"national": True}, {"$set": {f"{factor}DiversityIndex": gini_simpson(data, stair, opts)}}, @@ -348,17 +351,17 @@ def calculate_age_diversity_rank_history_national() -> None: def main(): - for localId in range(1, 227): - save_to_mongo_local(localId, "age", stair=10) - save_to_mongo_local(localId, "gender") - save_to_mongo_local(localId, "party") - calculate_rank_local("age") - calculate_rank_local("gender") - calculate_rank_local("party") - calculate_age_diversity_rank_history_local() + # for localId in range(1, 227): + # save_to_mongo_local(localId, "age", stair=10) + # save_to_mongo_local(localId, "gender") + # save_to_mongo_local(localId, "party") + # calculate_rank_local("age") + # calculate_rank_local("gender") + # calculate_rank_local("party") + # calculate_age_diversity_rank_history_local() for metroId in range(1, 18): - if metroId in [8, 17]: + if metroId in [17]: continue save_to_mongo_metro(metroId, "age", stair=10) save_to_mongo_metro(metroId, "gender") @@ -368,10 +371,10 @@ def main(): calculate_rank_metro("party") calculate_age_diversity_rank_history_metro() - save_to_mongo_national("age", stair=10) - save_to_mongo_national("gender") - save_to_mongo_national("party") - calculate_age_diversity_rank_history_national() + # save_to_mongo_national("age", stair=10) + # save_to_mongo_national("gender") + # save_to_mongo_national("party") + # calculate_age_diversity_rank_history_national() if __name__ == "__main__":