Skip to content

Commit

Permalink
Create listing of affected users by DANA by postal code
Browse files Browse the repository at this point in the history
  • Loading branch information
iranzo committed Nov 6, 2024
1 parent 4c6f358 commit 3c00ced
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 0 deletions.
134 changes: 134 additions & 0 deletions 3-sociosdana.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#!/usr/bin/env python


import common

codigos_postales = [
46970,
46470,
46687,
46369,
46290,
46250,
46960,
46910,
46197,
46680,
46230,
46440,
46910,
46450,
46469,
46689,
46117,
46165,
46360,
46330,
46240,
46196,
46470,
46315,
46612,
46400,
46350,
46380,
46370,
46614,
46687,
46314,
46388,
46610,
46160,
46393,
46613,
46910,
46195,
46368,
46940,
46470,
46920,
46192,
46193,
46200,
46980,
46164,
46210,
46220,
46688,
46930,
46194,
46340,
46190,
46417,
46910,
46392,
46460,
46320,
46430,
46168,
46410,
46760,
46900,
46389,
46300,
46017,
46026,
46012,
46012,
46012,
46012,
46950,
46367,
]


print("Loading file from disk")

users = common.rewadjson(filename="socios")


affected = []
telegramids = []

for user in users:
if (
"estat" in user
and user["estat"] == "COLESTVAL"
and "estatColegiat" in user
and user["estatColegiat"]["nom"] == "ESTALTA"
):
try:
cp = int(user["persona"]["adreces"][0]["municipi"]["codipostal"])
except:
cp = 0

if cp in codigos_postales:
affected.append(user["idColegiat"])

if isinstance(user["campsDinamics"], dict):
for field in common.telegramfields:
if field in user["campsDinamics"]:
try:
userid = user["campsDinamics"][field]
except:
userid = False

if userid:
if (
"estat" in user
and user["estat"] == "COLESTVAL"
and "estatColegiat" in user
and user["estatColegiat"]["nom"] == "ESTALTA"
):
# Always store if ID is valid or not

telegramids.append(userid)


affected = sorted(set(affected))
print("########## SOCIOS #######")
print(affected)
print(len(affected))
print("########## IDS Telegram #######")
print(sorted(set(telegramids)))
print(len(telegramids))
6 changes: 6 additions & 0 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,9 @@ def rewadjson(filename):
with open("data/%s.json" % filename, "r", encoding="utf-8") as f:
mydata = json.load(f)
return mydata


# Telegramfields
tutor1 = "0_13_20231012041710"
tutor2 = "0_14_20231012045321"
telegramfields = [tutor1, tutor2]

0 comments on commit 3c00ced

Please sign in to comment.