mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-25 16:19:40 +02:00
Adjust queues to prioritize account syncs (#1682)
This commit is contained in:
parent
7d04ea1071
commit
3140835f28
12 changed files with 37 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
||||||
class AutoUpgradeJob < ApplicationJob
|
class AutoUpgradeJob < ApplicationJob
|
||||||
queue_as :default
|
queue_as :latency_low
|
||||||
|
|
||||||
def perform(*args)
|
def perform(*args)
|
||||||
raise_if_disabled
|
raise_if_disabled
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class DestroyJob < ApplicationJob
|
class DestroyJob < ApplicationJob
|
||||||
queue_as :default
|
queue_as :latency_low
|
||||||
|
|
||||||
def perform(model)
|
def perform(model)
|
||||||
model.destroy
|
model.destroy
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class EnrichDataJob < ApplicationJob
|
class EnrichDataJob < ApplicationJob
|
||||||
queue_as :default
|
queue_as :latency_high
|
||||||
|
|
||||||
def perform(account)
|
def perform(account)
|
||||||
account.enrich_data
|
account.enrich_data
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class FetchSecurityInfoJob < ApplicationJob
|
class FetchSecurityInfoJob < ApplicationJob
|
||||||
queue_as :default
|
queue_as :latency_low
|
||||||
|
|
||||||
def perform(security_id)
|
def perform(security_id)
|
||||||
return unless Security.security_info_provider.present?
|
return unless Security.security_info_provider.present?
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class ImportJob < ApplicationJob
|
class ImportJob < ApplicationJob
|
||||||
queue_as :default
|
queue_as :latency_medium
|
||||||
|
|
||||||
def perform(import)
|
def perform(import)
|
||||||
import.publish
|
import.publish
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class SyncJob < ApplicationJob
|
class SyncJob < ApplicationJob
|
||||||
queue_as :default
|
queue_as :latency_medium
|
||||||
|
|
||||||
def perform(sync)
|
def perform(sync)
|
||||||
sync.perform
|
sync.perform
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class UserPurgeJob < ApplicationJob
|
class UserPurgeJob < ApplicationJob
|
||||||
queue_as :default
|
queue_as :latency_low
|
||||||
|
|
||||||
def perform(user)
|
def perform(user)
|
||||||
user.purge
|
user.purge
|
||||||
|
|
|
@ -37,6 +37,14 @@ class TimeSeries
|
||||||
series: self
|
series: self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def empty?
|
||||||
|
values.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def has_current_day_value?
|
||||||
|
values.any? { |v| v.date == Date.current }
|
||||||
|
end
|
||||||
|
|
||||||
# `as_json` returns the data shape used by D3 charts
|
# `as_json` returns the data shape used by D3 charts
|
||||||
def as_json
|
def as_json
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,15 +17,19 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="h-64">
|
<div class="h-64">
|
||||||
<% if series %>
|
<% if series.has_current_day_value? %>
|
||||||
<div
|
<div
|
||||||
id="lineChart"
|
id="lineChart"
|
||||||
class="w-full h-full"
|
class="w-full h-full"
|
||||||
data-controller="time-series-chart"
|
data-controller="time-series-chart"
|
||||||
data-time-series-chart-data-value="<%= series.to_json %>"></div>
|
data-time-series-chart-data-value="<%= series.to_json %>"></div>
|
||||||
|
<% elsif series.empty? %>
|
||||||
|
<div class="w-full h-full flex items-center justify-center">
|
||||||
|
<p class="text-gray-500 text-sm">No data available for the selected period.</p>
|
||||||
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="w-full h-full flex items-center justify-center">
|
<div class="w-full h-full flex items-center justify-center">
|
||||||
<p class="text-gray-500">No data available for the selected period.</p>
|
<p class="text-gray-500 text-sm animate-pulse">Calculating latest balance data...</p>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
<%# locals: (series:) %>
|
<%# locals: (series:) %>
|
||||||
<% if series %>
|
<% if series.has_current_day_value? %>
|
||||||
<div
|
<div
|
||||||
id="netWorthChart"
|
id="netWorthChart"
|
||||||
class="w-full flex-1 min-h-52"
|
class="w-full flex-1 min-h-52"
|
||||||
data-controller="time-series-chart"
|
data-controller="time-series-chart"
|
||||||
data-time-series-chart-data-value="<%= series.to_json %>"></div>
|
data-time-series-chart-data-value="<%= series.to_json %>"></div>
|
||||||
|
<% elsif series.empty? %>
|
||||||
|
<div class="w-full h-full flex items-center justify-center">
|
||||||
|
<p class="text-gray-500 text-sm">No data available for the selected period.</p>
|
||||||
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="w-full h-full flex items-center justify-center">
|
<div class="w-full h-full flex items-center justify-center">
|
||||||
<p class="text-gray-500">No data available for the selected period.</p>
|
<p class="text-gray-500 text-sm animate-pulse">Calculating latest balance data...</p>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
default: &default
|
default: &default
|
||||||
adapter: postgresql
|
adapter: postgresql
|
||||||
encoding: unicode
|
encoding: unicode
|
||||||
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
# 3 connections for Puma, 8 for GoodJob (in async mode, the default for self-hosters) = 11 connections
|
||||||
|
pool: <%= ENV.fetch("DB_POOL_SIZE") { 11 } %>
|
||||||
host: <%= ENV.fetch("DB_HOST") { "127.0.0.1" } %>
|
host: <%= ENV.fetch("DB_HOST") { "127.0.0.1" } %>
|
||||||
port: <%= ENV.fetch("DB_PORT") { "5432" } %>
|
port: <%= ENV.fetch("DB_PORT") { "5432" } %>
|
||||||
user: <%= ENV.fetch("POSTGRES_USER") { nil } %>
|
user: <%= ENV.fetch("POSTGRES_USER") { nil } %>
|
||||||
|
|
|
@ -11,6 +11,14 @@ Rails.application.configure do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 5 queue threads + 3 for job listener, cron, executor = 8 threads allocated
|
||||||
|
config.queues = {
|
||||||
|
"latency_low" => { max_threads: 1, priority: 10 }, # ~30s jobs
|
||||||
|
"latency_low,latency_medium" => { max_threads: 2, priority: 5 }, # ~1-2 min jobs
|
||||||
|
"latency_low,latency_medium,latency_high" => { max_threads: 1, priority: 1 }, # ~5+ min jobs
|
||||||
|
"*" => { max_threads: 1, priority: 0 } # fallback queue
|
||||||
|
}
|
||||||
|
|
||||||
# Auth for jobs admin dashboard
|
# Auth for jobs admin dashboard
|
||||||
ActiveSupport.on_load(:good_job_application_controller) do
|
ActiveSupport.on_load(:good_job_application_controller) do
|
||||||
before_action do
|
before_action do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue