diff --git a/app/models/metric.rb b/app/models/metric.rb index 6426c5f8261..bec9825b07d 100644 --- a/app/models/metric.rb +++ b/app/models/metric.rb @@ -26,33 +26,6 @@ class Metric < ActiveRecord::Base } QUERY - REPO_QUERY = <<~QUERY - query { - repository(owner: "%s", name: "%s") { - ref(qualifiedName: "master") { - target { - ... on Commit { - id - history(%s since: "%s") { - edges { - node { - id author { - name email date - } - } - } - pageInfo { - endCursor - hasNextPage - } - } - } - } - } - } - } - QUERY - # Generate the GraphQL query text for a PULL REQUEST link. # # hyperlink_data - a hash containing the owner name, repository name, and pull request number. @@ -68,19 +41,4 @@ def self.pull_query(hyperlink_data) }) end - # Generate the GraphQL query text for a REPOSITORY link. - # - # hyperlink_data - a hash containing the owner name and repository name. - # date - the assignment start date, in the format "YYYY-MM-DD". - # after - a pointer provided by the Github API to where the last query left off. - # - # Returns a hash containing the query text. - def self.repo_query(hyperlink_data, date) - format(REPO_QUERY, { - owner_name: hyperlink_data["owner_name"], - repository_name: hyperlink_data["repository_name"], - start_date: date.iso8601(3), - after_clause: nil - }) - end end diff --git a/app/views/assignments/edit/_rubrics.html.erb b/app/views/assignments/edit/_rubrics.html.erb index 9802f11c179..c94fbf7a92c 100644 --- a/app/views/assignments/edit/_rubrics.html.erb +++ b/app/views/assignments/edit/_rubrics.html.erb @@ -19,7 +19,7 @@ if (round_no == null && duty_id == undefined) { html += ''; } else if (round_no == null && duty_id != undefined) { - // E2147 : Add name of duty infront of the questionnaire type to select for which duty the questionnaire is being selected + // E2147 : Add name of duty in front of the questionnaire type to select for which duty the questionnaire is being selected html += ''; } else if (round_no!=null && duty_id == undefined) { diff --git a/spec/models/assignment_spec.rb b/spec/models/assignment_spec.rb index 8f1d46d69f2..033df68b938 100644 --- a/spec/models/assignment_spec.rb +++ b/spec/models/assignment_spec.rb @@ -726,19 +726,5 @@ def generated_csv(t_assignment, t_options) end end end - describe '#uses_github?' do - - it 'does NOT use github' do - create(:assignment) - create(:assignment_team, name: 'team1', submitted_hyperlinks: ["https://expertiza.ncsu.edu/"]) - expect(assignment.uses_github?).to eq(false) - end - - it 'uses github' do - create(:assignment) - create(:assignment_team, name: 'team1', submitted_hyperlinks: ["https://www.github.com/anonymous/expertiza", "https://github.com/expertiza/expertiza/pull/1234"]) - expect(assignment.uses_github?).to eq(true) - end - end end diff --git a/spec/models/metric_spec.rb b/spec/models/metric_spec.rb index 245792b745b..ee8402320f2 100644 --- a/spec/models/metric_spec.rb +++ b/spec/models/metric_spec.rb @@ -1,136 +1,39 @@ describe Metric do describe 'pull_query' do - it 'constructs the query for the first page' do - query = { - query: "query { - repository(owner: \"expertiza\", name:\"expertiza\") { - pullRequest(number: 1228) { - number additions deletions changedFiles mergeable merged headRefOid - commits(first:100 ){ - totalCount - pageInfo{ - hasNextPage startCursor endCursor - } - edges{ - node{ - id commit{ - author{ - name email - } - additions deletions changedFiles committedDate - }}}}}}}" - } - hyperlink_data = {} - hyperlink_data["owner_name"] = "expertiza" - hyperlink_data["repository_name"] = "expertiza" - hyperlink_data["pull_request_number"] = "1228" - response = Metric.pull_query(hyperlink_data, nil) - expect(response).to eq(query) - end - - it 'constructs the query for additional pages after 100 commits' do - query = { - query: "query { - repository(owner: \"expertiza\", name:\"expertiza\") { - pullRequest(number: 1228) { - number additions deletions changedFiles mergeable merged headRefOid - commits(first:100 after:\"pointer\"){ - totalCount - pageInfo{ - hasNextPage startCursor endCursor - } - edges{ - node{ - id commit{ - author{ - name email - } - additions deletions changedFiles committedDate - }}}}}}}" - } - hyperlink_data = {} - hyperlink_data["owner_name"] = "expertiza" - hyperlink_data["repository_name"] = "expertiza" - hyperlink_data["pull_request_number"] = "1228" - after="pointer" # In production, this will be a github SHA1 hash - response = Metric.pull_query(hyperlink_data, after) - expect(response).to eq(query) - end - end - describe 'repo_query' do it 'constructs the query for the first page' do - date = DateTime.yesterday query = { query: "query { - repository(owner: \"expertiza\", name: \"expertiza\") { - ref(qualifiedName: \"master\") { - target { - ... on Commit { - id - history( since:\"#{date.to_time.iso8601.to_s[0..18]}\") { - edges { - node { - id author { - name email date - } - } - } - pageInfo { - endCursor - hasNextPage - } - } - } - } - } + repository(owner: \"expertiza\", name: \"expertiza\") { + pullRequest(number: 1228) { + number additions deletions changedFiles mergeable merged headRefOid + commits(first: 100 ) { + totalCount + pageInfo { + hasNextPage startCursor endCursor } - }" - } - hyperlink_data = {} - hyperlink_data["owner_name"] = "expertiza" - hyperlink_data["repository_name"] = "expertiza" - response = Metric.repo_query(hyperlink_data, date, nil) - expect(response).to eq(query) - end - - it 'constructs the query for additional pages after 100 commits' do - date = DateTime.yesterday - query = { - query: "query { - repository(owner: \"expertiza\", name: \"expertiza\") { - ref(qualifiedName: \"master\") { - target { - ... on Commit { - id - history(after:\"pointer\" since:\"#{date.to_time.iso8601.to_s[0..18]}\") { - edges { - node { - id author { - name email date - } - } - } - pageInfo { - endCursor - hasNextPage - } - } + edges { + node { + id commit { + author { + name email } + additions deletions changedFiles committedDate } } } - }" + } + } + } +}" } hyperlink_data = {} hyperlink_data["owner_name"] = "expertiza" hyperlink_data["repository_name"] = "expertiza" hyperlink_data["pull_request_number"] = "1228" - after="pointer" # In production, this will be a github SHA1 hash - response = Metric.repo_query(hyperlink_data, date, after) - expect(response).to eq(query) + response = Metric.pull_query(hyperlink_data) + expect(response.strip).to eq(query[:query]) end end - -end \ No newline at end of file +end