<commit_before>import fetch from 'node-fetch';
import _ from 'lodash'; 

import config from '../config/configuration';

export default class YandexDiskApi {
    constructor(oAuthToken) {
        if (!oAuthToken) {
            throw new Error('There is no OAuth token for Yandex');
        }
        this._oAuthToken = oAuthToken;
        this._getHeaders = () => {
            return {
                "Authorization": `OAuth ${this._oAuthToken}`
            }
        };
        this._get = (url) => {
            return fetch(url, {
                "headers": this._getHeaders()
            })
        }
    }

    async getImagePreviews(limit = 12, offset = 0) {
        try {
            const data = await this._get(`${config.yandexDiskApiUrl}?path=${encodeURI(config.yandexDiskFolder)}&limit=${limit}&offset=${offset}`);

            const jsonData = await data.json();

            const embedded = jsonData._embedded;

            return {
                "items": _(embedded.items || []).filter(i => i.type === 'file').value(),
                "limit": embedded.limit,
                "offset": embedded.offset,
                "total": embedded.total
            };
        } catch(err) {
            console.log("Can't get preview data: " + err);
        }
    }

    async getImagePreview(fileName) {<commit_msg>Increase size of preview images<commit_after>import fetch from 'node-fetch';
import _ from 'lodash'; 

import config from '../config/configuration';

export default class YandexDiskApi {
    constructor(oAuthToken) {
        if (!oAuthToken) {
            throw new Error('There is no OAuth token for Yandex');
        }
        this._oAuthToken = oAuthToken;
        this._getHeaders = () => {
            return {
                "Authorization": `OAuth ${this._oAuthToken}`
            }
        };
        this._get = (url) => {
            return fetch(url, {
                "headers": this._getHeaders()
            })
        }
    }

    async getImagePreviews(limit = 12, offset = 0) {
        try {
            const data = await this._get(`${config.yandexDiskApiUrl}?path=${encodeURI(config.yandexDiskFolder)}&limit=${limit}&offset=${offset}&preview_size=x190`);

            const jsonData = await data.json();

            const embedded = jsonData._embedded;

            return {
                "items": _(embedded.items || []).filter(i => i.type === 'file').value(),
                "limit": embedded.limit,
                "offset": embedded.offset,
                "total": embedded.total
            };
        } catch(err) {
            console.log("Can't get preview data: " + err);
        }
    }

    async getImagePreview(fileName) {
{'fraction_non_alphanumeric': 0.13338301043219075, 'fraction_numerical': 0.0033532041728763042, 'mean_word_length': 1.8174186778593915, 'pattern_counts': {'":': 12, '<': 3, '<?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': '3598610', 'n_tokens_mistral': 757, 'n_tokens_neox': 721, 'n_words': 158}