# Full text search The pg_search Ruby gem is used for full-text searched in Rails. See: https://github.com/Casecommons/pg_search Reformatted SQL query for fulltext search: SELECT COUNT(*) FROM "packages" WHERE ( ( ( to_tsvector('simple', coalesce("packages"."name"::text, '')) || to_tsvector('simple', coalesce("packages"."description"::text, '')) || to_tsvector('simple', coalesce("packages"."long_description"::text, '')) ) @@ ( to_tsquery('simple', '''' || 'browser' || ' ''') ) ) ) # Index: CREATE INDEX packages_gin ON packages USING GIN( (to_tsvector('simple', coalesce("packages"."name"::text, '')) || to_tsvector('simple', coalesce("packages"."description"::text, '')) || to_tsvector('simple', coalesce("packages"."long_description"::text, ''))) ); --------- Used: https://github.com/semaperepelitsa/jquery.fileupload-rails Which is a gem for: https://github.com/blueimp/jQuery-File-Upload Paperclip for attachment/screenshot file handlind within ActiveRecord https://github.com/thoughtbot/paperclip -- Components: - Rails 5 (widespread, up-to-date, solves many common problems) - PostgreSQL (fast, easy, I don't like MySQL, good fulltext search) - Git (most people nowadays use Git) - jQuery (well known and easy to use) - Zurb Foundation (integrates nicer than Twitter Bootstrap) - Guard for automated testing (http://www.rubydoc.info/gems/guard-rails) -- Importer How Debian repositories are organized: https://wiki.debian.org/RepositoryFormat -- Logging from within the application into the database's "log" table: Log.log "foo" or with section (default='frontend'): Log.log "foo", "importer" -- Future stuff ------------ A possible migration adding a unique constraint to avoid duplicate images class AddScreenshotUniqueConstraintImageFingerprint < ActiveRecord::Migration def change add_index :screenshots, [:package_id, :image_fingerprint], :unique => true end end A separate validation in the Screenshots model has been implemented already. This unique constraint would raise an error and not trigger a validation error properly unless the separate model validation is in place. -- Deployment ---------- To prepare your computer to run Debshots 2.x either for development or production you need to… - unpack the project onto your disk somewhere - install Ruby 2.0.0 via rvm (see http://rvm.io/) - install the library header packages so that the required Ruby gems can be compiled: sudo apt-get install libbz2-dev libpq-dev libyaml-dev - install a PostgreSQL database: sudo apt-get install postgresql - edit the PostgreSQL authentication configuration at /etc/postgres/.../pg_hba.conf to allow password-based logins from localhost. Change the line starting with *local* to read: local all all md5 - create a user and databases - sudo su - postgres - createuser -s -P debshots - createdb debshots - for development only: - sudo su - postgres - createdb debshots_dev - migrate the data from the Debshots 1.x based production server: - bin/get-data-from-old-live-server.sh - install all Ruby gems required to run the application: - gem install bundle - bundler - run database migrations for development - RAILS_ENV=development rake db:migrate - import long description information for the packages into development database - RAILS_ENV=development rake debshots:update_longdescription_from_deb_repos - run database migrations for production - RAILS_ENV=production rake db:migrate - RAILS_ENV=production rake debshots:update_longdescription_from_deb_repos - import long description information for the packages into production database - prepare the static assets (CSS, JS) for production - RAILS_ENV=production rake assets:precompile - run the production web server - RAILS_ENV=production rails s