/**
  * Show activity information for project
  *
  * @param  string $key []
  * @return \Illuminate\Http\Response
  */
 public function activity($key, Category $category)
 {
     $project = $this->find($key);
     $active = 1;
     $categories = $category->get();
     return view('detail_activity', compact('project', 'active', 'categories'));
 }
Example #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $scopesList = ['seo' => 'SEO', 'backendSeo' => 'SEO', 'html' => 'Code Quality', 'css' => 'Code Quality', 'js' => 'Code Quality', 'socialMedia' => 'Social Media', 'gPagespeedDesktop' => 'Performance', 'gPagespeedMobile' => 'Performance', 'ySlow' => 'Performance'];
     foreach ($scopesList as $name => $category) {
         if (strcmp($name, 'css') == 0) {
             $type = 'css';
         } elseif (strcmp($name, 'js') == 0) {
             $type = 'js';
         } else {
             $type = 'url';
         }
         factory(Scope::class, 'seeder')->create(['name' => $name, 'category_id' => Category::byName($category)->first()->id, 'type' => $type]);
     }
 }
 /**
  * Test add score to database
  *
  * @return void
  */
 public function testAddScore()
 {
     $projectFaker = factory(Project::class)->create();
     $inspectionFaker = factory(Inspection::class)->create(['project_id' => $projectFaker->id]);
     factory(JobInspect::class, 5)->create(['inspection_id' => $inspectionFaker->id, 'scope_id' => 1, 'issue_count' => 7, 'status' => 2]);
     factory(Url::class, 2)->create(['project_id' => $projectFaker->id]);
     $score = Mockery::mock(Score::class);
     $category = Mockery::mock(Category::class);
     $score->shouldReceive('findOrNewByRelatedId')->andReturn(new Score());
     $score->shouldReceive('inspection->associate');
     $score->shouldReceive('save')->andReturn(true);
     $category->shouldReceive('all')->andReturn(Category::all());
     $calculateScore = new CalculateScore($score, $category);
     $calculateScore->calculate($inspectionFaker);
     $this->seeInDatabase('scores', ['category_id' => '1']);
 }
Example #4
0
 /**
  * Test get query scope of bySlug method
  *
  * @return void
  */
 public function testScopeGetBySlug()
 {
     $category = new Category();
     $this->assertEquals(new Collection(), $category->bySlug('test')->get());
 }
Example #5
0
 /**
  * Generate json data for graph
  *
  * @return array
  */
 public function getJsonData()
 {
     $graphData = [];
     $count = 0;
     $listGraph = array_merge(['overall' => 'Overall'], Category::lists('name', 'slug')->toArray());
     $graphData = array_add($graphData, 'title', $this->name);
     $graphData = array_add($graphData, 'series', []);
     $graphData = array_add($graphData, 'xAxis', []);
     $inspections = $this->inspections()->limit(10)->get();
     $inspectionsScore = $inspections->map(function ($item) {
         if ($item->status == '2') {
             return (double) $item->score;
         }
         return null;
     })->toArray();
     foreach ($this->inspections as $inspection) {
         array_push($graphData['xAxis'], '#' . $inspection->sequence_number);
     }
     foreach ($listGraph as $slug => $name) {
         array_set($series, $count . '.name', $name);
         if ($slug == 'overall') {
             array_set($series, $count . '.data', $inspectionsScore);
         } else {
             array_set($series, $count . '.data', $this->getScoreByCategorySlug($inspections, $slug));
         }
         $count++;
     }
     array_set($graphData, 'series', $series);
     return $graphData;
 }