Skip to content
This repository was archived by the owner on Jan 1, 2021. It is now read-only.

Commit ee46364

Browse files
committed
Ignore Adult movies from now on :)
1 parent df9f856 commit ee46364

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

app/Http/Controllers/API/DiscoverController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function upcoming() {
2828
$resp = Cache::remember("discovery.upcoming", Carbon::now()->addHours(12), function (){
2929
return Movie::whereHas("release_dates", function($query) {
3030
$query->whereIn("type", array(4,5,6))->whereBetween("release_date", array(Carbon::now()->subWeek(), Carbon::now()->addWeeks(3)))->orderBy("release_date", "ASC");
31-
})->orderBy("popularity", "DESC")->get()->toArray();
31+
})->where("adult", "=", "0")->orderBy("popularity", "DESC")->get()->toArray();
3232
});
3333
return response()->json($resp);
3434
}
@@ -57,7 +57,7 @@ public function recommendations(Request $request) {
5757
{
5858
abort(422, "Please add some movies before using our recommendation engine :)");
5959
}
60-
$movies_db = DB::select("SELECT mo.id, mo.popularity, mo.imdb_id, mo.title, mo.overview, mo.vote_average, mo.vote_count, mo.tagline, mo.poster_path, mo.release_date, mo.release_year, mo.trailer_key, mo.trailer_site, mo.backdrop_path, mo.homepage, mo.runtime, mo.countO FROM ( SELECT m.*, r.recommended_id, r.tmdbid, r.id as rid, count(m.id) as countO FROM movies m, recommendations r WHERE m.id = r.recommended_id AND r.tmdbid in ($ids) AND r.recommended_id not in ($ids$ignoredIds) GROUP BY m.id ) as mo;");
60+
$movies_db = DB::select("SELECT mo.id, mo.popularity, mo.imdb_id, mo.title, mo.overview, mo.vote_average, mo.vote_count, mo.tagline, mo.poster_path, mo.release_date, mo.release_year, mo.trailer_key, mo.trailer_site, mo.backdrop_path, mo.homepage, mo.runtime, mo.countO FROM ( SELECT m.*, r.recommended_id, r.tmdbid, r.id as rid, count(m.id) as countO FROM movies m, recommendations r WHERE m.id = r.recommended_id AND r.tmdbid in ($ids) AND r.recommended_id not in ($ids$ignoredIds) AND m.adult = 0 GROUP BY m.id ) as mo;");
6161
$movies = json_decode(json_encode($movies_db), true);
6262

6363
$this->count_max = maximum($movies, "countO");

app/Movie.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ class Movie extends Model
1414
*/
1515
public $timestamps = false;
1616

17+
protected $casts = [
18+
"adult" => "boolean",
19+
];
20+
1721
public function release_dates() {
1822
return $this->hasMany("App\ReleaseDate", "tmdbid", "id");
1923
}

0 commit comments

Comments
 (0)