ruby on rails manually aggregate data from 2 tables from 2 different databases to use in the view

236 views Asked by At

So I get this Active record object by making a database request on server A, database B, table C

# server A, database B, table C
scope :comp_ids_in, lambda {|comp_ids| where(:comp_id => comp_ids)}
company_info = CompanyInfo.comp_ids_in(my_array_of_ids)

And I get another Activerelation object through request on server X, database Y, table Z

# server X, database Y, table Z
remote_info = RemoteInfo.where(username: current_user.username, property_code: company_info.collect(&:org_id), chain_code: company_info.collect(&:site_id))

The above remote_info object gives me a result close to what I need, except that I need one more additional thing which is contained in the company_info object.

company_info.display_name

So in addition to whatever remote_info object is returning I want it to return company_info.display_name as well for each result returned.

So basically something like a join except that it is 2 different databases & server requests.

Is the above aggregation achievable in my current scenario?

0

There are 0 answers