NameL3ss

ideas sin concluir

Jun 7th, 2025 (edited)
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. https://backend.webdoxclm.com/v2/organizations/people/select_search?page=1&per_page=20
  2.  
  3. {id: 1, value: "perro"}
  4.  
  5.  
  6. #<MassImportLogger:0x0000000142fe95c8
  7. id: 4,
  8. customer_id: 1,
  9. user_id: 1,
  10. scoped_id: 1,
  11. importer_type: "organization_companies_and_people",
  12. status: "pending",
  13. records:
  14. {"Document"=>[19, 20, 21],
  15. "Document_failed_ids"=>[12, 13, 14, 15, 16, 17, 18],
  16. "extra"=>{"20"=>{"document_name"=>"ciudades", "document_attribute_options"=>["arica", "santiago"]}, "21"=>{"document_name"=>"tipo de archivos", "document_attribute_options"=>["tmp"]}}},
  17. errors_count: {"Document"=>3},
  18. created_at: Tue, 03 Jun 2025 12:56:21 -04 -04:00,
  19. updated_at: Thu, 05 Jun 2025 22:18:17 -04 -04:00,
  20. uploaded_excel_file_name: nil,
  21. uploaded_excel_content_type: nil,
  22. uploaded_excel_file_size: nil,
  23. uploaded_excel_updated_at: nil,
  24. errors_excel_file_name: nil,
  25.  
  26. id document_metadata_type document_metadata_id metadata mass_import_log
  27. 1. "Document". "1", { error => [{name: {"name already taken"}] }, 1
  28. 2 "DocumentAttribute", "2", { "document_attribute_values"=>["arica", "santiago"] }, 1
  29.  
  30.  
  31.  
  32. app/services/mass_import/classification/document_classification_row.rb
  33. dynamic_attr son los values a crear son los que vienen del excel crear un geter con estos elementos
  34.  
  35.  
  36.  
  37.  
  38. document_attribute_values traer todos los values de todos los documentos que se intentan clasificar
  39.  
  40. app/services/mass_import/sheet_import.rb
  41. linea 27
  42. al row_class sacarle los dynamic_attr
  43.  
  44. hacer resta entre dynamic_attr vs todos los values y esto insertar en una tabla
  45. para poder saber que nuevos valores se crearon en la clasificacion
  46.  
  47.  
  48.  
  49. def import
  50. sheet.set_sheet_importer(self)
  51. total_rows = parsed_data.size
  52. notifier.set_sheet(sheet_name: translation_key, total_rows: total_rows)
  53. parsed_data.each do |row_data|
  54. row = row_class.new(customer, user, row_data, self)
  55. if row.save!
  56. @saved_records << row.record.id
  57. else
  58. @rows_with_errors << row
  59. end
  60. notifier.push_progress_event(translation_key)
  61. end
  62. aca hacer flujo resta
  63. end
  64.  
  65.  
  66. luego
  67.  
  68.  
  69.  
  70. document.document_attribute_values.create!(attrs) if document.allows_create_options_on_classification?
  71.  
  72. records = {
  73. "document" => {
  74. ids: [19, 20, 21],
  75. extra: {
  76. "20" => { document_attribute_options: ["arica", "santiago"] },
  77. "21" => { document_attribute_options: ["concepcion"] }
  78. }
  79. }
  80. }
  81.  
  82. {
  83. "Document" => [19, 20, 21],
  84. "Document_failed_ids" => [12, 13, 14, 15, 16, 17, 18],
  85. "extra" => {
  86. "20" => { "document_name" => "ciudades", "document_attribute_options" => ["arica", "santiago"] },
  87. "21" => { "document_name" => "tipo de archivos", "document_attribute_options" => ["tmp"] }
  88. }
  89. }
  90.  
  91. def index
  92. import_logs = current_customer
  93. .mass_import_logs
  94. .where(importer_type: : document_classification, status: [:completed, :failed, :canceled])
  95. .order(scoped_id: :desc)
  96.  
  97. data, meta = CursorPaginatorService.new(
  98. resource: import_logs,
  99. limit: params[:limit],
  100. cursor: params[:cursor],
  101. cursor_column: :scoped_id,
  102. max_limit: params[:max_limit],
  103. order_direction: :desc
  104. ).paginate
  105.  
  106. render json: ::MassImport::Classification::MassImportLoggerSerializer.new(data, index_opts(meta: meta)).serialized_json, status: :ok
  107. end
  108.  
  109.  
  110. def index_opts(attrs = {})
  111. {
  112. fields: {
  113. mass_import_log: %i[user_full_name status errors_count documents_count scoped_id total update_count]
  114. }
  115. }.merge(attrs)
  116. end
  117.  
  118.  
Advertisement
Add Comment
Please, Sign In to add comment