Skip to content

Instantly share code, notes, and snippets.

View ashikajith's full-sized avatar

Ashik Ajith ashikajith

View GitHub Profile
@ashikajith
ashikajith / syncing_carrier_wave_to_active_storage.rb
Created September 22, 2022 21:54
Carrier wave to Active Storage Syncing
#app/models/profile.rb
def sync_active_storage_future_logo
# Abort if the attachment is default
return unless logo.present? && (logo.id != DefaultAvatar.for_logo.asset_id)
future_logo.purge if future_logo.attached? # remove the existing image from new attachment field
sync_future_logo
end
@ashikajith
ashikajith / rif_export_doc.md
Last active August 9, 2019 14:24
Rif Export

RIF Doc

For Rif template all the fileds have unique codes and we represent eah codes to the corresponding value. Following are the steps we follow to generate the report

  • Fetch the corresponding work from the controller CitationExportsController (app/controllers/ubiquity/citation_exports_controller.rb) and process the fetched record to render in RIF fromat.
  • A Controller Concern is added to handle the processing of data in Rif format (app/controllers/concerns/ubiquity/citations_export_concern.rb)

Basically we have a hash which consist of code and the fields that needs to map. Please find the hash below

@ashikajith
ashikajith / mailer_report_doc.md
Last active August 9, 2019 14:25
Mailer Report Doc

Mailer Report

For the mailer report we have WorkReportMailer which acts as the controller of the Application Mailer. The mailer is called in the ExportController file.

  def send_mail_report
    emails = process_email
    emails.each do |email|
      WorkReportMailer.send_report(email.strip, current_account.cname, params[:email_type]).deliver_later
    end
 redirect_to hyrax.admin_stats_path(anchor: 'email_reports')
@ashikajith
ashikajith / oai_export_doc.md
Last active August 9, 2019 14:33
OAI Export Feature

OAI Export

For OAI we are using the BlackLightOaiProvider gem (https://github.com/projectblacklight/blacklight_oai_provider) which harvest the data automatically once it is configured in the catalog controller. We have divided into two phases.

We do have an ENV variable which acts as a switch to enable this feature .

ENABLE_OAI_METADATA: 'true'
@ashikajith
ashikajith / mask_s3_url.md
Created August 9, 2019 11:50
Masking S3 URL

S3 Masking URL

For masking the url we created a seperate routes, controller to fetch the record and generate the url for the download file.

  app/controllers/ubiquity/fail_uploads_controller.rb
  
  def download_file
    params[:fileset_id]
    uuid = params[:uuid]
 s3_file_set_url = Ubiquity::ImporterClient.get_s3_url uuid
@ashikajith
ashikajith / chunk_file_doc.md
Last active August 9, 2019 14:25
Chunk File Upload Doc

File Chunk Upload

To support large file upload we need to segregate the file to different chunks and we will be sending each chunk in a single request to the server. Once they recieve the complete chunk, we will combine the chunk to get the actual file.

Following are the steps we followed to implement the feature.

@ashikajith
ashikajith / importer_client.rb
Created April 25, 2019 14:40
Api Call Wrapper
module Ubiquity
class ImporterClient
include HTTParty
format :json
base_uri 'https://importer.repo-test.ubiquity.press'
attr_accessor :file_url_hash, :code, :file_name_hash
def initialize(response)
if response