|
@ -5,7 +5,7 @@ namespace App\Http\Controllers; |
|
|
use Illuminate\Http\Request; |
|
|
use Illuminate\Http\Request; |
|
|
use Twitter; |
|
|
use Twitter; |
|
|
use App\Tweet; |
|
|
use App\Tweet; |
|
|
use App\Events\NewTweetEvent, App\Events\TweetClaimedEvent; |
|
|
|
|
|
|
|
|
use App\Events\NewTweetEvent, App\Events\TweetClaimedEvent, App\Events\TweetAcceptedEvent; |
|
|
use DB; |
|
|
use DB; |
|
|
|
|
|
|
|
|
class DashboardController extends Controller |
|
|
class DashboardController extends Controller |
|
@ -87,6 +87,9 @@ class DashboardController extends Controller |
|
|
public function score_tweet(Request $request) { |
|
|
public function score_tweet(Request $request) { |
|
|
$tweet = Tweet::where('id', $request->input('tweet_id'))->first(); |
|
|
$tweet = Tweet::where('id', $request->input('tweet_id'))->first(); |
|
|
if($tweet) { |
|
|
if($tweet) { |
|
|
|
|
|
// Calculate the previous mission status before saving this tweet
|
|
|
|
|
|
$previousMissionStatus = $tweet->mission->complete($tweet->team); |
|
|
|
|
|
|
|
|
$tweet->m1_transit_line_id = null; |
|
|
$tweet->m1_transit_line_id = null; |
|
|
$tweet->m1_non_trimet = null; |
|
|
$tweet->m1_non_trimet = null; |
|
|
$tweet->m2_transit_center_id = null; |
|
|
$tweet->m2_transit_center_id = null; |
|
@ -102,6 +105,7 @@ class DashboardController extends Controller |
|
|
} |
|
|
} |
|
|
$tweet->processed = 1; |
|
|
$tweet->processed = 1; |
|
|
$tweet->save(); |
|
|
$tweet->save(); |
|
|
|
|
|
event(new TweetAcceptedEvent($tweet, $previousMissionStatus)); |
|
|
} |
|
|
} |
|
|
return response()->json(['result'=>'ok']); |
|
|
return response()->json(['result'=>'ok']); |
|
|
} |
|
|
} |
|
|