-
-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add task(s) to visualize element and page usage
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
namespace :alchemy do | ||
desc "List Alchemy elements and pages usage" | ||
task usage: [:page_usage, :element_usage] | ||
|
||
desc "List Alchemy elements usage" | ||
task page_usage: :environment do | ||
include ActionView::Helpers::NumberHelper | ||
puts "\n Alchemy pages usage" | ||
puts " ----------------------" | ||
puts "\n" | ||
results = ActiveRecord::Base.connection.execute("SELECT page_layout, COUNT(*) AS count FROM alchemy_pages GROUP BY page_layout ORDER BY count DESC") | ||
if results.any? | ||
results.each do |row| | ||
puts " #{number_with_delimiter(row["count"])} 𝗑 #{row["page_layout"]}" | ||
end | ||
puts "\n = #{number_with_delimiter(Alchemy::Page.count)} pages in total." | ||
else | ||
puts " No pages found!" | ||
end | ||
end | ||
|
||
desc "List Alchemy elements usage" | ||
task element_usage: :environment do | ||
include ActionView::Helpers::NumberHelper | ||
puts "\n Alchemy elements usage" | ||
puts " ----------------------" | ||
puts "\n" | ||
results = ActiveRecord::Base.connection.execute("SELECT name, COUNT(*) AS count FROM alchemy_elements GROUP BY name ORDER BY count DESC") | ||
if results.any? | ||
results.each do |row| | ||
puts " #{number_with_delimiter(row["count"])} 𝗑 #{row["name"]}" | ||
end | ||
puts "\n = #{number_with_delimiter(Alchemy::Element.count)} elements in total." | ||
else | ||
puts " No elements found!" | ||
end | ||
end | ||
end |