From 065551157488b160a6a5d6fd73cd0fdde9ac8e82 Mon Sep 17 00:00:00 2001 From: nelsonlaquet Date: Sun, 1 Sep 2013 00:03:37 -0500 Subject: [PATCH] asdf --- app/commands/MigrateOldData.php | 2 -- app/controllers/AuthController.php | 4 +-- .../2013_06_07_003952_create_users_table.php | 2 -- app/models/Entities/Track.php | 26 ++++++++++++++----- app/views/shared/_app_layout.blade.php | 1 + public/styles/loader.css | 0 6 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 public/styles/loader.css diff --git a/app/commands/MigrateOldData.php b/app/commands/MigrateOldData.php index ed043911..0f03180b 100644 --- a/app/commands/MigrateOldData.php +++ b/app/commands/MigrateOldData.php @@ -40,8 +40,6 @@ 'created_at' => $user->created_at, 'updated_at' => $user->updated_at, 'slug' => $user->slug, - 'password_hash' => $user->password_hash, - 'password_salt' => $user->password_salt, 'bio' => $user->bio, 'sync_names' => $user->sync_names, 'can_see_explicit_content' => $user->can_see_explicit_content, diff --git a/app/controllers/AuthController.php b/app/controllers/AuthController.php index f0b96bf8..6ba6e0c8 100644 --- a/app/controllers/AuthController.php +++ b/app/controllers/AuthController.php @@ -67,13 +67,13 @@ $user = new User; - $user->username = $poniverseUser['username']; + $user->mlpforums_name = $poniverseUser['username']; $user->display_name = $poniverseUser['display_name']; $user->email = $poniverseUser['email']; $user->created_at = gmdate("Y-m-d H:i:s", time()); + $user->uses_gravatar = 1; $user->save(); - $user->roles()->attach(4); //We need to insert a new token row :O diff --git a/app/database/migrations/2013_06_07_003952_create_users_table.php b/app/database/migrations/2013_06_07_003952_create_users_table.php index 23a8b967..b0dd0bae 100644 --- a/app/database/migrations/2013_06_07_003952_create_users_table.php +++ b/app/database/migrations/2013_06_07_003952_create_users_table.php @@ -10,8 +10,6 @@ class CreateUsersTable extends Migration { $table->string('display_name', 255); $table->string('mlpforums_name')->nullable(); $table->boolean('sync_names')->default(true); - $table->string('password_hash', 32); - $table->string('password_salt', 5); $table->string('email', 150)->indexed(); $table->string('gravatar')->nullable(); $table->string('slug'); diff --git a/app/models/Entities/Track.php b/app/models/Entities/Track.php index 203b8bd7..32490d1d 100644 --- a/app/models/Entities/Track.php +++ b/app/models/Entities/Track.php @@ -54,31 +54,43 @@ } 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 - ::with(['user', 'genre', 'cover', 'user.avatar']) - ->published() - ->whereIsExplicit($allowExplicit) + ::published() ->join(DB::raw(' ( SELECT `track_id`, `created_at` 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'), 'tracks.id', '=', 'ranged_plays.track_id') ->groupBy('id') ->orderBy('plays', 'desc') ->take(20); + if (!$allowExplicit) + $query->whereIsExplicit(false); + $results = []; foreach($query->get(['*', DB::raw('count(*) as plays')]) as $track) { - $results[] = self::mapPublicTrackSummary($track); + $results[] = $track->id; } 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) { diff --git a/app/views/shared/_app_layout.blade.php b/app/views/shared/_app_layout.blade.php index cc97f4b5..0cf624fb 100644 --- a/app/views/shared/_app_layout.blade.php +++ b/app/views/shared/_app_layout.blade.php @@ -86,6 +86,7 @@ @endsection @section('styles') + {{ Assets::styleIncludes() }} @endsection diff --git a/public/styles/loader.css b/public/styles/loader.css new file mode 100644 index 00000000..e69de29b