Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| acfabbe670 |
@@ -8,8 +8,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
# runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
steps:
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class EnsureDailyChangeIsSynced
|
|||||||
) {
|
) {
|
||||||
defer(fn () => $model->portfolio->syncDailyChanges());
|
defer(fn () => $model->portfolio->syncDailyChanges());
|
||||||
|
|
||||||
Cache::put($cacheKey, true, now()->addMinutes(5));
|
Cache::put($cacheKey, now(), now()->addMinutes(5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -22,10 +22,10 @@
|
|||||||
"investbrainapp/frankfurter-client": "dev-main",
|
"investbrainapp/frankfurter-client": "dev-main",
|
||||||
"laravel/ai": "^0.2.5",
|
"laravel/ai": "^0.2.5",
|
||||||
"laravel/fortify": "^1.30.0",
|
"laravel/fortify": "^1.30.0",
|
||||||
"laravel/framework": "^13.0",
|
"laravel/framework": "^12.0",
|
||||||
"laravel/sanctum": "^4.0",
|
"laravel/sanctum": "^4.0",
|
||||||
"laravel/socialite": "^5.16",
|
"laravel/socialite": "^5.16",
|
||||||
"laravel/tinker": "^3.0",
|
"laravel/tinker": "^2.9",
|
||||||
"league/flysystem-aws-s3-v3": "^3.0",
|
"league/flysystem-aws-s3-v3": "^3.0",
|
||||||
"livewire/livewire": "^4.0",
|
"livewire/livewire": "^4.0",
|
||||||
"livewire/volt": "^1.6",
|
"livewire/volt": "^1.6",
|
||||||
@@ -39,11 +39,11 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fakerphp/faker": "^1.23",
|
"fakerphp/faker": "^1.23",
|
||||||
"laravel/boost": "^2.0",
|
"laravel/boost": "^1.8",
|
||||||
"laravel/pint": "^1.25",
|
"laravel/pint": "^1.25",
|
||||||
"mockery/mockery": "^1.6",
|
"mockery/mockery": "^1.6",
|
||||||
"nunomaduro/collision": "^8.0",
|
"nunomaduro/collision": "^8.0",
|
||||||
"phpunit/phpunit": "^12.0"
|
"phpunit/phpunit": "^11.0"
|
||||||
},
|
},
|
||||||
"repositories": [
|
"repositories": [
|
||||||
{
|
{
|
||||||
|
|||||||
Generated
+1075
-689
File diff suppressed because it is too large
Load Diff
@@ -107,17 +107,4 @@ return [
|
|||||||
|
|
||||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
|
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Cache Serializable Classes
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| For security, unserialization of cached PHP objects is restricted. Set
|
|
||||||
| this to false to disallow all object unserialization, or list the
|
|
||||||
| specific classes your application intentionally caches as objects.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
'serializable_classes' => false,
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
+3
-6
@@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Illuminate\Cookie\Middleware\EncryptCookies;
|
|
||||||
use Illuminate\Foundation\Http\Middleware\PreventRequestForgery;
|
|
||||||
use Laravel\Sanctum\Http\Middleware\AuthenticateSession;
|
|
||||||
use Laravel\Sanctum\Sanctum;
|
use Laravel\Sanctum\Sanctum;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@@ -80,9 +77,9 @@ return [
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
'middleware' => [
|
'middleware' => [
|
||||||
'authenticate_session' => AuthenticateSession::class,
|
'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class,
|
||||||
'encrypt_cookies' => EncryptCookies::class,
|
'encrypt_cookies' => Illuminate\Cookie\Middleware\EncryptCookies::class,
|
||||||
'validate_csrf_token' => PreventRequestForgery::class,
|
'validate_csrf_token' => Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -99,7 +99,6 @@
|
|||||||
|
|
||||||
this.data.tooltip = {
|
this.data.tooltip = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
shared: false,
|
|
||||||
y: {
|
y: {
|
||||||
formatter: (value, { series, seriesIndex, dataPointIndex, w }) => {
|
formatter: (value, { series, seriesIndex, dataPointIndex, w }) => {
|
||||||
const firstDataPoint = this.data.series[seriesIndex].data[0][1]
|
const firstDataPoint = this.data.series[seriesIndex].data[0][1]
|
||||||
|
|||||||
@@ -75,29 +75,26 @@ new #[Lazy] class extends Component
|
|||||||
|
|
||||||
foreach ($dailyChange as $data) {
|
foreach ($dailyChange as $data) {
|
||||||
$date = $data->date;
|
$date = $data->date;
|
||||||
$marketGainData[] = [$date, round($data->total_market_gain, 2)];
|
|
||||||
$marketValueData[] = [$date, round($data->total_market_value, 2)];
|
$marketValueData[] = [$date, round($data->total_market_value, 2)];
|
||||||
$costBasisData[] = [$date, round($data->total_cost_basis, 2)];
|
$costBasisData[] = [$date, round($data->total_cost_basis, 2)];
|
||||||
|
$marketGainData[] = [$date, round($data->total_market_gain, 2)];
|
||||||
// $dividendSeries[] = [$date, round($data->total_dividends_earned, 2)];
|
// $dividendSeries[] = [$date, round($data->total_dividends_earned, 2)];
|
||||||
// $realizedGainSeries[] = [$date, round($data->realized_gains, 2)];
|
// $realizedGainSeries[] = [$date, round($data->realized_gains, 2)];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'series' => [
|
'series' => [
|
||||||
[
|
|
||||||
'name' => __('Market Gain'),
|
|
||||||
'data' => $marketGainData,
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
'name' => __('Market Value'),
|
'name' => __('Market Value'),
|
||||||
'data' => $marketValueData,
|
'data' => $marketValueData,
|
||||||
'hidden' => true,
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => __('Cost Basis'),
|
'name' => __('Cost Basis'),
|
||||||
'data' => $costBasisData,
|
'data' => $costBasisData,
|
||||||
'hidden' => true,
|
],
|
||||||
|
[
|
||||||
|
'name' => __('Market Gain'),
|
||||||
|
'data' => $marketGainData,
|
||||||
],
|
],
|
||||||
|
|
||||||
// [
|
// [
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ new class extends Component
|
|||||||
<x-slot:actions>
|
<x-slot:actions>
|
||||||
@if (auth()->user()->id != $user->id)
|
@if (auth()->user()->id != $user->id)
|
||||||
<x-ui.select
|
<x-ui.select
|
||||||
class="cursor-pointer select-ghost border-none focus:outline-none focus:ring-0"
|
class="select select-ghost border-none focus:outline-none focus:ring-0"
|
||||||
:options="[['id' => 0, 'name' => __('Read only')], ['id' => 1, 'name' => __('Full access')]]"
|
:options="[['id' => 0, 'name' => __('Read only')], ['id' => 1, 'name' => __('Full access')]]"
|
||||||
wire:model.live.number="permissions.{{ $user->id }}.full_access"
|
wire:model.live.number="permissions.{{ $user->id }}.full_access"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ new class extends Component
|
|||||||
|
|
||||||
<div class="col-span-6 sm:col-span-4">
|
<div class="col-span-6 sm:col-span-4">
|
||||||
<x-ui.select
|
<x-ui.select
|
||||||
:label="__('Locale')"
|
label="{{ __('Locale') }}"
|
||||||
class=""
|
class="select block mt-1 w-full"
|
||||||
:options="config('app.available_locales')"
|
:options="config('app.available_locales')"
|
||||||
option-value="locale"
|
option-value="locale"
|
||||||
option-label="label"
|
option-label="label"
|
||||||
@@ -83,8 +83,8 @@ new class extends Component
|
|||||||
|
|
||||||
<div class="col-span-6 sm:col-span-4">
|
<div class="col-span-6 sm:col-span-4">
|
||||||
<x-ui.select
|
<x-ui.select
|
||||||
:label="__('Display Currency')"
|
label="{{ __('Display Currency') }}"
|
||||||
class=""
|
class="select block mt-1 w-full"
|
||||||
:options="$currencies"
|
:options="$currencies"
|
||||||
option-value="currency"
|
option-value="currency"
|
||||||
option-label="label"
|
option-label="label"
|
||||||
|
|||||||
@@ -1,75 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Tests\Api;
|
|
||||||
|
|
||||||
use App\Models\MarketData;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
||||||
use Tests\TestCase;
|
|
||||||
|
|
||||||
class MarketDataTest extends TestCase
|
|
||||||
{
|
|
||||||
use RefreshDatabase;
|
|
||||||
|
|
||||||
protected User $user;
|
|
||||||
|
|
||||||
protected function setUp(): void
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
$this->user = User::factory()->create();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_can_get_market_data_for_symbol(): void
|
|
||||||
{
|
|
||||||
MarketData::getMarketData('AAPL');
|
|
||||||
|
|
||||||
$this->actingAs($this->user)
|
|
||||||
->getJson(route('api.market-data.show', ['symbol' => 'AAPL']))
|
|
||||||
->assertOk()
|
|
||||||
->assertJsonStructure([
|
|
||||||
'symbol',
|
|
||||||
'name',
|
|
||||||
'market_value',
|
|
||||||
'fifty_two_week_low',
|
|
||||||
'fifty_two_week_high',
|
|
||||||
'last_dividend_date',
|
|
||||||
'last_dividend_amount',
|
|
||||||
'dividend_yield',
|
|
||||||
'market_cap',
|
|
||||||
'trailing_pe',
|
|
||||||
'forward_pe',
|
|
||||||
'book_value',
|
|
||||||
'created_at',
|
|
||||||
'updated_at',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_market_data_returns_correct_symbol(): void
|
|
||||||
{
|
|
||||||
$this->actingAs($this->user)
|
|
||||||
->getJson(route('api.market-data.show', ['symbol' => 'ACME']))
|
|
||||||
->assertSuccessful()
|
|
||||||
->assertJsonFragment([
|
|
||||||
'symbol' => 'ACME',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_market_data_response_has_expected_fields(): void
|
|
||||||
{
|
|
||||||
MarketData::getMarketData('MSFT');
|
|
||||||
|
|
||||||
$this->actingAs($this->user)
|
|
||||||
->getJson(route('api.market-data.show', ['symbol' => 'MSFT']))
|
|
||||||
->assertOk()
|
|
||||||
->assertJsonPath('symbol', 'MSFT')
|
|
||||||
->assertJsonPath('market_value', 230.19);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_cannot_access_market_data_when_unauthenticated(): void
|
|
||||||
{
|
|
||||||
$this->getJson(route('api.market-data.show', ['symbol' => 'AAPL']))->assertUnauthorized();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Tests\Api;
|
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
||||||
use Tests\TestCase;
|
|
||||||
|
|
||||||
class UserTest extends TestCase
|
|
||||||
{
|
|
||||||
use RefreshDatabase;
|
|
||||||
|
|
||||||
protected User $user;
|
|
||||||
|
|
||||||
protected function setUp(): void
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
$this->user = User::factory()->create();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_can_get_authenticated_user_profile(): void
|
|
||||||
{
|
|
||||||
$this->actingAs($this->user)
|
|
||||||
->getJson(route('api.me'))
|
|
||||||
->assertOk()
|
|
||||||
->assertJsonStructure([
|
|
||||||
'id',
|
|
||||||
'name',
|
|
||||||
'email',
|
|
||||||
'profile_photo_url',
|
|
||||||
'options' => ['display_currency', 'locale'],
|
|
||||||
'created_at',
|
|
||||||
'updated_at',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_profile_returns_correct_user_data(): void
|
|
||||||
{
|
|
||||||
$this->actingAs($this->user)
|
|
||||||
->getJson(route('api.me'))
|
|
||||||
->assertOk()
|
|
||||||
->assertJsonFragment([
|
|
||||||
'id' => $this->user->id,
|
|
||||||
'name' => $this->user->name,
|
|
||||||
'email' => $this->user->email,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_profile_returns_correct_options(): void
|
|
||||||
{
|
|
||||||
$this->actingAs($this->user)
|
|
||||||
->getJson(route('api.me'))
|
|
||||||
->assertOk()
|
|
||||||
->assertJsonPath('options.display_currency', $this->user->getCurrency())
|
|
||||||
->assertJsonPath('options.locale', $this->user->getLocale());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_cannot_access_profile_when_unauthenticated(): void
|
|
||||||
{
|
|
||||||
$this->getJson(route('api.me'))->assertUnauthorized();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_profile_does_not_expose_password(): void
|
|
||||||
{
|
|
||||||
$response = $this->actingAs($this->user)
|
|
||||||
->getJson(route('api.me'))
|
|
||||||
->assertOk();
|
|
||||||
|
|
||||||
$this->assertArrayNotHasKey('password', $response->json());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user