Skip to content

Commit

Permalink
More renames
Browse files Browse the repository at this point in the history
  • Loading branch information
schmeits committed Jan 26, 2024
1 parent 2604b74 commit d89749a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
blank_issues_enabled: false
contact_links:
- name: Ask a question
url: https://github.com/schmeits/pulse-database-table-sizes/discussions/new?category=q-a
url: https://github.com/schmeits/pulse-database-table-info/discussions/new?category=q-a
about: Ask the community for help
- name: Request a feature
url: https://github.com/schmeits/pulse-database-table-sizes/discussions/new?category=ideas
url: https://github.com/schmeits/pulse-database-table-info/discussions/new?category=ideas
about: Share ideas for new features
- name: Report a security issue
url: https://github.com/schmeits/pulse-database-table-sizes/security/policy
url: https://github.com/schmeits/pulse-database-table-info/security/policy
about: Learn how to notify us for sensitive bugs
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

All notable changes to `pulse-database-table-sizes` will be documented in this file.
All notable changes to `pulse-database-table-info` will be documented in this file.

## 1.4.1 - 2024-01-26

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# A Laravel Pulse card displaying the table info of the current database.

[![Latest Version on Packagist](https://img.shields.io/packagist/v/schmeits/pulse-database-table-sizes.svg?style=flat-square)](https://packagist.org/packages/schmeits/pulse-database-table-sizes)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/schmeits/pulse-database-table-sizes/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/schmeits/pulse-database-table-sizes/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/schmeits/pulse-database-table-sizes/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/schmeits/pulse-database-table-sizes/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/schmeits/pulse-database-table-sizes.svg?style=flat-square)](https://packagist.org/packages/schmeits/pulse-database-table-sizes)
[![Latest Version on Packagist](https://img.shields.io/packagist/v/schmeits/pulse-database-table-info.svg?style=flat-square)](https://packagist.org/packages/schmeits/pulse-database-table-info)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/schmeits/pulse-database-table-info/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/schmeits/pulse-database-table-info/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/schmeits/pulse-database-table-info/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/schmeits/pulse-database-table-info/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/schmeits/pulse-database-table-info.svg?style=flat-square)](https://packagist.org/packages/schmeits/pulse-database-table-info)

This pulse card displays the tables in the database with their corresponding info (size and rows).

Expand Down Expand Up @@ -41,7 +41,7 @@ Then, you can modify the `dashboard.blade.php` file:

```diff
<x-pulse>
+ <livewire:pulse.table-sizes cols='4' rows='2' />
+ <livewire:pulse.table-info cols='4' rows='2' />

<livewire:pulse.servers cols="full" />

Expand Down
2 changes: 1 addition & 1 deletion resources/views/livewire/table-info.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<x-pulse::card id="pulse-table-sizes" :cols="$cols" :rows="$rows" :class="$class" wire:poll.5s="">
<x-pulse::card id="pulse-table-info" :cols="$cols" :rows="$rows" :class="$class" wire:poll.5s="">
<x-pulse::card-header name="Table Info">
<x-slot:icon>
<x-pulse::icons.circle-stack></x-pulse::icons.circle-stack>
Expand Down
4 changes: 2 additions & 2 deletions src/Livewire/TableInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#[Lazy]
class TableInfo extends Card
{
#[Url(as: 'table-sizes')]
#[Url(as: 'table-info')]
public string $orderBy = 'size';

public function render(): View
Expand All @@ -34,7 +34,7 @@ function () {
default => $value->sortBy('name')
};

return view('pulse-database-table-sizes::livewire.table-info', [
return view('pulse-database-table-info::livewire.table-info', [
'results' => $value ?? collect(),
]);
}
Expand Down
12 changes: 6 additions & 6 deletions src/Recorders/TableInfoRecorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function record(SharedBeat $event): void

$connection = app(ConnectionResolverInterface::class)->connection($connectionName);

$results = $this->getTableSizes($connection);
$results = $this->getTableInfo($connection);

$results = collect($results)->map(function ($obj) {
return [
Expand All @@ -53,24 +53,24 @@ protected function getDefaultConnectionName(): string
return config('database.default');
}

private function getTableSizes(ConnectionInterface $connection): array
private function getTableInfo(ConnectionInterface $connection): array
{
return match (true) {
$connection instanceof MySqlConnection => $this->getTableSizesMysql($connection),
$connection instanceof PostgresConnection => $this->getTableSizesPostgres($connection),
$connection instanceof MySqlConnection => $this->getTableInfoMySql($connection),
$connection instanceof PostgresConnection => $this->getTableInfoPostgres($connection),
default => throw DatabaseNotSupported::make($connection),
};
}

private function getTableSizesMysql(ConnectionInterface $connection): array
private function getTableInfoMySql(ConnectionInterface $connection): array
{
return $connection->select(
'SELECT table_name as tablename, (data_length + index_length) AS size, TABLE_ROWS as rowcount FROM information_schema.TABLES WHERE table_schema = ?',
[$connection->getDatabaseName()]
);
}

private function getTableSizesPostgres(ConnectionInterface $connection): array
private function getTableInfoPostgres(ConnectionInterface $connection): array
{
return $connection->select('SELECT relname AS "tablename", pg_total_relation_size(relid) AS "size", n_live_tup as "rowcount" FROM pg_stat_user_tables');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getEnvironmentSetUp($app)
config()->set('database.default', 'testing');

/*
$migration = include __DIR__.'/../database/migrations/create_pulse-database-table-sizes_table.php.stub';
$migration = include __DIR__.'/../database/migrations/create_pulse-database-table-info_table.php.stub';
$migration->up();
*/
}
Expand Down

0 comments on commit d89749a

Please sign in to comment.