Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
hammady committed Dec 31, 2017
2 parents 0fc68f0 + 8162909 commit a1f6d8d
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 33 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ ENV RACK_ENV $env
RUN echo "Running \"bundle install $bundle_opts\" with environment set to \"$env\"..." && \
bundle install $bundle_opts

# generate sitemap
RUN bundle exec sitemap:refresh:no_ping

EXPOSE 3000

ENTRYPOINT ["bundle", "exec"]
Expand Down
10 changes: 4 additions & 6 deletions app/serializers/v3/word_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@ class V3::WordSerializer < V3::ApplicationSerializer
end

has_one :translation, serializer: V3::TranslationSerializer do
translation = object.public_send("#{scope[:language] || 'en'}_translations").first
translation = object.public_send("#{scope[:language] || 'en'}_translations").first

translation.present? ? translation : object.en_translations.first
translation.present? ? translation : object.en_translations.first
end

has_one :transliteration, serializer: V3::TransliterationSerializer do
transliteration = object.public_send("#{scope[:language] || 'en'}_transliterations").first

transliteration.present? ? transliteration : object.en_transliterations.first
has_one :transliteration, serializer: V3::TranslationSerializer do
object.en_translations.first
end

def class_name
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ if [ "$environment" == "development" ]; then
docker-compose build #--no-cache
./save-artifacts.sh $artifacts
else
docker-compose -f docker-compose.yml -f docker-compose.$environment.yml build
docker-compose -f docker-compose.$environment.yml build
fi
4 changes: 4 additions & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ default: &default

development:
<<: *default
adapter: postgresql
encoding: unicode
database: quran_dev

test:
<<: *default

production:
<<: *default
url: <%= ENV['DATABASE_URL'] %>
25 changes: 0 additions & 25 deletions docker-compose.override.yml

This file was deleted.

1 change: 1 addition & 0 deletions docker-compose.production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
args:
- env=production
- bundle_opts=--without development test --deployment --clean
image: qurancomapi_api:prod-latest
environment:
- SECRET_KEY_BASE=abcdefa

11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
version: '3'
services:
api:
build:
context: .
args:
- env=development
- bundle_opts=--without test
image: qurancomapi_api:dev-latest
volumes:
- .:/app
ports:
- "3000:3000"
environment:
- DATABASE_URL=postgres://quran_dev:quran_password@postgres:5432/quran_db
- ELASTICSEARCH_HOST=elasticsearch
- SENTRY_DSN=
- SECRET_KEY_BASE=abcdefa
depends_on:
- postgres
- elasticsearch
postgres:
image: qurandb:v102
ports:
Expand Down
2 changes: 1 addition & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ To rebuild the image for production:

RAILS_ENV=production ./build.sh

Push the resulting image to a registry so that a `docker stack deploy` finds it.
Then tag and push the resulting image to a registry so that a `docker stack deploy` finds it.
20 changes: 20 additions & 0 deletions lib/tasks/one_time.rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
namespace :one_time do
task replace_wbw_translation: :environment do
require 'csv'
changed = []

data = CSV.open("final_wbw_translation.csv").read

data[1..data.size].each do |row|
word = Word.find(row[0])
if word.en_translations.first.text != row[2].to_s.strip
changed[word.id] = {current: word.en_translations.first.text, new: row[2].to_s.strip}
end

word.en_translations.first.update_column :text, row[2].to_s.strip
end

File.open("wbw_report", 'wb') do |file|
file << changed.to_json
end
end

task fix_tafsir: :environment do
Tafsir.includes(:verse).each do |tafsir|
tafsir.update_attribute :verse_key, tafsir.verse.verse_key
Expand Down

0 comments on commit a1f6d8d

Please sign in to comment.