<commit_before>require 'slack-api-wrapper'
require 'logger'

module Slackpolice
  class Client
    def initialize(cli_options = {})
      @cli_options = cli_options
      @logger ||= Logger.new STDOUT

      @client = Slack::Client.new @cli_options[:api_token]
      @client.auth_test
    end

    def archive
      archives = []
      no_members_channels.each do |c|
        resp = @client.channels_archive('channel' => c['id'])
        archives << c if resp['ok']
      end
    end

    def no_members_channels
      @client.channels_list['channels'].select do |c|
        c['num_members'] == 0 && c['is_archived'] == false
      end
    end
  end
end<commit_msg>feat(expired_files): add expired_files method<commit_after>require 'slack-api-wrapper'
require 'logger'
require 'date'

module Slackpolice
  class Client
    def initialize(cli_options = {})
      @cli_options = cli_options
      @logger ||= Logger.new STDOUT

      @client = Slack::Client.new @cli_options[:api_token]
      @client.auth_test
    end

    def archive
      archives = []
      no_members_channels.each do |c|
        resp = @client.channels_archive('channel' => c['id'])
        archives << c if resp['ok']
      end
    end

    def delete_expired_files
      deleted_files = []

    end

    def no_members_channels
      @client.channels_list['channels'].select do |c|
        c['num_members'] == 0 && c['is_archived'] == false
      end
    end

    def expired_files(ts_to = Date.today.prev_day(7))
      page = 1
      Enumerator.new do |y|
        begin
          resp = @client.files_list('ts_to' => ts_to.to_time.to_i, 'page' => page)
          if resp['ok']
            pages = resp['paging']['pages']
            resp['files'].map do |file|
              y << file
            end
          end
          page += 1
        end while pages > page || 100 > page # over 100 page is not found. api bug?
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11770833333333333, 'fraction_numerical': 0.005729166666666666, 'mean_word_length': 2.3006872852233675, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '4479811', 'n_tokens_mistral': 625, 'n_tokens_neox': 603, 'n_words': 147}