{"id":14955647,"url":"https://github.com/mooreniemi/transbucket_rails","last_synced_at":"2025-10-01T01:31:09.502Z","repository":{"id":8202285,"uuid":"9634642","full_name":"mooreniemi/Transbucket_Rails","owner":"mooreniemi","description":":hospital: → :camera: → :thumbsup:","archived":false,"fork":false,"pushed_at":"2022-12-14T15:30:11.000Z","size":115964,"stargazers_count":10,"open_issues_count":35,"forks_count":4,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-01-14T11:45:55.267Z","etag":null,"topics":["community","elasticsearch","heroku","open-source","photo-sharing","photos","postgres","rails","rails4","ruby","transgender"],"latest_commit_sha":null,"homepage":"http://www.transbucket.com","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mooreniemi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-23T22:25:13.000Z","updated_at":"2023-12-27T23:19:53.000Z","dependencies_parsed_at":"2023-01-11T20:10:49.254Z","dependency_job_id":null,"html_url":"https://github.com/mooreniemi/Transbucket_Rails","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mooreniemi%2FTransbucket_Rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mooreniemi%2FTransbucket_Rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mooreniemi%2FTransbucket_Rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mooreniemi%2FTransbucket_Rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mooreniemi","download_url":"https://codeload.github.com/mooreniemi/Transbucket_Rails/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234808936,"owners_count":18890086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["community","elasticsearch","heroku","open-source","photo-sharing","photos","postgres","rails","rails4","ruby","transgender"],"created_at":"2024-09-24T13:11:29.670Z","updated_at":"2025-10-01T01:31:03.696Z","avatar_url":"https://github.com/mooreniemi.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"```\n          _______\n      _.-()______)-._\n    .'               '.\n   /                   \\\n  :      _________      :\n  |.--'''         '''--.|\n  (                     )\n  :'--..._________...--':\n  :                     :\n   :                   :\n   :         ⚧️         :\n    :                 :\n    :                 :\n     :               :\n     :               :\n      :             :\njrei  :_           _:\n        '''-----'''\n```\n\n\nTransbucket.com (Transbucket_Rails)\n===================================\n\nThe TL;DR of technical specs is: Rails 4.2.8 (in Ruby 2.6.6), using\n[bower_rails](https://github.com/rharriso/bower-rails) to manage\nJavascript dependencies, on Postgres database for storage, and with\nElasticsearch for search.\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n**Table of Contents**\n\n- [setup](#setup)\n  - [docker-compose](#docker-compose)\n  - [database setup](#database-setup)\n    - [elasticsearch](#elasticsearch)\n    - [postgres](#postgres)\n- [run environments](#run-environments)\n  - [development (local)](#development-local)\n  - [ci](#ci)\n  - [staging](#staging)\n  - [production](#production)\n  - [tests](#tests)\n    - [parallel tests](#parallel-tests)\n    - [performance testing](#performance-testing)\n  - [static analysis](#static-analysis)\n  - [profiling](#profiling)\n    - [ruby-prof example](#ruby-prof-example)\n    - [stackprof example](#stackprof-example)\n- [caching](#caching)\n- [search](#search)\n- [running scheduled jobs / async execution](#running-scheduled-jobs--async-execution)\n- [more help](#more-help)\n- [contact](#contact)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n# setup\n\n## docker-compose\n\nOnce you have [docker-compose](https://docs.docker.com/compose/install/)\ninstalled, you can spin up a containerized local dev environment by running:\n\n```sh\ndocker-compose up --build\n```\n\nThis will bring up the app at http://localhost:3000 alongside Elasticsearch,\nKibana, and Postgres. You can then complete the initial setup by running:\n\n```sh\ndocker-compose exec web bundle exec rake db:setup\ndocker-compose exec web \\\n    bundle exec rake environment elasticsearch:import:model CLASS=Pin INDEX=development_pins FORCE=y\n```\n\nTo stop the environment, run:\n```sh\ndocker-compose down\n```\n\nAlternatively, you can set up all the services directly on your machine as\ndescribed in the rest of this section.\n\n## database setup\n\nFor set up, you'll need to make sure you have Elasticsearch installed for search functionality and Postgres installed for the actual database. The database is currently set up to have the user \"Alex\".\n\n### elasticsearch\n\n```\nbrew install elasticsearch\nbrew install kibana\n\n# to make sure ES is up\ncurl localhost:9200\n```\n\nThen you can access the [Kibana UI](http://localhost:5601/app/kibana#/dev_tools/console).\n\n### postgres\n\nHeroku [manages our database.yml](https://devcenter.heroku.com/articles/heroku-postgresql#connecting-in-ruby) in production (and staging), so all these instructions are just for local environment.\n\nFor Postgres on Mac, you can use [postgresapp](http://postgresapp.com/).\nOn Linux check your distribution details.\n\nUse `createuser \"Alex\" -s` in the shell to create the user. (On\nLinux,`createuser` is its own executable, so log onto `psql` first.) If\npermissions seem wrong, run `psql` and enter `ALTER ROLE \"ALEX\" CREATEDB;`\nto give it the right permissions.\n\nNow you should be able to run `rake db:setup`. Make sure to redo this command and for subsequent commands rerun for `RAILS_ENV=test`, then you can run `bundle` to install gems, and `rspec` to run tests.\n\nSome seed data is necessary for the site to work. It is all handled via `rake db:seed` which is included during `rake db:setup`. The process in general is a backup and dump of the [prod database](https://devcenter.heroku.com/articles/heroku-postgres-import-export#export) is made, then a [seed_dump](https://github.com/rroblak/seed_dump) from it.\n\nFor your ease, `rake db:seed` will also create a user and an admin. Both will have the password \"password\". The usernames should output to console.\n\nOn Ubuntu, you will likely need to follow [these\ninstructions](https://gist.github.com/p1nox/4953113) after you've\ninstalled headers.\n\n# run environments\n\nStaging and production both deploy and depend on [Heroku](https://heroku.com/). You should grab their [cli](https://devcenter.heroku.com/articles/using-the-cli). These instructions assume you've set it up.\n\nEnvironment variables are kept in an untracked file (`config/application.yml`) managed by [Figaro](https://github.com/laserlemon/figaro#heroku). Running `heroku config --app transbucket` will give you the production env, and `heroku config --app transbucket-staging` staging's env. When you want to push local changes to Heroku (be VERY careful with this), you use `figaro heroku:set -e production`.\n\n## [development (local)](http://localhost:3000)\n\nTo run locally, I use `rails s -p 3003` (because I am often running servers on other ports). Then navigate to [localhost:3003](http://localhost:3000/) to browse. You can also just run it without specifiying the port.\n\nIf you need to test against an actual S3 instance, you can uncomment the config block in `config/environments/development.rb` and set the required environment varialbles. (You can grab those with `heroku config --app transbucket-staging`. Otherwise you'll just store on your local file system.\n\n## [ci](https://circleci.com/dashboard)\n\nCurrently using [CircleCI](https://circleci.com/), which runs the app on [Ubuntu 12](https://circleci.com/docs/build-image-precise/). If you need to change a setting, try changing it via the UI first, then edit the `circle.yml` file.\n\nFor master branch: [![CircleCI](https://circleci.com/gh/mooreniemi/Transbucket_Rails/tree/master.svg?style=svg\u0026circle-token=22981fbc246ebdb12d14ef593592e163d093caf7)](https://circleci.com/gh/mooreniemi/Transbucket_Rails/tree/master)\n\n## [staging](https://dashboard-preview.heroku.com/apps/transbucket-staging)\n\nStaging is meant to run in the production environment, as close to actual production as possible. Every successful build on CI (based on every `git push` you do) will trigger a deployment on staging automatically.\n\nIf you need to deploying a branch to [staging](https://transbucket-staging.herokuapp.com/) manually:\n\n`git push staging your_branch:master`\n\nConnecting to staging to debug or run tasks:\n\n`heroku run rails console --app transbucket-staging`\n\n## [production](transbucket.com)\n\nFor staging and production, assets need to be recompiled. It's wise to clean them first:\n\n```\n  rake assets:clean\n  RAILS_ENV=production bundle exec rake assets:precompile\n```\n\nWhile we remain on Heroku, it will infer this step for us. (You won't need to do it.)\n\n## tests\n\nOn the Ruby side, `rspec`, but you also need `chromium-chromedriver` in\norder to run UI integ tests, via Selenium. For example, on Ubuntu you can\nrun: `sudo apt-get install chromium-chromedriver`. If you want to spy on\nwhat's happening during a Selenium run, you can edit\n`spec/support/capybara_config.rb` to switch off `_headless`.\n\nSpring is installed to speed up Rails loading times; you should see much shorter load times after the first run.\n\nIf you need to see some performance stats, use `rspec --profile`.\n\n### parallel tests\n\nTo set up (one time only):\n\n```sh\nrake parallel:setup\n```\n\nThen, run tests with:\n\n`rake parallel:spec`\n\nOr, to run with Spring for faster load times:\n\n```sh\nexport DISABLE_SPRING=0 # needed to force activate spring\nspring rake parallel:spec\n```\n\n### performance testing\n\nBest if you run `unicorn` rather than usual development server `thin`:\n\n`unicorn -c config/unicorn.rb` # this will spawn 3 processes\n\nThen after installing [apache_bench](http://work.stevegrossi.com/2015/02/07/load-testing-rails-apps-with-apache-bench-siege-and-jmeter/) (you should be able to do `brew install ab`) run:\n\n`ab -n 100 -c 10 http://0.0.0.0:8080/`\n\n## static analysis\n\n[rubocop](https://github.com/bbatsov/rubocop) and [brakeman](https://github.com/presidentbeef/brakeman) are available.\n\n## profiling\n\nIn dev mode, [rack-mini-profiler](https://github.com/MiniProfiler/rack-mini-profiler), [stackprof](https://github.com/tmm1/stackprof) and [ruby-prof](https://github.com/ruby-prof/ruby-prof) are available.\n\n### ruby-prof example\n\n```ruby\n  require 'ruby-prof'\n  RubyProf.start\n\n  # some ruby code you want to profile\n\n  result = RubyProf.stop\n  printer = RubyProf::FlatPrinter.new(result)\n  printer.print(STDOUT)\n\n  # if you need the call stack, try\n  #printer = RubyProf::CallStackPrinter.new(result)\n  #printer.print(File.open('tmp/ruby_prof.html', \"w\"))\n```\n\n### stackprof example\n\n```ruby\n  # i add this to the top of a test file\n  # say, spec/presenters/pin_presenter_spec.rb\n\n  RSpec.configure do |config|\n    config.around(:each) do |example|\n      path = Rails.root.join(\"tmp/stackprof-cpu-test-#{example.full_description.parameterize}.dump\")\n      StackProf.run(mode: :cpu, out: path.to_s) do\n        example.run\n      end\n    end\n  end\n```\n\nThen you can use something like: `bundle exec stackprof tmp/stackprof-cpu-test-pinpresenter-filtering-results-returns-pins-scoped-by-procedure.dump` to view the dump.\n\nIf you need to find a corresponding call, you can use `git grep suspicious_call -- '*.rb'`.\n\n# caching\n\nFragment, page, and low-level caching are being used despite Heroku's [ephemeral file store](https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem). Given the site runs on one dyno, and that deploys are infrequent, filestore caching still has some benefit.\n\nPage caching is only used for public areas of the site. For the majority of the site, fragment caching and low-level calls of the form `Rails.cache.fetch` are being used.\n\n# search\n\nThe `Pin` model has a callback that will update Elasticsearch. But when\nyou are initially filling the index, you want to run the below command\nafter you have seeded the database. Essentially Elasticsearch is\na secondary view of our database data. It is safe to delete it and reindex\nit.\n\n```\nrake environment elasticsearch:import:model CLASS='Pin' INCLUDE='PinImage,Surgeon,Procedure' FORCE=true\n\n# should show you the index you created, labeled by env\ncurl localhost:9200/_cat/indices\n```\n\n# running scheduled jobs / async execution\n\nVia Heroku add-ons we have [scheduler](https://devcenter.heroku.com/articles/scheduler). The process is basically add a `rake` task, and use `heroku addons:open scheduler` to open the scheduler.\n\nThe other option is [delayed_job](https://github.com/collectiveidea/delayed_job). During deploy, a separate dyno is used to run `rake jobs:work` which starts the `delayed_job` process that manages execution of the queue.\n\nI've been using the `scheduler` to run things like periodic jobs, whereas I use `delayed_jobs` for stuff like sending an email async. (For an example see `app/helpers/notifications_helper.rb`.)\n\n# more help\n\n- Is there a rake task? Use `rake -T` to check.\n- Locked yourself out? `User.where(email: 'user_email_address').take.reset_password('new_password','new_password').confirm`\n- Having trouble getting to where an error is raised or want a quick feedback loop? Try [pry-rescue](https://github.com/ConradIrwin/pry-rescue) by doing `bundle exec rescue rspec` or `bundle exec rescue rails s`.\n- Not seeing a change you expect? Some fragment [caching](http://guides.rubyonrails.org/caching_with_rails.html) is being used. If you need to manually clear it, hop into `rails c` and then run `Rails.cache.clear`. (You can also just `rm -rf tmp`.)\n\n# contact\n\n[email alex](mailto:webmaster@transbucket.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmooreniemi%2Ftransbucket_rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmooreniemi%2Ftransbucket_rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmooreniemi%2Ftransbucket_rails/lists"}