Skip to content

DevOps: Synchronizing :diffusion_histories_count's

Emmanuel Nwakire edited this page Jul 12, 2024 · 10 revisions

The :diffusion_histories_count column was added to the practices table to alleviate N+1 queries being carried out in the loading of the /search page as identified by the bullet gem. For details see the jira ticket

  1. Have an account
  2. Browse to http://internal-jenkinsdevops-837096002.us-gov-west-1.elb.amazonaws.com/
  3. Login
  4. Click "DEV - update diffusion histories count":

image001

  1. Click the "Configure" tab from the left nav bar:

image002

  1. Verify the script has the correct server designated, in the below screenshot the script is pointing to the PROD server, to change this simply edit "PROD_SERVER" in the "Execute shell" "Command" text box to STG_SERVER or DEV_SERVER (the full script is provided at the bottom of this wiki page for posterity):

image003

  1. Click "Apply" and "Save" and go back to the previous page.
  2. From here click "Build Now" to run the rake task on the server you have designated. (see the 2nd screenshot above)
  3. The rake task is set up to print the id and diffusion_history_count of each Practice as it runs. To see the console output click the status icon for the build under the "Build History" beneath the left nav bar (see the 2nd screenshot above). The console output will look like this when complete:

image004

This is the "Execute shell" "Command" script found in the "Configuration" page:

ssh ec2-user@$PROD_SERVER "CONTAINER_ID=\$(sudo docker ps -q -f ancestor=[124858472090.dkr.ecr.us-gov-west-1.amazonaws.com/diffusion-marketplace:ruby-2.7.8](http://124858472090.dkr.ecr.us-gov-west-1.amazonaws.com/diffusion-marketplace:ruby-2.7.8)); sudo docker exec \$CONTAINER_ID bundle exec rake practice:update_diffusion_histories_counts;"

As mentioned, to change this to run on another server simply change PROD_SERVER to the desired server. So this would be the script for STG:

ssh ec2-user@$STG_SERVER "CONTAINER_ID=\$(sudo docker ps -q -f ancestor=[124858472090.dkr.ecr.us-gov-west-1.amazonaws.com/diffusion-marketplace:ruby-2.7.8](http://124858472090.dkr.ecr.us-gov-west-1.amazonaws.com/diffusion-marketplace:ruby-2.7.8)); sudo docker exec \$CONTAINER_ID bundle exec rake practice:update_diffusion_histories_counts;"

for DEV:

ssh ec2-user@$DEV_SERVER "CONTAINER_ID=\$(sudo docker ps -q -f ancestor=[124858472090.dkr.ecr.us-gov-west-1.amazonaws.com/diffusion-marketplace:ruby-2.7.8](http://124858472090.dkr.ecr.us-gov-west-1.amazonaws.com/diffusion-marketplace:ruby-2.7.8)); sudo docker exec \$CONTAINER_ID bundle exec rake practice:update_diffusion_histories_counts;"
Clone this wiki locally