Skip to content

Commit

Permalink
Dumps download page
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtOfCode- committed Jan 12, 2018
1 parent 35c0dc2 commit 90f11d3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,15 @@ def spam_by_site
@posts = @posts.order(id: :desc).paginate(per_page: 50, page: params[:page])
@sites = Site.where(id: @posts.map(&:site_id))
end

def db_dumps
@dumps = Dir.chdir(Rails.root.join('shared', 'dumps')) do
Dir.glob '*.sql.gz'
end
end

def download_dump
@dump = Rails.root.join('shared', 'dumps', params[:filename])
send_file @dump, type: 'application/octet-stream'
end
end
12 changes: 12 additions & 0 deletions app/views/dashboard/db_dumps.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<h3>Database Dumps</h3>
<p>What follows is a list of sanitized metasmoke database dumps. Click a filename to download it.</p>

<table class="table">
<tbody>
<% @dumps.each do |d| %>
<tr>
<td><%= link_to d, download_dump_path(filename: d) %></td>
</tr>
<% end %>
</tbody>
</table>
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<%= nav_link AdminController, label: 'User Data', action: :users %>
<%= nav_link AdminController, label: 'Invalidated Feedback', action: :recently_invalidated %>
<%= nav_link AdminController, label: 'Feedback via API', action: :api_feedback %>
<%= nav_link DashboardController, label: 'Database Dumps', action: :db_dumps %>
<% if current_user.moderator? %>
<%= nav_link StackExchangeUsersController, label: 'Spammers', action: :sites %>
<% end %>
Expand Down
5 changes: 5 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
# Have to have this root route *without* the as: parameter, otherwise we get weirdness like #247
root to: 'dashboard#new_dash'

scope '/dumps' do
root to: 'dashboard#db_dumps', as: :dumps
get 'download', to: 'dashboard#download_dump', as: :download_dump
end

scope '/authentication' do
get 'status', to: 'authentication#status', as: :authentication_status
get 'redirect_target', to: 'authentication#redirect_target'
Expand Down
Empty file.

0 comments on commit 90f11d3

Please sign in to comment.