Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions mapknowledge/competency/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ def __delete_source_from_tables(self, cursor, source: KnowledgeSource):
cursor.execute('DELETE FROM path_phenotypes WHERE source_id=%s', (source_id, ))
cursor.execute('DELETE FROM path_properties WHERE source_id=%s', (source_id, ))
cursor.execute('DELETE FROM path_node_mappings WHERE source_id=%s', (source_id, ))
cursor.execute('DELETE FROM path_node_mappings WHERE sckan_id=%s', (source_id, ))
cursor.execute('DELETE FROM path_nodes WHERE source_id=%s', (source_id, ))
cursor.execute('DELETE FROM feature_types WHERE source_id=%s', (source_id, ))
cursor.execute('DELETE FROM feature_expert_consultants WHERE source_id=%s', (source_id, ))
cursor.execute('DELETE FROM feature_terms WHERE source_id=%s', (source_id, ))

def __update_anatomical_types(self, cursor):
Expand Down Expand Up @@ -238,6 +240,16 @@ def __update_connectivity(self, cursor, knowledge: KnowledgeList, show_progress=
cursor.executemany('INSERT INTO path_node_mappings (source_id, path_id, node_id, sckan_id, sckan_node_id) VALUES (%s, %s, %s, %s, %s) ON CONFLICT DO NOTHING',
node_mappings)

# Expert consultants
expert_consultants = record.get('expert-consultants', [])
cursor.executemany('INSERT INTO expert_consultants (expert_id) VALUES (%s) ON CONFLICT DO NOTHING',
((expert,) for expert in expert_consultants))

# Path expert consultants
with cursor.copy("COPY feature_expert_consultants (source_id, term_id, expert_id) FROM STDIN") as copy:
for expert in expert_consultants:
copy.write_row((source_id, path_id, expert))

if progress_bar is not None:
progress_bar.update(1)
if progress_bar is not None:
Expand Down