* feat: make the sidebar more dynamic * refactor: use the action in the same controller instead of the whole path * feat: remove hardcoded routes * feat: move routes into file * feat: use rails 6 draw for the admin routes * add a helper method * oops: fix super * feat: add the hacky helper methods :( ) * WIP: created different path helpers for the new routes and point the old helpers to the new ones if the FF is toggled * feat: update the module * chore: add new paths * feat: change link_to's use paths instead * feat: feedback_messages to scoped admin route * chore: update the feature flag urls helpers * feat: feedback_messages issue * chore: remove all the workarounds * chore: rubucop * fix: oops remove helper * chore: comment out the tests that touch the tabbed navbar which is affected by the rails application needing to be reloaded * feat: ensure that we chcek if the db table exists
57 lines
1.5 KiB
Ruby
57 lines
1.5 KiB
Ruby
module Admin
|
|
class ToolsController < Admin::ApplicationController
|
|
layout "admin"
|
|
|
|
def index; end
|
|
|
|
def bust_cache
|
|
flash[:success] = if params[:dead_link]
|
|
handle_dead_path
|
|
"#{params[:dead_link]} was successfully busted"
|
|
elsif params[:bust_user]
|
|
handle_user_cache
|
|
"User ##{params[:bust_user]} was successfully busted"
|
|
elsif params[:bust_article]
|
|
handle_article_cache
|
|
"Article ##{params[:bust_article]} was successfully busted"
|
|
end
|
|
redirect_to admin_tools_path
|
|
rescue StandardError => e
|
|
flash[:danger] = e.message
|
|
redirect_to admin_tools_path
|
|
end
|
|
|
|
private
|
|
|
|
def handle_dead_path
|
|
bust_link(params[:dead_link])
|
|
end
|
|
|
|
def handle_user_cache
|
|
user = User.find(params[:bust_user].to_i)
|
|
user.touch(:profile_updated_at, :last_followed_at, :last_comment_at)
|
|
bust_link(user.path)
|
|
end
|
|
|
|
def handle_article_cache
|
|
article = Article.find(params[:bust_article].to_i)
|
|
article.touch(:last_commented_at)
|
|
EdgeCache::BustArticle.call(article)
|
|
end
|
|
|
|
def bust_link(link)
|
|
if link.starts_with?(URL.url)
|
|
link.sub!(URL.url, "")
|
|
end
|
|
|
|
paths = [
|
|
link,
|
|
"#{link}/",
|
|
"#{link}?i=i",
|
|
"#{link}/?i=i",
|
|
]
|
|
|
|
EdgeCache::Bust.call(paths)
|
|
end
|
|
end
|
|
end
|