<?php

use App\Jobs\GetUrlBodyJob;
use App\Models\UrlToCrawl;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Route::get('/scrape', [App\Http\Controllers\Tests\ScraperTestController::class, 'scrape']);

Route::get('/gen', [App\Http\Controllers\Tests\ScraperTestController::class, 'gen']);

Route::get('/backlinks', [App\Http\Controllers\Tests\GeneralTestController::class, 'backlinks']);

Route::get('/process_backlinks', [App\Http\Controllers\Tests\GeneralTestController::class, 'processBacklinks']);

Route::get('/dfs_on_page', [App\Http\Controllers\Tests\GeneralTestController::class, 'onPage']);

Route::get('/dfs-onpage-listid', [App\Http\Controllers\TestOnPageController::class, 'listId']);
Route::get('/dfs-onpage-taskpost', [App\Http\Controllers\TestOnPageController::class, 'taskPost']);

Route::get('/get_domain', function (Request $request) {

    $url_to_crawl = UrlToCrawl::find($request->input('id', null));

    if (is_null($url_to_crawl)) {
        return;
    }

    GetUrlBodyJob::dispatch($url_to_crawl->id)->onQueue('default')->onConnection('default');

    return 'ok';
});

Route::get('/epoch', function () {

    dd(epoch_now_timestamp(1));

});
