-
Notifications
You must be signed in to change notification settings - Fork 0
/
mailxmatch.py
94 lines (81 loc) · 3.05 KB
/
mailxmatch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
"""
Build different lists of people registered in pretalx and/or google
spread sheet. The script makes a crossmatch between both registries
and displays the following lists.
- People in Google spreadsheet not registered in ADASS
- Main authors in pretalx not registered in ADASS
- Main authors with contributions confirmed in pretalx not registered in ADASS
- Main authors with contributions confirmed in pretalx registered in ADASS
"""
import psycopg2
from sshtunnel import SSHTunnelForwarder
import pandas as pd
import gspread
PASSWD = "*****"
KEYFILE = "/users/jer/.ssh/id_rsa"
GOOGLE_DOC = "*****"
# create an ssh tunnel
tunnel = SSHTunnelForwarder(
("www.adass2020.es", 22),
ssh_username="root",
ssh_pkey=KEYFILE,
ssh_private_key_password=PASSWD,
remote_bind_address=("localhost", 5432),
local_bind_address=("localhost", 6543),
)
# start the tunnel
tunnel.start()
# create a database connection
conn = psycopg2.connect(database="pretalx", user="pretalx", host=tunnel.local_bind_host, port=tunnel.local_bind_port,)
sql = """
SELECT
submission_submission.title, submission_submission.state, submission_submission.paper_id, person_user.email
FROM
submission_submission,
person_user
WHERE
submission_submission.main_author_id=person_user.id
AND submission_submission.state not in ('deleted', 'withdrawn')
ORDER BY email;
"""
postgredf = pd.read_sql_query(sql, conn)
conn.close()
# stop the tunnel
tunnel.stop()
# open google spreadsheet
gc = gspread.service_account()
wks = gc.open('ADASS XXX Registrations').sheet1
gdf = pd.DataFrame(wks.get_all_records())[1:]
invited = gdf[gdf["INVITED"] == "Yes"]
not_invited = gdf[gdf["INVITED"] == ""]
not_registered = not_invited[not_invited["Amount"] == 0]
payed = not_invited[not_invited["Amount"] != 0]
registered = pd.concat([invited, payed])
print("-------------------------------------------")
print("People in Google spreadsheet not registered")
print("-------------------------------------------")
print(not_registered["Email"])
i = 1
print("---------------------------")
print("Main authors not registered")
print("---------------------------")
for idx, row in postgredf.iterrows():
if registered[registered["Email"] == row["email"]].empty:
print(f"{i}; {row['email']}; {row['title']}")
i += 1
i = 1
print("--------------------------------------------------------")
print("Main authors not registered with contributions confirmed")
print("--------------------------------------------------------")
for idx, row in postgredf.iterrows():
if registered[registered["Email"] == row["email"]].empty and row["state"] == "confirmed":
print(f"{i}; {row['email']}; {row['title']}")
i += 1
i = 1
print("----------------------------------------------------")
print("Main authors registered with contributions confirmed")
print("----------------------------------------------------")
for idx, row in postgredf.iterrows():
if not registered[registered["Email"] == row["email"]].empty and row["state"] == "confirmed":
print(f"{i}; {row['email']}; {row['paper_id']}; {row['title']}")
i += 1