<commit_before>module PgDrive
  module Uploader
    Drive = Google::Apis::DriveV2
    AUTH_SCOPE = "https://www.googleapis.com/auth/drive".freeze
    RETRY_COUNT = 3

    class << self
      def call(content)
        drive = Drive::DriveService.new
        drive.authorization = credentials
        app_name = Rails.application.class.parent_name
        drive.insert_file(
          Drive::File.new(title: "backup-#{app_name}-#{Time.now.to_i}"),
          upload_source: gzip(content),
          content_type: GZIP_MIME_TYPE,
          options: { retries: RETRY_COUNT }
        )
      end

      def gzip(string)
        gzipped_io = StringIO.new
        writer = Zlib::GzipWriter.new(gzipped_io)
        writer.write(string)
        writer.close
        StringIO.new(gzipped_io.string)
      end

      def client_id
        Google::Auth::ClientId.new(google_key, google_secret)
      end

      def google_key
        ENV.fetch("PG_DRIVE_GOOGLE_KEY")
      end<commit_msg>Change timestamp to be human readable<commit_after>module PgDrive
  module Uploader
    Drive = Google::Apis::DriveV2
    AUTH_SCOPE = "https://www.googleapis.com/auth/drive".freeze
    RETRY_COUNT = 3

    class << self
      def call(content)
        drive = Drive::DriveService.new
        drive.authorization = credentials
        app_name = Rails.application.class.parent_name
        drive.insert_file(
          Drive::File.new(title: "backup-#{app_name}-#{Time.now.utc.iso8601}"),
          upload_source: gzip(content),
          content_type: GZIP_MIME_TYPE,
          options: { retries: RETRY_COUNT }
        )
      end

      def gzip(string)
        gzipped_io = StringIO.new
        writer = Zlib::GzipWriter.new(gzipped_io)
        writer.write(string)
        writer.close
        StringIO.new(gzipped_io.string)
      end

      def client_id
        Google::Auth::ClientId.new(google_key, google_secret)
      end

      def google_key
        ENV.fetch("PG_DRIVE_GOOGLE_KEY")
      end
{'fraction_non_alphanumeric': 0.09843513377082282, 'fraction_numerical': 0.004038364462392731, 'mean_word_length': 2.342327150084317, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '2193251', 'n_tokens_mistral': 652, 'n_tokens_neox': 624, 'n_words': 104}