Compare commits
5 commits
9a3cad4293
...
3682572001
| Author | SHA1 | Date | |
|---|---|---|---|
| 3682572001 | |||
| 3c707d39ec | |||
| b7048dc565 | |||
| b4cc42db2c | |||
| a91b52ea83 |
2 changed files with 17 additions and 17 deletions
|
|
@ -52,7 +52,7 @@ class FicTracker::Cli::Story < Thor
|
||||||
}.compact
|
}.compact
|
||||||
found = FicTracker::Models::Story.where(**search)
|
found = FicTracker::Models::Story.where(**search)
|
||||||
|
|
||||||
if found.size > 1 && !story.start_with?('*/')
|
if found.count > 1 && !story.start_with?('*/')
|
||||||
puts "Found multiple potential stories for #{story}, please specify which ones to remove using the syntax <backend>/<story>: (use */<story> to remove all)"
|
puts "Found multiple potential stories for #{story}, please specify which ones to remove using the syntax <backend>/<story>: (use */<story> to remove all)"
|
||||||
found.each do |f|
|
found.each do |f|
|
||||||
puts " - #{f.backend_name}/#{f.slug} - #{f}"
|
puts " - #{f.backend_name}/#{f.slug} - #{f}"
|
||||||
|
|
@ -69,9 +69,9 @@ class FicTracker::Cli::Story < Thor
|
||||||
desc 'list', 'List all tracked stories'
|
desc 'list', 'List all tracked stories'
|
||||||
def list
|
def list
|
||||||
setup!
|
setup!
|
||||||
info = [['Story', 'Chapters', 'Completed', 'Last Updated'], ['-----','--------','---------','------------']]
|
info = [['Slug', 'Story', 'Chapters', 'Completed', 'Last Updated'], ['----','-----','--------','---------','------------']]
|
||||||
FicTracker::Models::Story.order_by(:name).each do |story|
|
FicTracker::Models::Story.order_by(:name).each do |story|
|
||||||
info << [story.name, story.chapters.size, story.completed?, (story.updated_at || story.published_at).strftime("%F")]
|
info << [story.slug, story.name, story.chapters.size, story.completed?, (story.updated_at || story.published_at).strftime("%F")]
|
||||||
end
|
end
|
||||||
print_table info
|
print_table info
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -155,9 +155,8 @@ module FicTracker::Models
|
||||||
def ensure_fully_loaded
|
def ensure_fully_loaded
|
||||||
return backend.load_full_story(self) unless id
|
return backend.load_full_story(self) unless id
|
||||||
|
|
||||||
refresh_content
|
refresh_content(splay: true)
|
||||||
refresh_metadata
|
refresh_metadata(splay: true)
|
||||||
apply_splay!
|
|
||||||
|
|
||||||
full_load = true
|
full_load = true
|
||||||
if chapters && chapters.size > 0
|
if chapters && chapters.size > 0
|
||||||
|
|
@ -208,8 +207,11 @@ module FicTracker::Models
|
||||||
[backend_name, slug, name].join('_').downcase.gsub(/[^[[:alnum:]]-_]/, '_').gsub(/__+/, '_').gsub(/^_|_$/, '')
|
[backend_name, slug, name].join('_').downcase.gsub(/[^[[:alnum:]]-_]/, '_').gsub(/__+/, '_').gsub(/^_|_$/, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
def refresh_metadata
|
def refresh_metadata(splay: false)
|
||||||
refresh_metadata! if backend && needs_metadata_refresh?
|
return unless backend && needs_metadata_refresh?
|
||||||
|
|
||||||
|
self.last_metadata_refresh += rand(-3600..3600) * 24 if splay
|
||||||
|
refresh_metadata!
|
||||||
end
|
end
|
||||||
|
|
||||||
def refresh_metadata!
|
def refresh_metadata!
|
||||||
|
|
@ -217,8 +219,11 @@ module FicTracker::Models
|
||||||
backend.load_story(self)
|
backend.load_story(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
def refresh_content
|
def refresh_content(splay: false)
|
||||||
refresh_content! if backend && needs_content_refresh?
|
return unless backend && needs_content_refresh?
|
||||||
|
|
||||||
|
self.last_content_refresh += rand(-3600..3600) if splay
|
||||||
|
refresh_content!
|
||||||
# chapters.each(&:refresh_content)
|
# chapters.each(&:refresh_content)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -228,11 +233,6 @@ module FicTracker::Models
|
||||||
# chapters.each(&:refresh_content!)
|
# chapters.each(&:refresh_content!)
|
||||||
end
|
end
|
||||||
|
|
||||||
def apply_splay!(max: CONTENT_REFRESH_INTERVAL / 10)
|
|
||||||
self.last_metadata_refresh += rand(0..max)
|
|
||||||
self.last_content_refresh += rand(0..max)
|
|
||||||
end
|
|
||||||
|
|
||||||
def needs_metadata_refresh?
|
def needs_metadata_refresh?
|
||||||
# return true if id && authors.empty?
|
# return true if id && authors.empty?
|
||||||
|
|
||||||
|
|
@ -240,7 +240,7 @@ module FicTracker::Models
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.needing_metadata_refresh
|
def self.needing_metadata_refresh
|
||||||
where { Sequel.|(last_metadata_refresh.nil?, last_metadata_refresh < date.function(Time.now - METADATA_REFRESH_INTERVAL, 'localtime')) }
|
where { Sequel.|({ last_metadata_refresh: nil }, last_metadata_refresh < date.function(Time.now - METADATA_REFRESH_INTERVAL, 'localtime')) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def needs_content_refresh?
|
def needs_content_refresh?
|
||||||
|
|
@ -248,7 +248,7 @@ module FicTracker::Models
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.needing_content_refresh
|
def self.needing_content_refresh
|
||||||
where { Sequel.|(last_content_refresh.nil?, last_content_refresh < date.function(Time.now - (completed? ? METADATA_REFRESH_INTERVAL : CONTENT_REFRESH_INTERVAL), 'localtime')) }
|
where { Sequel.|({ last_content_refresh: nil }, last_content_refresh < date.function(Time.now - CONTENT_REFRESH_INTERVAL, 'localtime')) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue