Skip to content

Commit 3e43126

Browse files
authored
Merge pull request #177 from mapswipe/dev
fix update when there are no project
2 parents db9b844 + 8da2dba commit 3e43126

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

mapswipe_workers/mapswipe_workers/firebase_to_postgres/update_data.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,18 @@ def update_project_data(project_ids=None):
115115
projects_ref = fb_db.reference('v2/projects/')
116116
projects = projects_ref.get()
117117

118-
for project_id, project in projects.items():
119-
query_update_project = '''
120-
UPDATE projects
121-
SET status=%s
122-
WHERE project_id=%s;
123-
'''
124-
# TODO: Is there need for fallback to ''
125-
# if project.status is not existent
126-
data_update_project = [project.get('status', ''), project_id]
127-
pg_db.query(query_update_project, data_update_project)
128-
logger.info(f"updated status for project {project_id} in postgres")
118+
if projects:
119+
for project_id, project in projects.items():
120+
query_update_project = '''
121+
UPDATE projects
122+
SET status=%s
123+
WHERE project_id=%s;
124+
'''
125+
# TODO: Is there need for fallback to ''
126+
# if project.status is not existent
127+
data_update_project = [project.get('status', ''), project_id]
128+
pg_db.query(query_update_project, data_update_project)
129+
logger.info(f"updated status for project {project_id} in postgres")
129130

130131
del(pg_db)
131132

test_config.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ def test_nginx_config():
151151
assert 'SERVER_NAME' in env_variables, \
152152
f"you didn't set a SERVER_NAME in {file_path}"
153153

154+
for line in env_variables.split('\n'):
155+
if len(line) > 0:
156+
variable_name = line.split('=')[0]
157+
variable_value = line.split('=')[1].strip('"')
158+
if variable_name == 'SERVER_NAME':
159+
server_name = variable_value
160+
154161
file_path = 'nginx/nginx.conf'
155162
assert os.path.isfile(file_path), \
156163
f"you didn't set up config file: {file_path}"
@@ -161,9 +168,6 @@ def test_nginx_config():
161168
assert 'server_name' in nginx_config, \
162169
f"you didn't set server_name in: {file_path}"
163170

164-
# TODO: get server name from nginx config file or .env
165-
server_name = 'dev.mapswipe.org'
166-
167171
file_path = f'/etc/letsencrypt/live/{server_name}/fullchain.pem'
168172
assert os.path.isfile(file_path), \
169173
f"you didn't set up ssl certificate: {file_path}"

0 commit comments

Comments
 (0)