3bf5f2de89807642dcd1e030e45226ff3944779b,common.py,,get_filename,#Any#Any#,20
Before Change
def get_filename(db, submission_id):
submission = db.submissions.find_one({"_id": ObjectId(submission_id)})
fname = submission.get("filename", None)
user = submission.get("username", None)
if fname and user:
return "{}/{}".format(user, fname), fname
After Change
def get_filename(postgres_db, submission_id):
query = "SELECT filename, user_id FROM submissions WHERE id = "{}"".format(submission_id)
cursor = postgres_db.cursor()
cursor.execute(query)
results = cursor.fetchone()
filename = results[0]
user_id = results[1]
query = "SELECT username FROM users WHERE id = "{}"".format(user_id)
cursor.execute(query)
username = cursor.fetchone()[0]
cursor.close()
return "{}/{}".format(username, filename), filename
def download_submission(postgres_db, submission_id):
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 10
Instances
Project Name: numerai/submission-criteria
Commit Name: 3bf5f2de89807642dcd1e030e45226ff3944779b
Time: 2017-11-10
Author: xander@numer.ai
File Name: common.py
Class Name:
Method Name: get_filename
Project Name: numerai/submission-criteria
Commit Name: 3bf5f2de89807642dcd1e030e45226ff3944779b
Time: 2017-11-10
Author: xander@numer.ai
File Name: common.py
Class Name:
Method Name: get_filename
Project Name: numerai/submission-criteria
Commit Name: 3bf5f2de89807642dcd1e030e45226ff3944779b
Time: 2017-11-10
Author: xander@numer.ai
File Name: originality.py
Class Name:
Method Name: submission_originality
Project Name: numerai/submission-criteria
Commit Name: 3bf5f2de89807642dcd1e030e45226ff3944779b
Time: 2017-11-10
Author: xander@numer.ai
File Name: database_manager.py
Class Name: DatabaseManager
Method Name: get_date_created