-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added tafsir endpoint * finished tafsir * formating * added rake task to update verse key for tafsirs * Fix PR
- Loading branch information
1 parent
2a6db0c
commit 6eadd5d
Showing
10 changed files
with
66 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,4 +74,5 @@ group :development do | |
gem 'mechanize' | ||
gem 'bullet' | ||
gem 'meta_request' | ||
gem 'rubocop', require: false | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,31 @@ | ||
class V3::TafsirsController < ApplicationController | ||
before_action :set_verse | ||
|
||
def index | ||
chapter = Chapter.find(params[:chapter_id]) | ||
verse = chapter.verses.find(params[:verse_id]) | ||
tafsirs = verse.tafsirs.where(resource_content_id: params[:tafsirs]) | ||
|
||
tafsirs = @verse.tafsirs | ||
|
||
if tafirs_filter.present? | ||
tafsirs = tafsirs.where(resource_content_id: tafirs_filter) | ||
end | ||
|
||
render json: tafsirs | ||
end | ||
|
||
protected | ||
|
||
def chapter | ||
Chapter.find(params[:chapter_id]) | ||
end | ||
|
||
def set_verse | ||
@verse = chapter.verses.find_by_id_or_key(params[:verse_id]) | ||
end | ||
|
||
def tafirs_filter | ||
return nil unless params[:tafsirs].present? | ||
|
||
ResourceContent.where(id: params[:tafsirs]) | ||
.or(ResourceContent.where(slug: tafsirs)) | ||
.pluck(:id) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
if Rails.env.production? | ||
Raven.configure do |config| | ||
config.dsn = ENV['SENTRY_DSN'] | ||
config.environments = ['staging', 'production'] | ||
end | ||
Raven.configure do |config| | ||
config.dsn = ENV['SENTRY_DSN'] | ||
config.environments = ['staging', 'production'] | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AddVerseKeyToTafsirs < ActiveRecord::Migration[5.0] | ||
def change | ||
add_column :tafsirs, :verse_key, :string | ||
add_index :tafsirs, :verse_key | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace :one_time do | ||
task fix_tafsir: :environment do | ||
Tafsir.includes(:verse).each do |tafsir| | ||
tafsir.update_attribute :verse_key, tafsir.verse.verse_key | ||
end | ||
end | ||
end |