Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
Merge branch 'development' of https://github.com/CDCgov/SDP-Vocabular…
Browse files Browse the repository at this point in the history
…y-Service into development
  • Loading branch information
cssandlin committed Jan 4, 2019
2 parents 5da5f69 + fef3017 commit 90b45a1
Show file tree
Hide file tree
Showing 15 changed files with 182 additions and 49 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require:
- rubocop/formatter/checkstyle_formatter
inherit_from: .rubocop_todo.yml
AllCops:
TargetRubyVersion: 2.2
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ gem 'axlsx_rails'
group :development, :test do
gem 'fakeweb', '~> 1.3'
gem 'rubocop', '~> 0.49.0', require: false
gem 'rubocop-checkstyle_formatter', require: false
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'axe-matchers'
gem 'byebug'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ GEM
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
rubocop-checkstyle_formatter (0.4.0)
rubocop (>= 0.35.1)
ruby-graphviz (1.2.3)
ruby-ole (1.2.12.1)
ruby-progressbar (1.9.0)
Expand Down Expand Up @@ -513,6 +515,7 @@ DEPENDENCIES
roo (~> 2.4.0)
roo-xls (~> 1.0.0)
rubocop (~> 0.49.0)
rubocop-checkstyle_formatter
scss_lint
selenium-webdriver
simplecov
Expand Down
58 changes: 53 additions & 5 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#!/usr/bin/env groovy
pipeline {
agent none
agent { label 'vocab-ruby' }

options {
timeout(time: 120, unit: 'MINUTES')
}

stages {
stage('Run Tests') {
agent { label 'vocab-ruby' }

steps {
updateSlack('#FFFF00', 'Started tests')

Expand Down Expand Up @@ -107,9 +105,19 @@ pipeline {
}
}

stage('Build for Dev Env') {
agent any
stage('Publish Results') {
steps {
publishBrakeman 'reports/brakeman.html'
cucumber 'reports/cucumber.json'
checkstyle canComputeNew: false, defaultEncoding: '', healthy: '',
pattern: 'reports/rubocop-checkstyle-result.xml', unHealthy: ''
publishHTML([allowMissing: false, alwaysLinkToLastBuild: true, keepAll: false,
reportDir: 'reports/rubocop', reportFiles: 'index.html', reportName: 'RuboCop Report',
reportTitles: ''])
}
}

stage('Build for Dev Env') {
when {
branch 'development'
}
Expand All @@ -132,6 +140,46 @@ pipeline {
}
}
}

stage('Scan Image') {
agent { label 'docker' }
when {
branch 'development'
}

steps {
echo "Pulling SDP-V container image for scanning..."
sh 'set +x; docker -H localhost:2375 login -u serviceaccount -p $(oc whoami -t) docker-registry.default.svc.cluster.local:5000'
sh 'docker -H localhost:2375 pull docker-registry.default.svc.cluster.local:5000/sdp/vocabulary:latest'

echo "Scanning image with Twistlock..."
twistlockScan ca: '',
cert: '',
compliancePolicy: 'critical',
dockerAddress: 'tcp://localhost:2375',
gracePeriodDays: 7,
ignoreImageBuildTime: true,
repository: '',
image: 'docker-registry.default.svc.cluster.local:5000/sdp/vocabulary:latest',
tag: '',
key: '',
logLevel: 'true',
policy: 'critical',
requirePackageUpdate: true,
timeout: 10

echo "Publishing results..."
twistlockPublish ca: '',
cert: '',
dockerAddress: 'tcp://localhost:2375',
gracePeriodDays: 7,
ignoreImageBuildTime: true,
image: 'docker-registry.default.svc.cluster.local:5000/sdp/vocabulary:latest',
key: '',
logLevel: 'true',
timeout: 10
}
}
}
}

Expand Down
11 changes: 10 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ Rails.application.load_tasks

if Rails.env != 'production'
require 'rubocop/rake_task'
RuboCop::RakeTask.new
RuboCop::RakeTask.new(:rubocop) do |t|
t.options = ['--format',
'RuboCop::Formatter::CheckstyleFormatter',
'-o',
'reports/rubocop-checkstyle-result.xml',
'--format',
'html',
'-o',
'reports/rubocop/index.html']
end
task default: [:create_reports_dir, :rubocop, 'brakeman:run', 'bundle_audit:run',
'javascript:test', 'javascript:lint', 'erd:test', 'swagger:validate', 'cucumber']
end
Expand Down
1 change: 1 addition & 0 deletions app/serializers/es_response_set_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class ESResponseSetSerializer < ActiveModel::Serializer
attribute :id
attribute :name
attribute :oid
attribute :version_independent_id
attribute :version
attribute :status
Expand Down
4 changes: 2 additions & 2 deletions app/views/questions/_epi_info_question_field.xml.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Field
Name="<%= sni.question.content.parameterize.underscore.camelize.truncate(40, omission: '') %>"
PageId="<%= page_id %>"
PageId="<%= @position %>"
FieldId="<%= @tab_counter+1 %>"
UniqueId=""
FieldTypeId="<%= epi_info_field_type(sni.question.response_type.code, sni.response_set) %>"
Expand All @@ -9,7 +9,7 @@
PageName="<%= page_name %>"
PageBeforeCheckCode=""
PageAfterCheckCode=""
Position="<%= position %>"
Position="<%= @position %>"
PromptTopPositionPercentage="<%= @top += 0.025 %>"
PromptLeftPositionPercentage="<%= left + 0.01 %>"
ControlTopPositionPercentage="<%= @top += 0.025 %>"
Expand Down
63 changes: 59 additions & 4 deletions app/views/sections/_epi_info_section_field.xml.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Field
Name="<%= section.name.parameterize.underscore.camelize.truncate(40, omission: '') %>"
PageId="<%= page_id %>"
PageId="<%= @position %>"
FieldId="<%= @tab_counter+1 %>"
UniqueId=""
FieldTypeId="21"
Expand All @@ -9,7 +9,7 @@
PageName="<%= page_name %>"
PageBeforeCheckCode=""
PageAfterCheckCode=""
Position="<%= position %>"
Position="<%= @position %>"
ControlTopPositionPercentage="<%= @top+=0.03 %>"
ControlLeftPositionPercentage="<%= left %>"
ControlHeightPercentage="<%= height %>"
Expand Down Expand Up @@ -50,9 +50,64 @@
<% section.section_nested_items.each do |sni| %>
<% if sni.nested_section %>
<%= render partial: "sections/epi_info_section_field.xml",
locals: {section: sni.nested_section, page_id: page_id, position: position, left: left + 0.01, height: sni.nested_section.calculate_section_height, page_name: page_name } %>
locals: {section: sni.nested_section, left: left + 0.01, height: sni.nested_section.calculate_section_height, page_name: page_name } %>
<% else %>
<%= render partial: "questions/epi_info_question_field.xml",
locals: {section: section, sni: sni, page_id: page_id, position: position, left: left + 0.01, page_name: page_name } %>
locals: {section: section, sni: sni, left: left + 0.01, page_name: page_name } %>
<% if @top > 0.75 %>
<% @top = -0.03 %>
<% left = 0.01 %>
</Page>
<Page PageId="<%= @position+=1 %>" Name="<%= 'Page' + section.name.parameterize.underscore.camelize.truncate(40, omission: '') %>" Position="<%= @position %>" BackgroundId="0" ViewId="1">
<Field
Name="<%= section.name.parameterize.underscore.camelize.truncate(40, omission: '') %>"
PageId="<%= @position %>"
FieldId="<%= @tab_counter+1 %>"
UniqueId=""
FieldTypeId="21"
ControlAfterCheckCode=""
ControlBeforeCheckCode=""
PageName="<%= page_name %>"
PageBeforeCheckCode=""
PageAfterCheckCode=""
Position="<%= @position %>"
ControlTopPositionPercentage="<%= @top+=0.03 %>"
ControlLeftPositionPercentage="<%= left %>"
ControlHeightPercentage="1"
ControlWidthPercentage="<%= 1-(2*left) %>"
ControlScriptName=""
PromptTopPositionPercentage=""
PromptLeftPositionPercentage=""
PromptText="<%= section.name %>"
PromptFontFamily="Segoe UI"
PromptFontSize="12"
PromptFontStyle="Regular"
ControlFontFamily="Segoe UI"
ControlFontSize="12"
ControlFontStyle="Bold"
PromptScriptName=""
ShouldRepeatLast="False"
IsRequired="False"
IsReadOnly="False"
ShouldRetainImageSize="False"
Pattern=""
MaxLength=""
ShowTextOnRight="False"
Lower=""
Upper=""
RelateCondition=""
ShouldReturnToParent="False"
RelatedViewId=""
List="<%= section.nested_item_names %>"
SourceTableName=""
CodeColumnName=""
TextColumnName=""
BackgroundColor=""
Sort="False"
IsExclusiveTable="False"
TabIndex="<%= @tab_counter+=1 %>"
HasTabStop="True"
SourceFieldId="" />
<% end %>
<% end %>
<% end %>
4 changes: 2 additions & 2 deletions app/views/sections/_epi_info_section_page.xml.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Page PageId="<%= page_id %>" Name="<%= 'Page' + section.name.parameterize.underscore.camelize.truncate(40, omission: '') %>" Position="<%= position %>" BackgroundId="0" ViewId="1">
<Page PageId="<%= @position+=1 %>" Name="<%= 'Page' + section.name.parameterize.underscore.camelize.truncate(40, omission: '') %>" Position="<%= @position %>" BackgroundId="0" ViewId="1">
<% left = 0.01 %>
<%= render partial: "sections/epi_info_section_field.xml",
locals: {section: section, page_id: page_id, position: position, left: left, height: 1, page_name: 'Page' + section.name.parameterize.underscore.camelize.truncate(40, omission: '') } %>
locals: {section: section, left: left, height: 1, page_name: 'Page' + section.name.parameterize.underscore.camelize.truncate(40, omission: '') } %>
</Page>
18 changes: 4 additions & 14 deletions app/views/surveys/epi_info.xml.erb
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
<Template Name="<%= @survey.name.parameterize.underscore.camelize.truncate(40, omission: '') %>" Level="View">
<Project>
<View ViewId="1" Name="<%= @survey.name.parameterize.underscore.camelize.truncate(40, omission: '') %>" CheckCode="">
<% if @survey.page_numbers_present? %>
<% sects = @survey.survey_sections %>
<% sects.each do |ss| %>
<% sections_for_page = @survey.sections.select { |s| s.concepts.where(display_name: 'PageId', value: ss.section.page_id).present? } %>
<% if ss.section.id == sections_for_page[0].id %>
<%= render partial: "sections/epi_info_multi_section_page.xml",
locals: {sections: sections_for_page, page_id: ss.section.page_id, position: ss.position} %>
<% end %>
<% end %>
<% else %>
<% @survey.survey_sections.each do |ss| %>
<% @top = -0.03 %>
<% @position = 0 %>
<% @survey.survey_sections.each do |ss| %>
<% @top = -0.03 %>
<%= render partial: "sections/epi_info_section_page.xml",
locals: {section: ss.section, page_id: ss.position + 1, position: ss.position} %>
<% end %>
locals: {section: ss.section} %>
<% end %>
</View>
</Project>
Expand Down
11 changes: 8 additions & 3 deletions docs/elastic_search_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@
"tokenizer": {
"sdp": {
"type": "edge_ngram",
"min_gram": 3,
"max_gram": 10,
"min_gram": 2,
"max_gram": 20,
"token_chars": [
"letter",
"digit"
"digit",
"punctuation",
"symbol"
]
}
},
Expand Down Expand Up @@ -825,6 +827,9 @@
"id": {
"type": "text"
},
"oid": {
"type": "text"
},
"mostRecent": {
"type": "boolean"
},
Expand Down
11 changes: 10 additions & 1 deletion lib/sdp/elastic_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ def self.search(type, query_string, page, query_size = 10, must_filters = {}, cu

must_body = if query_string.blank?
{}
elsif query_string.include?('"')
# If the string has double quotes it should be exact match
{ query_string: { query: query_string, fields: [
'name', 'description', 'codes.code', 'codes.codeSystem', 'codes.displayName',
'tag_list', 'category', 'subcategory', 'createdBy.email', 'createdBy.name',
'status', 'content_stage', 'oid', 'version_independent_id'
] } }
else
{ dis_max: { queries: [
{ match: { name: { query: query_string, boost: 9 } } },
Expand All @@ -98,7 +105,9 @@ def self.search(type, query_string, page, query_size = 10, must_filters = {}, cu
{ match: { 'createdBy.email': { query: query_string } } },
{ match: { 'createdBy.name': { query: query_string } } },
{ match: { status: { query: query_string } } },
{ match: { content_stage: { query: query_string } } }
{ match: { content_stage: { query: query_string } } },
{ match: { oid: { query: query_string } } },
{ match: { version_independent_id: { query: query_string } } }
] } }
end

Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/cucumber.rake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ begin
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
t.fork = true # You may get faster startup if you set this to false
t.profile = 'default'
t.cucumber_opts = ["--format rerun --out rerun.txt"]
t.cucumber_opts = ["--format rerun --out rerun.txt --format json --out reports/cucumber.json"]
end

Cucumber::Rake::Task.new({:wip => 'test:prepare'}, 'Run features that are being worked on') do |t|
Expand Down
21 changes: 14 additions & 7 deletions webpack/actions/survey_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,22 @@ function fetchSurveyFailure(error) {
};
}

export function fetchDuplicates(id) {
export function fetchDuplicates(id, successHandler=null, failureHandler=null) {
const getPromise = axios.get(routes.duplicatesSurveyPath(id), {
headers: {
'X-Key-Inflection': 'camel',
'Accept': 'application/json'
}
});
if (successHandler) {
getPromise.then(successHandler);
}
if (failureHandler) {
getPromise.catch(failureHandler);
}
return {
type: FETCH_DUPLICATES,
payload: axios.get(routes.duplicatesSurveyPath(id), {
headers: {
'X-Key-Inflection': 'camel',
'Accept': 'application/json'
}
})
payload: getPromise
};
}

Expand Down
Loading

0 comments on commit 90b45a1

Please sign in to comment.