app/models/publishable.rb
# This method creates a portal publication entry in the database. It expects client code to pass a block that
# returns status of the publication (and perform it im some cases). The status should be a hash that provides
# following properties:
# - publication_data -> string, data that is used for publishing (usually after calling .to_json)
# - response -> string, response from Portal (if available) or some information useful for debugging
# - success -> boolean
# It returns response (described above).
This method creates a portal publication entry in the database. It expects client code to pass a block that
returns status of the publication (and perform it im some cases). The status should be a hash that provides
following properties:
publication_data -> string, data that is used for publishing (usually after calling .to_json)
response -> string, response from Portal (if available) or some information useful for debugging
success -> boolean
It returns response (described above).
This method creates a portal publication entry in the database . It expects client code to pass a block that returns status of the publication ( and perform it im some cases ) . The status should be a hash that provides following properties : publication_data - > string data that is used for publishing ( usually after calling . to_json ) response - > string response from Portal ( if available ) or some information useful for debugging success - > boolean It returns response ( described above ) .
def add_portal_publication(auth_portal)
    start_time = Time.now.to_f
    result = yield
    end_time = Time.now.to_f
    Rails.logger.info "Response Time: #{end_time - start_time}"
    Rails.logger.info "Response: #{result[:response].inspect}"
    publication_hash = Digest::SHA1.hexdigest(result[:publication_data])
    portal_publications.create({
      sent_data: result[:publication_data],
      response: result[:response].inspect, 
      success: result[:success],
      publication_hash: publication_hash,
      portal_url: auth_portal.publishing_url,
      publishable: self,
      publication_time: (end_time - start_time) * 1000,
    })
    self.update_column(:publication_hash, publication_hash)
    result[:response]
  end
def add_portal_publication ( auth_portal ) start_time = Time . now . to_f result = yield end_time = Time . now . to_f Rails . logger . info "Response Time: #{end_time - start_time}" Rails . logger . info "Response: #{result[:response].inspect}" publication_hash = Digest :: SHA1 . hexdigest ( result [ :publication_data ] ) portal_publications . create ( { sent_data : result [ :publication_data ] , response : result [ :response ] . inspect , success : result [ :success ] , publication_hash : publication_hash , portal_url : auth_portal . publishing_url , publishable : self , publication_time : ( end_time - start_time ) * 1000 , } ) self . update_column ( :publication_hash , publication_hash ) result [ :response ] end
This method creates a portal publication entry in the database.
This method creates a portal publication entry in the database .
# Properties that have to be provided by the block execution result. # it works fine for actual HTTP response or any other value (e.g. string) # Automatically calculated properties. # update_column is necessary so this change doesn't trigger update_after # if update_after is triggered then a new Job will be queued and we don't need # to do that. This also means that updated_at column won't be changed by this # Return response provided by a block execution.
auth_portal
<not_specific>