Skip to content

Commit

Permalink
fix: ensure we send indexing and eula details in viewer and submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
macite committed Dec 20, 2023
1 parent 124558f commit 38d4059
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 2 additions & 0 deletions app/helpers/turn_it_in.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class TurnItIn
def self.load_config(config)
config.tii_enabled = ENV['TII_ENABLED'].present? && (ENV['TII_ENABLED'].to_s.downcase == "true" || ENV['TII_ENABLED'].to_i == 1)

config.tii_add_submissions_to_index = ENV['TII_INDEX_SUBMISSIONS'].present? && (ENV['TII_INDEX_SUBMISSIONS'].to_s.downcase == "true" || ENV['TII_INDEX_SUBMISSIONS'].to_i == 1)

if config.tii_enabled
# Turn-it-in TII configuration
require 'tca_client'
Expand Down
13 changes: 10 additions & 3 deletions app/models/turn_it_in/tii_action_upload_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def fetch_tii_submission_id
save_and_reschedule

# If we had to indicate the eula was accepted, then we need to update the user
unless submitted_by_user.tii_eula_version_confirmed
unless submitted_by_user.eula_accepted_and_confirmed?
submitted_by_user.confirm_eula_version(TurnItIn.eula_version, DateTime.now)
end

Expand Down Expand Up @@ -218,7 +218,7 @@ def tii_submission_data
end

# Add eula acceptance details to submission, if required
if submitted_by_user.accepted_tii_eula? && !submitted_by_user.tii_eula_version_confirmed
if submitted_by_user.accepted_tii_eula? && !submitted_by_user.eula_accepted_and_confirmed?
result.eula = TCAClient::EulaAcceptRequest.new(
user_id: submitted_by_user.username,
language: 'en-us',
Expand Down Expand Up @@ -299,11 +299,18 @@ def request_similarity_report
]

exec_tca_call "TiiSubmission #{entity.id} - requesting similarity report", error_code do
add_to_index = Rails.env.production? && Doubtfire::Application.config.tii_add_submissions_to_index

data = TCAClient::SimilarityPutRequest.new(
indexing_settings:
TCAClient::IndexingSettings.new(
add_to_index: add_to_index,
),
generation_settings:
TCAClient::SimilarityGenerationSettings.new(
search_repositories: TiiActionFetchFeaturesEnabled.search_repositories,
auto_exclude_self_matching_scope: 'GROUP_CONTEXT'
auto_exclude_self_matching_scope: 'GROUP_CONTEXT',
priority: 'LOW'
)
)

Expand Down
4 changes: 4 additions & 0 deletions app/models/turn_it_in/user_tii_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def accepted_tii_eula?
tii_eula_version == TurnItIn.eula_version
end

def eula_accepted_and_confirmed?
accepted_tii_eula? && tii_eula_version_confirmed
end

def confirm_eula_version(version, timestamp)
update(
tii_eula_version_confirmed: true,
Expand Down
4 changes: 2 additions & 2 deletions test/models/tii_model_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def test_tii_process
similarity_request = stub_request(:put, "https://#{ENV['TCA_HOST']}/api/v1/submissions/1223/similarity").
with(tii_headers).
with(
body: "{\"generation_settings\":{\"search_repositories\":[\"INTERNET\",\"SUBMITTED_WORK\",\"PUBLICATION\",\"CROSSREF\",\"CROSSREF_POSTED_CONTENT\"],\"auto_exclude_self_matching_scope\":\"GROUP_CONTEXT\"}}",
body: "{\"indexing_settings\":{\"add_to_index\":false},\"generation_settings\":{\"search_repositories\":[\"INTERNET\",\"SUBMITTED_WORK\",\"PUBLICATION\",\"CROSSREF\",\"CROSSREF_POSTED_CONTENT\"],\"auto_exclude_self_matching_scope\":\"GROUP_CONTEXT\",\"priority\":\"LOW\"}}",
).
to_return(status: 200, body: "", headers: {})

Expand Down Expand Up @@ -486,7 +486,7 @@ def test_tii_process
similarity_request = stub_request(:put, "https://#{ENV['TCA_HOST']}/api/v1/submissions/1222/similarity").
with(tii_headers).
with(
body: "{\"generation_settings\":{\"search_repositories\":[\"INTERNET\",\"SUBMITTED_WORK\",\"PUBLICATION\",\"CROSSREF\",\"CROSSREF_POSTED_CONTENT\"],\"auto_exclude_self_matching_scope\":\"GROUP_CONTEXT\"}}",
body: "{\"indexing_settings\":{\"add_to_index\":false},\"generation_settings\":{\"search_repositories\":[\"INTERNET\",\"SUBMITTED_WORK\",\"PUBLICATION\",\"CROSSREF\",\"CROSSREF_POSTED_CONTENT\"],\"auto_exclude_self_matching_scope\":\"GROUP_CONTEXT\",\"priority\":\"LOW\"}}",
).
to_return(status: 200, body: "", headers: {})

Expand Down

0 comments on commit 38d4059

Please sign in to comment.