From bdb2491ae795a064c0c7d2b6974db79b03c4a8c4 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Mon, 3 Jul 2017 18:19:11 -0700 Subject: [PATCH] define more relations, add separate column for marking m1/m2 as complete --- app/Team.php | 4 +++ app/Tweet.php | 14 +++++++- .../2017_07_04_010640_mark_complete.php | 34 +++++++++++++++++++ resources/assets/js/components/Scorecard.vue | 8 +++-- 4 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 database/migrations/2017_07_04_010640_mark_complete.php diff --git a/app/Team.php b/app/Team.php index 744f067..1d7622f 100644 --- a/app/Team.php +++ b/app/Team.php @@ -13,4 +13,8 @@ class Team extends Model public function players() { return $this->hasMany('App\Player'); } + + public function tweets() { + return $this->hasMany('App\Tweet'); + } } diff --git a/app/Tweet.php b/app/Tweet.php index e6b4bd7..4af9474 100644 --- a/app/Tweet.php +++ b/app/Tweet.php @@ -27,10 +27,22 @@ class Tweet extends Model 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() { // time out tweets if they aren't processed after the specified time $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) { $tweet->claimed_at = null; $tweet->save(); diff --git a/database/migrations/2017_07_04_010640_mark_complete.php b/database/migrations/2017_07_04_010640_mark_complete.php new file mode 100644 index 0000000..abda652 --- /dev/null +++ b/database/migrations/2017_07_04_010640_mark_complete.php @@ -0,0 +1,34 @@ +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'); + }); + } +} diff --git a/resources/assets/js/components/Scorecard.vue b/resources/assets/js/components/Scorecard.vue index 2f159ef..defe2b8 100644 --- a/resources/assets/js/components/Scorecard.vue +++ b/resources/assets/js/components/Scorecard.vue @@ -234,25 +234,27 @@ module.exports = { switch(this.tweet.mission_id) { case 1: + score_data['m1_complete'] = 1; score_data['m1_transit_line_id'] = this.selectedTransitLine; score_data['m1_non_trimet'] = this.selectedNonTrimetLine; break; case 2: + score_data['m2_complete'] = this.selectedTransitCenter ? 1 : 0; score_data['m2_transit_center_id'] = this.selectedTransitCenter; score_data['m2_with_other_team'] = this.selectedPhotoHasAnotherTeam ? 1 : 0; break; case 3: - score_data['m3_complete'] = true ? 1 : 0; + score_data['m3_complete'] = 1; break; case 4: - score_data['m4_complete'] = true ? 1 : 0; + score_data['m4_complete'] = 1; break; case 5: score_data['m5_complete'] = this.selectedM5Singing ? 1 : 0; score_data['m5_tip'] = this.selectedM5Tipping ? 1 : 0; break; case 6: - score_data['m6_complete'] = true ? 1 : 0; + score_data['m6_complete'] = 1; break; case 7: score_data['m7_document_id'] = this.selectedDocument;