This commit is contained in:
nelsonlaquet 2013-09-01 00:03:37 -05:00
parent b15b804999
commit 0655511574
6 changed files with 22 additions and 13 deletions

View file

@ -40,8 +40,6 @@
'created_at' => $user->created_at, 'created_at' => $user->created_at,
'updated_at' => $user->updated_at, 'updated_at' => $user->updated_at,
'slug' => $user->slug, 'slug' => $user->slug,
'password_hash' => $user->password_hash,
'password_salt' => $user->password_salt,
'bio' => $user->bio, 'bio' => $user->bio,
'sync_names' => $user->sync_names, 'sync_names' => $user->sync_names,
'can_see_explicit_content' => $user->can_see_explicit_content, 'can_see_explicit_content' => $user->can_see_explicit_content,

View file

@ -67,13 +67,13 @@
$user = new User; $user = new User;
$user->username = $poniverseUser['username']; $user->mlpforums_name = $poniverseUser['username'];
$user->display_name = $poniverseUser['display_name']; $user->display_name = $poniverseUser['display_name'];
$user->email = $poniverseUser['email']; $user->email = $poniverseUser['email'];
$user->created_at = gmdate("Y-m-d H:i:s", time()); $user->created_at = gmdate("Y-m-d H:i:s", time());
$user->uses_gravatar = 1;
$user->save(); $user->save();
$user->roles()->attach(4);
//We need to insert a new token row :O //We need to insert a new token row :O

View file

@ -10,8 +10,6 @@ class CreateUsersTable extends Migration {
$table->string('display_name', 255); $table->string('display_name', 255);
$table->string('mlpforums_name')->nullable(); $table->string('mlpforums_name')->nullable();
$table->boolean('sync_names')->default(true); $table->boolean('sync_names')->default(true);
$table->string('password_hash', 32);
$table->string('password_salt', 5);
$table->string('email', 150)->indexed(); $table->string('email', 150)->indexed();
$table->string('gravatar')->nullable(); $table->string('gravatar')->nullable();
$table->string('slug'); $table->string('slug');

View file

@ -54,31 +54,43 @@
} }
public static function popular($count, $allowExplicit = false) { public static function popular($count, $allowExplicit = false) {
$tracks = Cache::remember('popular_tracks-' . ($allowExplicit ? 'explicit' : 'safe'), 5, function() use ($allowExplicit) { $trackIds = Cache::remember('popular_tracks-' . ($allowExplicit ? 'explicit' : 'safe'), 5, function() use ($allowExplicit) {
$query = static $query = static
::with(['user', 'genre', 'cover', 'user.avatar']) ::published()
->published()
->whereIsExplicit($allowExplicit)
->join(DB::raw(' ->join(DB::raw('
( SELECT `track_id`, `created_at` ( SELECT `track_id`, `created_at`
FROM `resource_log_items` FROM `resource_log_items`
WHERE `created_at` > now() - INTERVAL 1 DAY WHERE track_id IS NOT NULL AND log_type = 3 AND `created_at` > now() - INTERVAL 1 DAY
) AS ranged_plays'), ) AS ranged_plays'),
'tracks.id', '=', 'ranged_plays.track_id') 'tracks.id', '=', 'ranged_plays.track_id')
->groupBy('id') ->groupBy('id')
->orderBy('plays', 'desc') ->orderBy('plays', 'desc')
->take(20); ->take(20);
if (!$allowExplicit)
$query->whereIsExplicit(false);
$results = []; $results = [];
foreach($query->get(['*', DB::raw('count(*) as plays')]) as $track) { foreach($query->get(['*', DB::raw('count(*) as plays')]) as $track) {
$results[] = self::mapPublicTrackSummary($track); $results[] = $track->id;
} }
return $results; return $results;
}); });
return $tracks; $tracks = Track::summary()
->userDetails()
->explicitFilter()
->published()
->with('user', 'genre', 'cover', 'album', 'album.user')
->whereIn('id', $trackIds);
$processed = [];
foreach ($tracks->get() as $track)
$processed[] = Track::mapPublicTrackSummary($track);
return $processed;
} }
public static function mapPublicTrackShow($track) { public static function mapPublicTrackShow($track) {

View file

@ -86,6 +86,7 @@
@endsection @endsection
@section('styles') @section('styles')
<link rel="stylesheet" type="text/css" href="/styles/loader.css" />
{{ Assets::styleIncludes() }} {{ Assets::styleIncludes() }}
@endsection @endsection

0
public/styles/loader.css Normal file
View file