Skip to content

Commit

Permalink
Merge pull request #2464 from alphagov/remove-tasks-and-scripts-that-…
Browse files Browse the repository at this point in the history
…require-writeable-filesystem

Remove tasks and scripts that require a writeable filesystem
  • Loading branch information
floehopper authored Oct 26, 2023
2 parents 88ab8c5 + c6d8154 commit 4c817aa
Show file tree
Hide file tree
Showing 17 changed files with 0 additions and 850 deletions.
57 changes: 0 additions & 57 deletions app/presenters/event_log_presenter.rb

This file was deleted.

61 changes: 0 additions & 61 deletions app/presenters/usage_presenter.rb

This file was deleted.

90 changes: 0 additions & 90 deletions lib/numbers/metrics.rb

This file was deleted.

24 changes: 0 additions & 24 deletions lib/numbers/numbers_csv.rb

This file was deleted.

36 changes: 0 additions & 36 deletions lib/numbers/user_segments.rb

This file was deleted.

12 changes: 0 additions & 12 deletions lib/tasks/event_log.rake
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
namespace :event_log do
desc "Export the event log as a CSV"
task :export, %i[min_id max_id] => :environment do |_, args|
usage_message = "usage: rake event_log:export[<min_id>, <max_id>]".freeze
abort usage_message unless args[:min_id] && args[:max_id]

ENV["GOVUK_APP_ROOT"] ||= Rails.root
path = File.join(ENV["GOVUK_APP_ROOT"], "reports")
EventLogPresenter.new(min_id, max_id).write_csv(path)

puts "Report successfully generated inside #{path}"
end

desc "Delete all events in the event log older than 2 years"
task delete_logs_older_than_two_years: :environment do
delete_count = EventLog.where("created_at < ?", 2.years.ago).delete_all
Expand Down
19 changes: 0 additions & 19 deletions lib/tasks/export_usage_stats.rake

This file was deleted.

6 changes: 0 additions & 6 deletions lib/tasks/numbers.rake

This file was deleted.

39 changes: 0 additions & 39 deletions lib/tasks/users.rake
Original file line number Diff line number Diff line change
Expand Up @@ -51,45 +51,6 @@ namespace :users do
User.find_each { |user| PermissionUpdater.perform_on(user) }
end

desc "Exports user permissions by application(s) in csv format"
task export_permissions: :environment do
raise "Requires ENV variable EXPORT_DIR to be set to a valid directory path" if ENV["EXPORT_DIR"].blank?
raise "Requires ENV variable APPLICATIONS to be set to a string containing comma-separated application names" if ENV["APPLICATIONS"].blank?

application_names = ENV["APPLICATIONS"].split(",").map(&:strip).map(&:titleize)
UserPermissionsExporter.new(ENV["EXPORT_DIR"], Logger.new($stdout)).export(application_names)
end

desc "Exports user roles in csv format"
task export_roles: :environment do
raise "Requires ENV variable EXPORT_DIR to be set to a valid directory path" if ENV["EXPORT_DIR"].blank?

UserPermissionsExporter.new(ENV["EXPORT_DIR"], Logger.new($stdout)).export_signon
end

desc "Exports users which have been auto-suspended since the given date, and details of their unsuspension"
task export_auto_suspended_users: :environment do
raise "Requires ENV variable EXPORT_DIR to be set to a valid directory path" if ENV["EXPORT_DIR"].blank?

if ENV["DATE"].blank?
raise "Requires ENV variable USERS_SINCE to be set to a valid date" if ENV["USERS_SINCE"].blank?

users_since_date = Date.parse(ENV["USERS_SINCE"])

raise "Requires ENV variable SUSPENSIONS_SINCE to be set to a valid date" if ENV["SUSPENSIONS_SINCE"].blank?

suspensions_since_date = Date.parse(ENV["SUSPENSIONS_SINCE"])
else
users_since_date = Date.parse(ENV["DATE"])
suspensions_since_date = Date.parse(ENV["DATE"])
end

raise "Requires ENV variable USERS_SINCE to be set to a valid date" unless users_since_date
raise "Requires ENV variable SUSPENSIONS_SINCE to be set to a valid date" unless suspensions_since_date

UserSuspensionsExporter.call(ENV["EXPORT_DIR"], users_since_date, suspensions_since_date, Logger.new($stdout))
end

desc "Grant all active and suspended users access to an application, who don't have access"
task :grant_application_access, [:application] => :environment do |_t, args|
application = Doorkeeper::Application.find_by(name: args.application)
Expand Down
Loading

0 comments on commit 4c817aa

Please sign in to comment.