Compare commits

...

6 Commits

Author SHA1 Message Date
hackerESQ ee51cb7e2a fix: division by zero error 2025-07-12 00:40:37 -05:00
hackerESQ 40120c7027 fix: delay queued currency rates filling 2025-07-11 22:38:09 -05:00
hackerESQ cfd5b8a4f3 feat: default to pgsql 2025-07-11 22:13:16 -05:00
hackerESQ 3b93e328d5 feat: fancy ascii art 2025-07-11 21:43:36 -05:00
hackerESQ 1fd858287d fix: clear and re-create caches 2025-07-11 21:42:11 -05:00
hackerESQ e370f5bbb7 fix: clear cache after every reload 2025-07-11 21:33:58 -05:00
5 changed files with 41 additions and 23 deletions
+3 -1
View File
@@ -134,9 +134,11 @@ class CurrencyRate extends Model
if (is_array($currency)) { if (is_array($currency)) {
$i = 1;
foreach ($currency as $curr) { foreach ($currency as $curr) {
dispatch(fn () => self::timeSeriesRates($curr, $start, $end)); dispatch(fn () => self::timeSeriesRates($curr, $start, $end))->delay(now()->addSeconds(30 * $i));
$i++;
} }
return []; return [];
+5 -2
View File
@@ -99,8 +99,11 @@ class DailyChange extends Model
'tx1.quantity', 'tx1.quantity',
]) ])
->selectRaw("(CASE ->selectRaw("(CASE
WHEN tx1.transaction_type = 'BUY' WHEN
THEN COALESCE(cr.rate, 1) tx1.transaction_type = 'BUY'
OR SUM(tx1.cost_basis_base) = 0
THEN
COALESCE(cr.rate, 1)
ELSE ( ELSE (
SELECT SELECT
SUM(COALESCE(cr2.rate, 1) * buy.cost_basis_base) SUM(COALESCE(cr2.rate, 1) * buy.cost_basis_base)
+5 -2
View File
@@ -302,8 +302,11 @@ class Holding extends Model
]) ])
->selectRaw( ->selectRaw(
"(CASE "(CASE
WHEN transactions.transaction_type = 'BUY' WHEN
THEN COALESCE(cr.rate, 1) transactions.transaction_type = 'BUY'
OR SUM(transactions.cost_basis_base) = 0
THEN
COALESCE(cr.rate, 1)
ELSE ( ELSE (
SELECT SELECT
SUM(COALESCE(cr2.rate, 1) * buy.cost_basis_base) SUM(COALESCE(cr2.rate, 1) * buy.cost_basis_base)
+15 -15
View File
@@ -11,9 +11,9 @@ services:
- 8000:80 - 8000:80
environment: # You can either use these properties OR an .env file. Do not use both! environment: # You can either use these properties OR an .env file. Do not use both!
APP_URL: "http://localhost:8000" APP_URL: "http://localhost:8000"
DB_CONNECTION: mysql DB_CONNECTION: pgsql
DB_HOST: investbrain-mysql DB_HOST: investbrain-pgsql
DB_PORT: 3306 DB_PORT: 5432
DB_DATABASE: investbrain DB_DATABASE: investbrain
DB_USERNAME: investbrain DB_USERNAME: investbrain
DB_PASSWORD: investbrain DB_PASSWORD: investbrain
@@ -25,7 +25,7 @@ services:
- investbrain-storage:/var/app/storage # You can use a volume... - investbrain-storage:/var/app/storage # You can use a volume...
# - /path/to/storage:/var/app/storage:delegated # ...or you can use a path on host # - /path/to/storage:/var/app/storage:delegated # ...or you can use a path on host
depends_on: depends_on:
- mysql - pgsql
- redis - redis
networks: networks:
- investbrain-network - investbrain-network
@@ -40,22 +40,22 @@ services:
- investbrain-redis:/data - investbrain-redis:/data
networks: networks:
- investbrain-network - investbrain-network
mysql: pgsql:
image: mysql:8.0 image: postgres:15-alpine
container_name: investbrain-mysql container_name: investbrain-pgsql
restart: unless-stopped restart: unless-stopped
ports:
- "5432:5432"
environment: environment:
MYSQL_DATABASE: ${DB_DATABASE:-investbrain} POSTGRES_DB: ${DB_DATABASE:-investbrain}
MYSQL_USER: ${DB_USERNAME:-investbrain} POSTGRES_USER: ${DB_USERNAME:-investbrain}
MYSQL_PASSWORD: ${DB_PASSWORD:-investbrain} POSTGRES_PASSWORD: ${DB_PASSWORD:-investbrain}
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-investbrain} command: postgres -c log_min_messages=error
command:
- --cte-max-recursion-depth=25000
volumes: volumes:
- investbrain-mysql:/var/lib/mysql - investbrain-pgsql:/var/lib/postgresql/data
networks: networks:
- investbrain-network - investbrain-network
volumes: volumes:
investbrain-storage: investbrain-storage:
investbrain-redis: investbrain-redis:
investbrain-mysql: investbrain-pgsql:
+13 -3
View File
@@ -3,7 +3,7 @@
cd /var/app cd /var/app
# Starting Investbrain # Starting Investbrain
echo "CiAgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKICAqICBJSUkgICBOICAgTiAgViAgIFYgIEVFRUVFICBTU1NTICBUVFRUVCAgQkJCQkIgICBSUlJSICAgIEFBQUFBICBJSUkgICBOICAgTiAgKgogICogICBJICAgIE5OICBOICBWICAgViAgRSAgICAgIFMgICAgICAgVCAgICBCICAgIEIgIFIgICBSICAgQSAgIEEgICBJICAgIE5OICBOICAqCiAgKiAgIEkgICAgTiBOIE4gIFYgICBWICBFRUVFICAgU1NTUyAgICBUICAgIEJCQkJCICAgUlJSUiAgICBBQUFBQSAgIEkgICAgTiBOIE4gICoKICAqICAgSSAgICBOICBOTiAgViAgIFYgIEUgICAgICAgICAgUyAgIFQgICAgQiAgICBCICBSICBSICAgIEEgICBBICAgSSAgICBOICBOTiAgKgogICogIElJSSAgIE4gICBOICAgVlZWICAgRUVFRUUgIFNTU1MgICAgVCAgICBCQkJCQiAgIFIgICBSICAgQSAgIEEgIElJSSAgIE4gICBOICAqCiAgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKICA=" | base64 -d echo "CuKWhOKWliAgICAgICAg4paXIOKWjCAgICAg4paYICAK4paQIOKWm+KWjOKWjOKWjOKWiOKWjOKWm+KWmOKWnOKWmOKWm+KWjOKWm+KWmOKWgOKWjOKWjOKWm+KWjArilp/ilpbilozilozilprilpjilpnilpbiloTilozilpDilpbilpnilozilowg4paI4paM4paM4paM4paMCg==" | base64 -d
echo -e "\n====================== Validating environment... ====================== " echo -e "\n====================== Validating environment... ====================== "
@@ -54,7 +54,6 @@ RETRIES=12
DELAY=5 DELAY=5
run_migrations() { run_migrations() {
sleep $DELAY sleep $DELAY
# php artisan migrate --force
output=$(php artisan migrate --force 2>/dev/null) output=$(php artisan migrate --force 2>/dev/null)
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
echo "$output" echo "$output"
@@ -72,7 +71,18 @@ until run_migrations; do
echo -e "\n > Waiting for database to be ready... retrying in $DELAY seconds. \n" echo -e "\n > Waiting for database to be ready... retrying in $DELAY seconds. \n"
done done
echo -e "\n====================== Cleaning up... ====================== \n"
# Clear caches
echo $(php artisan cache:clear)
echo $(php artisan view:clear)
echo $(php artisan route:clear)
echo $(php artisan event:clear)
# Re-create caches
echo $(php artisan route:cache)
echo $(php artisan event:cache)
echo -e "\n====================== Spinning up Supervisor daemon... ====================== \n" echo -e "\n====================== Spinning up Supervisor daemon... ====================== \n"
exec supervisord -c /etc/supervisor/conf.d/supervisord.conf exec supervisord -c /etc/supervisor/conf.d/supervisord.conf