Skip to content

Commit

Permalink
fixing code
Browse files Browse the repository at this point in the history
  • Loading branch information
antgonza committed Apr 3, 2017
1 parent 3ff8a15 commit 88c1358
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions qiita_db/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,17 +621,18 @@ def visibility(self, value):
with qdb.sql_connection.TRN:
# In order to correctly propagate the visibility we need to find
# the root of this artifact and then propagate to all the artifacts
root = self.artifact
while root.parents:
# [0] we only support one parent
root = root.parents[0]
sql = "SELECT * FROM qiita.find_artifact_roots(%s)"
qdb.sql_connection.TRN.add(sql, [self.id])
root_id = qdb.sql_connection.TRN.execute_fetchlast()
root = qdb.artifact.Artifact(root_id)
# these are the ids of all the children from the root
ids = [a.id for a in root.descendants.nodes()]

sql = """UPDATE qiita.artifact
SET visibility_id = %s
WHERE artifact_id IN %s"""
vis_id = qdb.util.convert_to_id(value, "visibility")
qdb.sql_connection.TRN.add(sql, [vis_id, tuple(ids)], many=True)
qdb.sql_connection.TRN.add(sql, [vis_id, tuple(ids)])
qdb.sql_connection.TRN.execute()

@property
Expand Down

0 comments on commit 88c1358

Please sign in to comment.