Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Commit

Permalink
v1.2.1 Bug Fixes (#243)
Browse files Browse the repository at this point in the history
* #240, Mail possibly not working (Mailgun)

* #241, Paginate listings to 10 instead of 7

* #241, Paginate listings to 10 instead of 7

* #238, Cards not linking to details page.

* Version 1.2.1

* Refactor code to simplify reading.

* Skip test of v1.2.2 functionality.
  • Loading branch information
marky291 authored Aug 20, 2019
1 parent ae18eaa commit 1082aa1
Show file tree
Hide file tree
Showing 19 changed files with 47 additions and 22 deletions.
1 change: 1 addition & 0 deletions app/Http/Controllers/ListingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Controllers;

use App\Events\ListingCreatedEvent;
use App\Listings\ListingScreenshot;
use App\Listings\ReconditionListingSpace;
use App\Tag;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/StoreListingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function rules()
'accent' => Rule::in(config('filter.accents')),
'language' => Rule::in(config('filter.languages')),
'background' => 'required',
'website' => 'active_url|required|min:3',
'website' => 'required|min:3',
'mode' => Rule::in(config('filter.modes')),
'tags.*' => Rule::in(config('filter.tags')),
'screenshots.*' => 'sometimes|string',
Expand Down
4 changes: 2 additions & 2 deletions app/Listings/Listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Listings;

use App\FileSpaces;
use App\Tag;
use App\User;
use Carbon\Carbon;
Expand Down Expand Up @@ -48,9 +47,10 @@
* @method static create(array $validated)
* @method static make(array $validated)
* @method static whereName(string $name)
* @method static orderBy(string $string)
* @method static Builder orderBy(string $string)
* @method static Builder withCount(array $array)
* @method static count()
* @method static Builder latest()
*/
class Listing extends Model
{
Expand Down
4 changes: 3 additions & 1 deletion app/Listings/ListingObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class ListingObserver
*/
public function created(Listing $listing): void
{
$listing->ranking()->save(new ListingRanking(['rank'=>ListingRanking::query()->max('rank') + 1]));
$listing->ranking()->save(new ListingRanking([
'rank' => ListingRanking::query()->max('rank') + 1
]));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions app/Listings/ListingRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class ListingRepository
{
public static function LatestEntriesCache(int $count)
{
return Cache::remember('listing:latest-entries', 60, static function () use ($count) {
return ListingResource::collection(Listing::orderBy('created_at')->limit($count)->get());
return Cache::remember('listing:latest-entries', 300, static function () use ($count) {
return ListingResource::collection(Listing::latest()->orderBy('created_at')->limit($count)->get());
});
}
}
1 change: 1 addition & 0 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Providers;

use App\Events\ListingCreatedEvent;
use App\Listings\ListingVotedEvent;
use App\Listings\ListingClickedEvent;
use Illuminate\Support\Facades\Event;
Expand Down
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
| and that deployments are loading the correct filesource.
|
*/
'version' => '1.2.0',
'version' => '1.2.1',

/*
|--------------------------------------------------------------------------
Expand Down
Binary file removed public/img/logo-mobile.jp2
Binary file not shown.
Binary file removed public/img/logo-mobile.png
Binary file not shown.
2 changes: 1 addition & 1 deletion public/js/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/js/app.js": "/js/app.js?id=2c606cb57d61bc3464a0",
"/js/app.js": "/js/app.js?id=68af1f7d1d6731a91705",
"/css/app.css": "/css/app.css?id=db58cf74eab71e9237d4"
}
5 changes: 4 additions & 1 deletion resources/js/components/FilteredListingContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div v-for="listing in data" :key="listing['id']" :data-index="listing['id']">
<div class="mb-3 server-card item flex-fill tw-shadow border rounded">
<div class="server-card-head image rounded-top" v-bind:style="{ 'background-image': 'url(' + space + '/' + listing['background'] + ')' }"></div>
<div @click="visitProfile(listing)" class="server-card-head hover:tw-bg-transparent tw-cursor-pointer overlap d-flex">
<div @click="openProfile(listing)" class="server-card-head hover:tw-bg-transparent tw-cursor-pointer overlap d-flex">
<div class="left-side d-flex w-75 flex-column align-items-start px-4 py-2 align-self-end">
<h1 class="font-weight-bold mb-0" style="font-size: 26px; color:rgb(243, 243, 243);">{{ listing['name'] }}</h1>
<ul class="tag-list tw-flex tw-flex-wrap tw-text-xs tw-text-green-light" style="font-size:13px; margin-bottom: .5rem; width:inherit">
Expand Down Expand Up @@ -73,6 +73,9 @@
});
ga('send', 'event', 'website', 'clicked', this.listing.name);
},
openProfile: function(listing) {
window.open(`/listing/${listing.slug}`, '_self');
},
beforeEnter: function (el) {
el.style.opacity = 0;
el.style.height = 0;
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/FilteredListingSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
mode: 'all',
sort: 'rank',
tag: 'all',
paginate: '7',
paginate: '10',
}
},
methods: {
Expand Down
4 changes: 2 additions & 2 deletions resources/js/components/homepage/Homepage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export default {
data: function () {
return {
resource: 'api/servers/all/all/all/rank/7',
resource: 'api/servers/all/all/all/rank/10',
currentPage: 1,
listings: {
data: {},
Expand Down Expand Up @@ -32,4 +32,4 @@
},
},
}
</script>
</script>
3 changes: 2 additions & 1 deletion resources/js/components/homepage/Paginate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
methods : {
changePage(page) {
this.pagination.current_page = page;
this.$emit('paginate', `/api/servers/all/all/all/rank/7?page=${this.pagination.current_page}`);
this.$emit('paginate', `/api/servers/all/all/all/rank/10?page=${this.pagination.current_page}`);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions resources/views/listing/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
@section('content')
<homepage inline-template>
<div class="shadow-inner">
<div class="tw-container tw-pt-5">
<div class="tw-container tw-pt-5" id="listingView">
@if (auth()->check() && !auth()->user()->hasVerifiedEmail())
<div class="row">
<div class="col-12 pb-3">
<at-alert message="Verification Required" description="A verification email has been sent and awaiting response, account functionality is limited until completed!" type="error" show-icon></at-alert>
<at-alert message="Verification Required" description="A verification email has been sent and awaiting response, account functionality is limited until completed, email may be found in spam or inbox folder!" type="error" show-icon></at-alert>
</div>
</div>
@endif
Expand Down
6 changes: 2 additions & 4 deletions resources/views/sidebar/filter.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@
</select>

<select @change="filterChanged" v-model="paginate" style="color: #8795a1" class="form-control-sm tw-text-sm tw-bg-panel tw-rounded-full tw-px-5 tw-py-3 tw-flex tw-items-center tw-cursor-pointer tw-leading-none">
<option value="7" selected>And show 7 servers</option>
<option value="15">And show 15 servers</option>
<option value="30">And show 30 servers</option>
<option value="10" selected>And show 10 servers</option>
<option value="25">And show 25 servers</option>
<option value="50">And show 50 servers</option>
<option value="100">And show 100 servers</option>
</select>
</div>
</transition>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/sidebar/recent.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</div>

<div id="additions" class="content tw-shadow py-0 rounded">
@foreach (\App\Listings\ListingRepository::LatestEntriesCache(7) as $listing)
@foreach (\App\Listings\ListingRepository::LatestEntriesCache(10) as $listing)
<div class="microcard" style="{{ $loop->last ? null : 'border-bottom: 1px dashed #e3e3e3;' }}">
<div class="information d-flex flex-row py-3">
<div class="icon text-green align-self-center mr-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class CertifyRankPositionTest extends TestCase
class RankPositionComparatorTest extends TestCase
{
use RefreshDatabase;

Expand Down Expand Up @@ -60,4 +60,23 @@ public function test_no_change_in_listing_rank_position()
$this->assertDatabaseHas('listing_rankings', ['rank' => 1, 'listing_id' => 1]);
$this->assertDatabaseHas('listing_rankings', ['rank' => 2, 'listing_id' => 2]);
}

public function test_listing_rank_does_not_compare_deleted_listings()
{
$this->markTestIncomplete(
'Currently missing functionality, required for v1.2.2'
);

$listing1 = factory(Listing::class)->create(['id' => 1]);
$listing2 = factory(Listing::class)->create(['id' => 2]);

// delete listing two
$listing2->delete();

// add a new listing after deleting one. (should set a rank ignoring deleted)
$listing3 = factory(Listing::class)->create(['id' => 3]);

$this->assertDatabaseHas('listing_rankings', ['rank' => 1, 'listing_id' => 1]);
$this->assertDatabaseHas('listing_rankings', ['rank' => 2, 'listing_id' => 3]);
}
}

0 comments on commit 1082aa1

Please sign in to comment.