<?php
require_once '..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'sqlUtils.php';

global $projectLocalFolder;
$mysqli = sqlCreateConnection("init_mainEng ");
$from_date = strtotime("-10 year", time());
$to_date =  time();

 getUserHistory("876408437814558724", "he", $from_date, $to_date, 1000);
    // fetchThreadDataTwitter($mysqli, 'admin', 20, "posts_20", $projectLocalFolder.'/posts_20', null);
// $path = "C:\\Users\\galar\\OneDrive\\Desktop\\posts_10";
// if ($handle = opendir($path)) {
    
//     while (false !== ($entry = readdir($handle))) {
        
//         if ($entry != "." && $entry != "..") {
//             $full_path = $path.DIRECTORY_SEPARATOR.$entry;
//             $jsonString = file_get_contents($full_path);
//             $data = json_decode($jsonString, true);
            
//             //gets doc id
//             $filename = str_replace('.json', '', $entry);
// //             $sql = "SELECT docid FROM t_id WHERE VALUE=$filename";
//             $sql = "SELECT id FROM files WHERE filename=\"$filename.txt.json\" LIMIT 1";
//             $res = sqlQuery($mysqli, $sql);
//             $obj = $res->fetch_object();
//             $docid = $obj->id;
//             //tag info for document
//             $tag_sql = "SELECT GROUP_CONCAT(DISTINCT NAME) AS tag FROM filetags WHERE docid=$docid AND NAME != 'Reviewed' AND NAME != 'upload_text'";
//             $res = sqlQuery($mysqli, $tag_sql);
//             if(!empty($res)){
//                 $objTag = $res->fetch_object();
//                 $objTagArr = explode(',', $objTag->tag);
//             }
//             $data['intuview_info']['tag'] = $objTagArr;
//             $newJsonString = json_encode($data);
//             file_put_contents($path.DIRECTORY_SEPARATOR.'output'.DIRECTORY_SEPARATOR.$entry, $newJsonString);
//         }
//     }
    
//     closedir($handle);
// }