def pullRequestsPerProject(project_id, devpostId): db.query('select pr.id from pull_requests pr where pr.base_repo_id = ' + project_id + ';') r = db.store_result() pull_requests = r.fetch_row(maxrows=0) for pullrequest in pull_requests: pull_request_id = pullrequest[0] db.query("select pr.id, ph.created_at, ph.actor_id, pc.commit_id, c.sha " \ "from pull_requests pr, pull_request_history ph, pull_request_commits pc, commits c " \ "where pr.id = " + pull_request_id + " and ph.pull_request_id = pr.id and pc.pull_request_id = pr.id and c.id = pc.commit_id;") r = db.store_result() print("Pull request id found") pr_stuff = r.fetch_row(maxrows=0) for pr in pr_stuff: db.query('select u.login from users u where u.id = ' + pr[2] + ';') r = db.store_result() authorLogin = r.fetch_row(maxrows=0)[0][0].decode("utf-8") pr_rows.append([ devpostId, str(pullrequest[0]), pr[1], authorLogin, pr[4].decode("utf-8") ])
def commitsPerDays(commitsList, hackathonendDate, devPostId): hackathonEndDateParts = hackathonendDate.split("-") hackathonEndDate = datetime.date(int(hackathonEndDateParts[0]), int(hackathonEndDateParts[1]), int(hackathonEndDateParts[2])) parsedCommits = [] for commit in commitsList: commitParts = commit[0].split(" ")[0].split("-") fullDate = datetime.date(int(commitParts[0]), int(commitParts[1]), int(commitParts[2])) originalDate = commit[0] parsedCommits.append([ fullDate, commit[1], commit[2], commit[3], commit[5], originalDate ]) for i in range(1, 271): hackathonEndDate += datetime.timedelta(days=1) commit_id = str(devPostId) for parsedCommit in parsedCommits: commentIds = "" if hackathonEndDate == parsedCommit[0]: authorID = parsedCommit[2] committerID = parsedCommit[3] db.query( 'select cc.comment_id from commit_comments cc where cc.commit_id = ' + parsedCommit[4] + ';') r = db.store_result() comment_ids = r.fetch_row(maxrows=0) db.query('select u.login from users u where u.id = ' + authorID + ';') r = db.store_result() authorLogin = r.fetch_row(maxrows=0)[0][0].decode("utf-8") db.query('select u.login from users u where u.id = ' + committerID + ';') r = db.store_result() committerLogin = r.fetch_row(maxrows=0)[0][0].decode("utf-8") for commentId in comment_ids: commentIds += str(commentId[0]) + "&" commit_rows.append([ str(commit_id), parsedCommit[1].decode("utf-8"), i, parsedCommit[5], authorLogin, committerLogin, commentIds ])
devpost_id = str(row[0]) project_technologies = str(row[2]) project_participants = str(row[4]) print("ROW: " + str(line_count)) if github_url and ("github.com" in github_url or "github.io" in github_url): if "github.io" in github_url: github_url = fixGithubIoLink(github_url) (userName, project_name) = projectNameFromGithubURL(github_url) db.query('select u.id from users u where u.login = "******";') r = db.store_result() userId = r.fetch_row(maxrows=0) user_id = userId[0][0] ## GHTORRENT USERS.ID query = 'select c.created_at, c.sha, c.author_id, c.committer_id, p.id, c.id, p.forked_from from commits c, projects p where p.owner_id = ' + \ user_id + ' and p.name = "' + project_name.strip() + '" and c.project_id = p.id;' db.query(query) r = db.store_result() commits = r.fetch_row(maxrows=0) if len(commits) > 0: if isAfterHackathon(commits, hackathon_end_date): WORK_AFTER_HACKATHON_GITHUB += 1 proj_id = str(commits[0][4]) forked_from = str(commits[0][6])
def idk(): mysqldb.query("SELECT * FROM test:") result = mysqldb.store_result() result = result.fetch_row(maxrows=0)