Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RF-498/Documnet-description-parsing #154

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions app/models/phase_revision.rb
Original file line number Diff line number Diff line change
@@ -100,6 +100,8 @@ def load_metadata(summary)
current_label = nil
current_status_content = ''
collecting = false
description_collecting = false
description_content = ''

doc.search('h3, p, ul, li').each do |element|
if element.name == 'h3'
@@ -111,12 +113,22 @@ def load_metadata(summary)
current_status_content = ''
end

if description_collecting
assign_value(metadata_mapping["Stručný opis:"], description_content.strip)
description_collecting = false
description_content = ''
end

collecting = true if current_label == "Čo sa práve deje"
description_collecting = true if current_label == "Stručný opis"
end

if collecting && %w[p ul].include?(element.name)
current_status_content += element.to_html

elsif description_collecting && %w[p ul li].include?(element.name)
description_content += element.to_html

elsif element.name == 'p'
strong_element = element.at('strong')
if strong_element
@@ -139,6 +151,10 @@ def load_metadata(summary)
if collecting && metadata_mapping.key?("Čo sa práve deje:")
assign_value(metadata_mapping["Čo sa práve deje:"], current_status_content)
end

if description_collecting && metadata_mapping.key?("Stručný opis:")
assign_value(metadata_mapping["Stručný opis:"], description_content.strip)
end
end

def assign_value(attribute, value)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeDescriptionToTextInPhaseRevisions < ActiveRecord::Migration[5.1]
def change
change_column :phase_revisions, :description, :text
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chceme migráciu, ktorá nezmaže hodnoty

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@celuchmarek podla tychto clankov(clanok_1, clanok_2), by sa hodnota v tomto pripade zmazat nemala, ak to ide z string -> text, neda sa vsak rollbacknut...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

end
end
4 changes: 2 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20240621112043) do
ActiveRecord::Schema.define(version: 20241212091706) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -39,7 +39,7 @@
t.string "title", null: false
t.string "full_name"
t.string "guarantor"
t.string "description"
t.text "description"
t.string "budget"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false