Browse Source

define more relations, add separate column for marking m1/m2 as complete

master
Aaron Parecki 7 years ago
parent
commit
bdb2491ae7
No known key found for this signature in database GPG Key ID: 276C2817346D6056
4 changed files with 56 additions and 4 deletions
  1. +4
    -0
      app/Team.php
  2. +13
    -1
      app/Tweet.php
  3. +34
    -0
      database/migrations/2017_07_04_010640_mark_complete.php
  4. +5
    -3
      resources/assets/js/components/Scorecard.vue

+ 4
- 0
app/Team.php View File

@ -13,4 +13,8 @@ class Team extends Model
public function players() { public function players() {
return $this->hasMany('App\Player'); return $this->hasMany('App\Player');
} }
public function tweets() {
return $this->hasMany('App\Tweet');
}
} }

+ 13
- 1
app/Tweet.php View File

@ -27,10 +27,22 @@ class Tweet extends Model
return $this->belongsTo('\App\Mission'); return $this->belongsTo('\App\Mission');
} }
public function transit_line() {
return $this->belongsTo('\App\TransitLine', 'm1_transit_line_id');
}
public function transit_center() {
return $this->belongsTo('\App\TransitCenter', 'm2_transit_center_id');
}
public function document() {
return $this->belongsTo('\App\Document', 'm7_document_id');
}
public static function claimed_timeout() { public static function claimed_timeout() {
// time out tweets if they aren't processed after the specified time // time out tweets if they aren't processed after the specified time
$timeout = 520; $timeout = 520;
$tweets = Tweet::where('claimed_at', '<', date('Y-m-d H:i:s', time()-$timeout))->get();
$tweets = Tweet::where('claimed_at', '<', date('Y-m-d H:i:s', time()-$timeout))->where('processed', 0)->get();
foreach($tweets as $tweet) { foreach($tweets as $tweet) {
$tweet->claimed_at = null; $tweet->claimed_at = null;
$tweet->save(); $tweet->save();

+ 34
- 0
database/migrations/2017_07_04_010640_mark_complete.php View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class MarkComplete extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('tweets', function (Blueprint $table) {
$table->boolean('m1_complete')->nullable();
$table->boolean('m2_complete')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('tweets', function (Blueprint $table) {
$table->dropColumn('m1_complete');
$table->dropColumn('m2_complete');
});
}
}

+ 5
- 3
resources/assets/js/components/Scorecard.vue View File

@ -234,25 +234,27 @@ module.exports = {
switch(this.tweet.mission_id) { switch(this.tweet.mission_id) {
case 1: case 1:
score_data['m1_complete'] = 1;
score_data['m1_transit_line_id'] = this.selectedTransitLine; score_data['m1_transit_line_id'] = this.selectedTransitLine;
score_data['m1_non_trimet'] = this.selectedNonTrimetLine; score_data['m1_non_trimet'] = this.selectedNonTrimetLine;
break; break;
case 2: case 2:
score_data['m2_complete'] = this.selectedTransitCenter ? 1 : 0;
score_data['m2_transit_center_id'] = this.selectedTransitCenter; score_data['m2_transit_center_id'] = this.selectedTransitCenter;
score_data['m2_with_other_team'] = this.selectedPhotoHasAnotherTeam ? 1 : 0; score_data['m2_with_other_team'] = this.selectedPhotoHasAnotherTeam ? 1 : 0;
break; break;
case 3: case 3:
score_data['m3_complete'] = true ? 1 : 0;
score_data['m3_complete'] = 1;
break; break;
case 4: case 4:
score_data['m4_complete'] = true ? 1 : 0;
score_data['m4_complete'] = 1;
break; break;
case 5: case 5:
score_data['m5_complete'] = this.selectedM5Singing ? 1 : 0; score_data['m5_complete'] = this.selectedM5Singing ? 1 : 0;
score_data['m5_tip'] = this.selectedM5Tipping ? 1 : 0; score_data['m5_tip'] = this.selectedM5Tipping ? 1 : 0;
break; break;
case 6: case 6:
score_data['m6_complete'] = true ? 1 : 0;
score_data['m6_complete'] = 1;
break; break;
case 7: case 7:
score_data['m7_document_id'] = this.selectedDocument; score_data['m7_document_id'] = this.selectedDocument;

Loading…
Cancel
Save