Indexes for performance improvements, improved FTN regex

This commit is contained in:
Deon George 2022-11-01 16:39:58 +11:00
parent 5334b7d615
commit 702c5fb4f2
3 changed files with 53 additions and 3 deletions

View File

@ -271,7 +271,7 @@ class SystemController extends Controller
return redirect()->action([self::class,'home']); return redirect()->action([self::class,'home']);
} }
$o->load(['addresses.zone.domain']); $o->load(['addresses.zone.domain','addresses.system','sessions.domain','sessions.systems']);
return view('system.addedit') return view('system.addedit')
->with('action',$o->exists ? 'update' : 'create') ->with('action',$o->exists ? 'update' : 'create')

View File

@ -32,6 +32,9 @@ class Address extends Model
protected $with = ['zone']; protected $with = ['zone'];
// http://ftsc.org/docs/frl-1028.002
public const ftn_regex = '([0-9]+):([0-9]+)/([0-9]+)(\.([0-9]+))?(@([a-z0-9\-_~]{0,8}))?';
public const NODE_ZC = 1<<0; // Zone public const NODE_ZC = 1<<0; // Zone
public const NODE_RC = 1<<1; // Region public const NODE_RC = 1<<1; // Region
public const NODE_NC = 1<<2; // Host public const NODE_NC = 1<<2; // Host
@ -513,6 +516,7 @@ class Address extends Model
} }
/** /**
*
* Parse a string and split it out as an FTN array * Parse a string and split it out as an FTN array
* *
* @param string $ftn * @param string $ftn
@ -521,8 +525,7 @@ class Address extends Model
*/ */
public static function parseFTN(string $ftn): array public static function parseFTN(string $ftn): array
{ {
// http://ftsc.org/docs/frl-1028.002 if (! preg_match(sprintf('#^%s$#',self::ftn_regex),strtolower($ftn),$matches))
if (! preg_match('#^([0-9]+):([0-9]+)/([0-9]+)(.([0-9]+))?(@([a-z0-9\-_~]{0,8}))?$#',strtolower($ftn),$matches))
throw new Exception('Invalid FTN: '.$ftn); throw new Exception('Invalid FTN: '.$ftn);
// Check our numbers are correct. // Check our numbers are correct.

View File

@ -0,0 +1,47 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('echomail_seenby', function (Blueprint $table) {
$table->index(['echomail_id','address_id']);
$table->index(['packet']);
$table->index(['sent_at']);
$table->index(['export_at']);
});
Schema::table('echomails', function (Blueprint $table) {
$table->index(['msgid']);
$table->index(['replyid']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('echomails', function (Blueprint $table) {
$table->dropIndex(['msgid']);
$table->dropIndex(['replyid']);
});
Schema::table('echomail_seenby', function (Blueprint $table) {
$table->dropIndex(['packet']);
$table->dropIndex(['sent_at']);
$table->dropIndex(['export_at']);
$table->dropIndex(['echomail_id','address_id']);
});
}
};