Module: Tracker::PG
- Defined in:
- lib/tracker/p_g.rb,
lib/tracker/p_g/version.rb
Constant Summary collapse
- VERSION =
"0.0.11"
Class Method Summary collapse
- .connection ⇒ Object
- .database_url ⇒ Object
- .database_url=(database_url) ⇒ Object
- .recursive_parent_story_stories_sql(story_id) ⇒ Object
- .reset! ⇒ Object
Class Method Details
.connection ⇒ Object
18 19 20 |
# File 'lib/tracker/p_g.rb', line 18 def self.connection @connection ||= Sequel.connect(database_url) end |
.database_url ⇒ Object
14 15 16 |
# File 'lib/tracker/p_g.rb', line 14 def self.database_url @database_url end |
.database_url=(database_url) ⇒ Object
10 11 12 |
# File 'lib/tracker/p_g.rb', line 10 def self.database_url=(database_url) @database_url = database_url end |
.recursive_parent_story_stories_sql(story_id) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/tracker/p_g.rb', line 27 def self.recursive_parent_story_stories_sql(story_id) <<-SQL WITH RECURSIVE parent_stories(id, parent_story_id, child_story_id) AS ( SELECT id, parent_story_id, child_story_id FROM story_stories WHERE child_story_id = #{story_id} UNION ALL SELECT ss.id, ss.parent_story_id, ss.child_story_id FROM parent_stories ps, story_stories ss WHERE ps.parent_story_id = ss.child_story_id ) SELECT id from parent_stories SQL end |
.reset! ⇒ Object
22 23 24 25 |
# File 'lib/tracker/p_g.rb', line 22 def self.reset! @connection = nil self.database_url = nil end |