<commit_before>namespace :permissions do    
    desc "Restore admin permissions"
    task :give, [:user] => :environment do |task, args|
        begin
            user = User.find_by_email(args.user + '@d.umn.edu')
            user.admin = true
            user.save
            print "user " + args.user + " given admin permissions.\n"
        rescue
            print "user " + args.user + " doesn't exist!\n"
        end
    end

    desc "Revoke admin permissions"
    task :revoke, [:user] => :environment do |task, args|
        begin
            user = User.find_by_email(args.user + '@d.umn.edu')
            user.admin = false
            user.save
            print "user " + args.user + " revoked admin permissions.\n"
        rescue
            print "user " + args.user + " doesn't exist!\n"
        end
    end
end<commit_msg>Clean up permissions rake task<commit_after>namespace :permissions do    
    desc "Restore admin permissions"
    task :give, [:user] => :environment do |task, args|
        set_admin(args.user, true)
    end

    desc "Revoke admin permissions"
    task :revoke, [:user] => :environment do |task, args|
        set_admin(args.user, false)
    end
    
    def set_admin(email, is_admin)
        begin
            user = User.find_by(email: email)
            user.admin = is_admin
            user.save!
            puts email + " is admin: " + is_admin.to_s
        rescue Exception => e
            puts e
        end
    end
end
{'fraction_non_alphanumeric': 0.1044776119402985, 'fraction_numerical': 0.0, 'mean_word_length': 1.8095238095238095, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2102837', 'n_tokens_mistral': 436, 'n_tokens_neox': 433, 'n_words': 125}