Added Scheduling
All checks were successful
Push image to registry / build-image (push) Successful in 4m20s
All checks were successful
Push image to registry / build-image (push) Successful in 4m20s
This commit is contained in:
@ -2,29 +2,29 @@
|
||||
|
||||
namespace App\Browser;
|
||||
|
||||
use App\Browser\JobArtifacts\JobRunArtifact;
|
||||
use App\Exception\JobException;
|
||||
use App\Models\JobArtifact;
|
||||
use App\Models\JobRun;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Facebook\WebDriver\Chrome\ChromeOptions;
|
||||
use Facebook\WebDriver\Remote\DesiredCapabilities;
|
||||
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
||||
use Facebook\WebDriver\Remote\RemoteWebElement;
|
||||
use Facebook\WebDriver\WebDriverBy;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Laravel\Dusk\Browser;
|
||||
use Laravel\Dusk\TestCase as BaseTestCase;
|
||||
use Closure;
|
||||
use PHPUnit\Framework\Attributes\BeforeClass;
|
||||
use Exception;
|
||||
use Laravel\Dusk\Chrome\SupportsChrome;
|
||||
use Laravel\Dusk\Concerns\ProvidesBrowser;
|
||||
use Laravel\Dusk;
|
||||
use PHPUnit\Framework\Attributes\BeforeClass;
|
||||
use Throwable;
|
||||
|
||||
abstract class BrowserJob
|
||||
abstract class BrowserJob implements ShouldQueue
|
||||
{
|
||||
use SupportsChrome, ProvidesBrowser;
|
||||
use SupportsChrome, ProvidesBrowser, Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public int $jobId;
|
||||
|
||||
@ -209,8 +209,16 @@ abstract class BrowserJob
|
||||
return "dataTest";
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$this->execute();
|
||||
}
|
||||
|
||||
// BROWSER MACROS
|
||||
|
||||
// === BROWSER MACROS ===
|
||||
protected function waitForAndClickText(Browser $browser, string $text, int $timeout = 30, bool $ignoreCase = true) {
|
||||
$browser->waitForText($text, $timeout, $ignoreCase);
|
||||
$this->findElementContainingText($browser, $text, $ignoreCase)?->click();
|
||||
|
@ -15,6 +15,7 @@ use App\Notification\Notifications\Hellcase\HellcaseNotificationLogin;
|
||||
use App\Notification\Providers\AllNotification;
|
||||
use Dom\XPath;
|
||||
use Facebook\WebDriver\WebDriverBy;
|
||||
use Illuminate\Support\Facades\Schedule;
|
||||
use Laravel\Dusk\Browser;
|
||||
|
||||
class HellcaseJob extends BrowserJob
|
||||
@ -169,23 +170,24 @@ class HellcaseJob extends BrowserJob
|
||||
}
|
||||
|
||||
// If we see "availible in 20 HR 49 MIN", parse the hours and minute and reschedule
|
||||
$availibleInButton = $this->waitForElementContainingTextAndGetIt($browser, "available", 30);
|
||||
if ($availibleInButton != null) {
|
||||
$availibleInButton = $browser->driver->findElement(WebDriverBy::xpath('//button[contains(@class, "daily-free-banner__button")]'));
|
||||
if ($availibleInButton->getAttribute("disabled") == "true") {
|
||||
$hours = $availibleInButton->getText();
|
||||
$hours = explode(" ", $hours);
|
||||
$minutes = $hours[2];
|
||||
$hours = $hours[0];
|
||||
$minutes = $hours[4];
|
||||
$hours = $hours[2];
|
||||
// $this->reschedule($hours);
|
||||
|
||||
$this->jobRun->addArtifact(new JobArtifact([
|
||||
"name" => "Cadeau gratuit pas encore disponible",
|
||||
"content" => "Le cadeau gratuit journalier sera disponible dans $hours heures et $minutes minutes.\nDatboi se fera un plaisir d'aller le chercher pour vous."
|
||||
"content" => "Le cadeau gratuit journalier sera disponible dans {$hours} heures et {$minutes} minutes.\nDatboi se fera un plaisir d'aller le chercher pour vous."
|
||||
]));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->waitForAndClickText($browser, "Get Free Bonus", 30, true);
|
||||
// Click the dailyfree button
|
||||
$availibleInButton->click();
|
||||
|
||||
$lootElement = $browser->driver->findElement(WebDriverBy::xpath('//div[contains(@class, "daily-free-win-bonus")]'));
|
||||
$lootElement->takeElementScreenshot(HellcaseDailyFreeScreenshot::getImgFileAbsolutePath());
|
||||
@ -193,8 +195,6 @@ class HellcaseJob extends BrowserJob
|
||||
AllNotification::send(
|
||||
new HellcaseNotificationDailyFree($this->jobId, new HellcaseNotificationDailyFreeBody())
|
||||
);
|
||||
|
||||
sleep(5000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user