Browse Source

bonus points for certain documents

master
Aaron Parecki 6 years ago
parent
commit
ffcd75b131
No known key found for this signature in database GPG Key ID: 276C2817346D6056
3 changed files with 57 additions and 10 deletions
  1. +14
    -0
      app/Mission.php
  2. +32
    -0
      database/migrations/2017_07_04_184748_flexible_doc_points.php
  3. +11
    -10
      database/seeds/DocumentSeeder.php

+ 14
- 0
app/Mission.php View File

@ -195,6 +195,11 @@ class Mission extends Model
if($this->complete($team)) {
$score = 50;
// +10 if any of their photos are tipping the bus driver
$num = Tweet::where('team_id', $team->id)->where('m5_complete', 1)->where('m5_tip', 1)->count();
if($num > 0)
$score += 10;
return $score;
} else {
return 0;
@ -207,6 +212,15 @@ class Mission extends Model
if($extra_docs > 0) {
$score += $extra_docs * 5;
}
// add bonus points for certain documents
$tweets = DB::table('tweets')->select('m7_document_id', 'm7_documents.points')
->where('team_id', $team->id)
->join('m7_documents', 'm7_documents.id', '=', 'tweets.m7_document_id')
->whereNotNull('m7_document_id')
->distinct()->get();
foreach($tweets as $tweet) {
$score += $tweet->points;
}
return $score;
} else {
return 0;

+ 32
- 0
database/migrations/2017_07_04_184748_flexible_doc_points.php View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class FlexibleDocPoints extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('m7_documents', function (Blueprint $table) {
$table->integer('points');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('m7_documents', function (Blueprint $table) {
$table->removeColumn('points');
});
}
}

+ 11
- 10
database/seeds/DocumentSeeder.php View File

@ -12,17 +12,18 @@ class DocumentSeeder extends Seeder
public function run()
{
$documents = [
['Fare Inspection', 'Getting the fare inspected but not by a bus driver'],
['Employee Pass', 'Someone using their employer-provided pass to ride TriMet'],
['Purchase at Books with Pictures', 'A receipt for a purchase at Books with Pictures'],
['TriMet Clothing', 'A team member wearing a TriMet-branded item of clothing or gear'],
['Biketown', 'A team member holding up their Biketown card'],
['TriMet High-Five', 'A team member high-fiving a TriMet employee who is wearing official agency clothing'],
['Streetcar Dancing', 'Team members dancing on the Portland Streetcar'],
['Vintage Heavy Rail', 'Your team posing with a vintage heavy-rail train'],
['Public Art', 'Your team posing with a piece of public art'],
['Fare Inspection', 'Getting the fare inspected but not by a bus driver', 5],
['Employee Pass', 'Someone using their employer-provided pass to ride TriMet', 5],
['Purchase at Books with Pictures', 'A receipt for a purchase at Books with Pictures', 5],
['TriMet Clothing', 'A team member wearing a TriMet-branded item of clothing or gear', 5],
['Biketown', 'A team member holding up their Biketown card', 5],
['TriMet High-Five', 'A team member high-fiving a TriMet employee who is wearing official agency clothing', 5],
['Streetcar Dancing', 'Team members dancing on the Portland Streetcar', 5],
['Vintage Heavy Rail', 'Your team posing with a vintage heavy-rail train', 5],
['Public Art', 'Your team posing with a piece of public art', 5],
['Airport Carpet', 'Your team posing with the PDX airpor carpet (old or new)', 20],
];
foreach($documents as $d)
DB::table('m7_documents')->insert(['name' => $d[0], 'description' => $d[1]]);
DB::table('m7_documents')->insert(['name' => $d[0], 'description' => $d[1], 'points' => $d[2]]);
}
}

Loading…
Cancel
Save