Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize dump #683

Merged
merged 5 commits into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 41 additions & 7 deletions resources/js/screens/dumps/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
return {
entries: [],
ready: false,
error: null,
newEntriesTimeout: null,
newEntriesTimeoutInSeconds: 2000,
newEntriesTimer: 2000,
recordingStatus: 'enabled'
};
},
Expand Down Expand Up @@ -38,16 +39,41 @@
methods: {
loadEntries(){
axios.post(Telescope.basePath + '/telescope-api/dumps').then(response => {
this.error = null;
this.entries = response.data.entries;
this.recordingStatus = response.data.status;

this.checkForNewEntries();
}).catch(error => {
if (error.response && error.response.data.message) {
this.error = error.response.data.message;
} else {
this.error = 'Something went wrong';
}
}).finally(() => {
this.ready = true;

this.newEntriesTimeout = setTimeout(() => {
this.loadEntries();
}, this.newEntriesTimeoutInSeconds);
});
}
},


/**
* Keep checking if there are new entries.
*/
checkForNewEntries(){
this.newEntriesTimeout = setTimeout(() => {
axios.post(Telescope.basePath + '/telescope-api/dumps?take=1').then(response => {
this.recordingStatus = response.data.status;

if (response.data.entries.length && !this.entries.length) {
this.loadEntries();
} else if (response.data.entries.length && _.first(response.data.entries).id !== _.first(this.entries).id) {
this.loadEntries();
} else {
this.checkForNewEntries();
}
})
}, this.newEntriesTimer);
},
}
}
</script>
Expand Down Expand Up @@ -76,14 +102,22 @@
</div>


<div v-if="ready && entries.length == 0" class="d-flex flex-column align-items-center justify-content-center card-bg-secondary p-5 bottom-radius">
<div v-if="ready && entries.length == 0 && !error" class="d-flex flex-column align-items-center justify-content-center card-bg-secondary p-5 bottom-radius">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60" class="fill-text-color" style="width: 200px;">
<path fill-rule="evenodd" d="M7 10h41a11 11 0 0 1 0 22h-8a3 3 0 0 0 0 6h6a6 6 0 1 1 0 12H10a4 4 0 1 1 0-8h2a2 2 0 1 0 0-4H7a5 5 0 0 1 0-10h3a3 3 0 0 0 0-6H7a6 6 0 1 1 0-12zm14 19a1 1 0 0 1-1-1 1 1 0 0 0-2 0 1 1 0 0 1-1 1 1 1 0 0 0 0 2 1 1 0 0 1 1 1 1 1 0 0 0 2 0 1 1 0 0 1 1-1 1 1 0 0 0 0-2zm-5.5-11a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zm24 10a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zm1 18a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zm-14-3a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zm22-23a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zM33 18a1 1 0 0 1-1-1v-1a1 1 0 0 0-2 0v1a1 1 0 0 1-1 1h-1a1 1 0 0 0 0 2h1a1 1 0 0 1 1 1v1a1 1 0 0 0 2 0v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 0-2h-1z"></path>
</svg>

<span>We didn't find anything - just empty space.</span>
</div>

<div v-if="error" class="d-flex flex-column align-items-center justify-content-center card-bg-secondary p-5 bottom-radius">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60" class="fill-text-color" style="width: 200px;">
<path fill-rule="evenodd" d="M7 10h41a11 11 0 0 1 0 22h-8a3 3 0 0 0 0 6h6a6 6 0 1 1 0 12H10a4 4 0 1 1 0-8h2a2 2 0 1 0 0-4H7a5 5 0 0 1 0-10h3a3 3 0 0 0 0-6H7a6 6 0 1 1 0-12zm14 19a1 1 0 0 1-1-1 1 1 0 0 0-2 0 1 1 0 0 1-1 1 1 1 0 0 0 0 2 1 1 0 0 1 1 1 1 1 0 0 0 2 0 1 1 0 0 1 1-1 1 1 0 0 0 0-2zm-5.5-11a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zm24 10a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zm1 18a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zm-14-3a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zm22-23a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zM33 18a1 1 0 0 1-1-1v-1a1 1 0 0 0-2 0v1a1 1 0 0 1-1 1h-1a1 1 0 0 0 0 2h1a1 1 0 0 1 1 1v1a1 1 0 0 0 2 0v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 0-2h-1z"></path>
</svg>

<span>Whoops: {{ error }}</span>
</div>

<div v-if="ready && entries.length > 0" class="code-bg px-3 pt-3">
<transition-group tag="div" name="list">
<div v-for="entry in entries" :key="entry.id" class="mb-4">
Expand Down
7 changes: 7 additions & 0 deletions src/Http/Controllers/DumpController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Laravel\Telescope\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Cache\ArrayStore;
use Laravel\Telescope\EntryType;
use Laravel\Telescope\Watchers\DumpWatcher;
use Laravel\Telescope\Contracts\EntriesRepository;
Expand Down Expand Up @@ -37,6 +38,12 @@ public function __construct(CacheRepository $cache)
*/
public function index(Request $request, EntriesRepository $storage)
{
if ($this->cache->getStore() instanceof ArrayStore) {
return response()->json([
'message' => 'The Array cache driver cannot be used for Dumps. Please use a persistent cache.',
], 400);
}

$this->cache->put('telescope:dump-watcher', true, now()->addSeconds(4));

return parent::index($request, $storage);
Expand Down