Skip to content

Commit

Permalink
use jpeg images in oligrapher overview page
Browse files Browse the repository at this point in the history
  • Loading branch information
aepyornis committed Dec 3, 2021
1 parent 2321c52 commit 1e7eddc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/models/network_map.rb
Expand Up @@ -92,7 +92,7 @@ def documents_to_html
end

def screenshot_path
Rails.root.join('public/images/oligrapher', "#{id}.png")
Rails.root.join('public/images/oligrapher', "#{id}.jpeg")
end

def screenshot_exists?
Expand Down Expand Up @@ -289,7 +289,7 @@ def self.index_maps
featured.limit(200).filter(&:screenshot_exists?).map do |m|
{
id: m.id,
screenshot: "/images/oligrapher/#{m.id}.png",
screenshot: "/images/oligrapher/#{m.id}.jpeg",
url: m.url,
title: m.name
}
Expand Down
15 changes: 9 additions & 6 deletions lib/tasks/maps.rake
Expand Up @@ -3,24 +3,27 @@
namespace :maps do
namespace :screenshot do
desc 'create screenshots for all maps missing thumbnails'
task missing: :environment do
task :missing, [:force] => :environment do |_t, args|
args.with_defaults(force: false)
NetworkMap.where(is_private: false).order(updated_at: :desc).find_each(batch_size: 100) do |map|
map.take_screenshot unless map.screenshot_exists?
if args[:force] || !map.screenshot_exists?
map.take_screenshot
end
end
end

desc 're-take screenshots for all featured thumbnails'
task featured: :environment do
NetworkMap.featured.each do |map|
ColorPrinter.print_blue "Taking Screenshot for #{map.to_param}"
map.take_screenshot # unless map.screenshot_exists?
map.take_screenshot
end
end

desc 'create screenshots for maps updated in the past X hours'
task :recent, [:hours] => :environment do |_t, args|
hours = args[:hours].nil? ? 25 : args[:hours].to_i

NetworkMap.where('updated_at > ?', hours.hours.ago).each(&:take_screenshot)
args.with_defaults(hours: 25)
NetworkMap.where('updated_at > ?', hours.to_i.hours.ago).each(&:take_screenshot)
end
end

Expand Down

0 comments on commit 1e7eddc

Please sign in to comment.