From 536b38a27f5ca16e40eb3de4d1fd8e6f1d25e924 Mon Sep 17 00:00:00 2001 From: horus Date: Mon, 3 Jan 2022 14:55:31 +0100 Subject: Adding new users should be async. (Does not work yet.) --- app/Http/Controllers/IndexController.php | 41 ++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'app/Http/Controllers/IndexController.php') diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php index d9e792a..c595b4e 100644 --- a/app/Http/Controllers/IndexController.php +++ b/app/Http/Controllers/IndexController.php @@ -11,6 +11,9 @@ use App\AnimeStats; use App\MALUser; use App\Libraries\Helper; +use App\Jobs\AddNewCalUser; +use Imtigger\LaravelJobStatus\JobStatus; + class IndexController extends Controller { /** * Shows the index page. @@ -81,10 +84,12 @@ class IndexController extends Controller { echo "OK"; } - public function createUser( $username ) { + public function _createUser( $username ) { $helper = new Helper(); $helper->createUser( $username ); - $helper->setIsWatching( $username ); + if ( false === $helper->setIsWatching( $username ) ) { + echo "not ok"; return; + } $helper->setCalendar( $username ); echo "OK. https://animes.iamfabulous.de/ical/" . $username; return; @@ -103,4 +108,36 @@ class IndexController extends Controller { echo $user->get(); } + + public function createUser( $username ) { + + $job = new AddNewCalUser( $username ); + #$job = AddNewCalUser::create(); + $id = $job::dispatch( $username ); + + echo "
";
+ #var_dump($job->id);
+ var_dump($job);
+ var_dump($id);
+ #$jobStatusId = $job->getJobStatusId();
+ #echo "https://anistats.com/status/" . $jobStatusId;
+ }
+
+ public function showJobStatus( $jobStatusId ) {
+ $jobStatus = JobStatus::find($jobStatusId);
+
+ echo "";
+ /*
+ while ( "queued" == $jobStatus->status || "executing" == $jobStatus->status ) {
+ echo $jobStatus->status;
+ echo "";
+ $jobStatus = JobStatus::find($jobStatusId);
+ sleep(1);
+ }
+ */
+
+ var_dump($jobStatus);
+ var_dump($jobStatus->output);
+
+ }
}
--
cgit v1.2.3