From 32ca1fa4322b8e74ef17b92e9a72a1d7e9f751e1 Mon Sep 17 00:00:00 2001 From: Claude Ayitey Date: Sat, 6 Jan 2024 14:57:33 +0000 Subject: [PATCH] Changed perform_asnyc to perform sincen GoodJob does not use perform_async --- app/controllers/accounts_controller.rb | 8 +++---- app/controllers/api/plaid_controller.rb | 10 ++++----- app/controllers/connections_controller.rb | 2 +- app/controllers/conversations_controller.rb | 4 ++-- app/models/security.rb | 2 +- lib/tasks/maintenance.rake | 24 ++++++++++----------- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index dcca2c6c..d7144454 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -103,11 +103,11 @@ class AccountsController < ApplicationController # Save the account if @account.save - GenerateBalanceJob.perform_async(@account.id) + GenerateBalanceJob.perform(@account.id) GenerateMetricsJob.perform_in(15.seconds, current_family.id) if @account.kind == 'property' and @account.subkind == 'real_estate' - SyncPropertyValuesJob.perform_async(@account.id) + SyncPropertyValuesJob.perform(@account.id) end # If the account saved, redirect to the accounts page @@ -130,7 +130,7 @@ class AccountsController < ApplicationController # Find or create a new "Manual Bank" connection @connection = Connection.find_or_create_by(user: current_user, family: current_family, name: "Manual", source: "manual") @account = Account.new - + render layout: 'simple' end @@ -160,7 +160,7 @@ class AccountsController < ApplicationController # Find or create a new "Manual Bank" connection @connection = Connection.find_or_create_by(user: current_user, family: current_family, name: "Manual", source: "manual") @account = Account.new - + render layout: 'simple' end diff --git a/app/controllers/api/plaid_controller.rb b/app/controllers/api/plaid_controller.rb index 596f6af8..c4edcf9d 100644 --- a/app/controllers/api/plaid_controller.rb +++ b/app/controllers/api/plaid_controller.rb @@ -16,7 +16,7 @@ class Api::PlaidController < ApplicationController item_id = exchange_token_response.item_id item_get_request = Plaid::ItemGetRequest.new({ access_token: access_token}) - item_response = $plaid_api_client.item_get(item_get_request) + item_response = $plaid_api_client.item_get(item_get_request) aggregator_id = item_response.item.institution_id consent_expiration = item_response.item.consent_expiration_time @@ -41,11 +41,11 @@ class Api::PlaidController < ApplicationController ) user.save! - SyncPlaidItemAccountsJob.perform_async(item_id) + SyncPlaidItemAccountsJob.perform(item_id) + + # SyncPlaidHoldingsJob.perform(item_id) + # SyncPlaidInvestmentTransactionsJob.perform(item_id) - # SyncPlaidHoldingsJob.perform_async(item_id) - # SyncPlaidInvestmentTransactionsJob.perform_async(item_id) - GenerateMetricsJob.perform_in(1.minute, user.family.id) render json: { diff --git a/app/controllers/connections_controller.rb b/app/controllers/connections_controller.rb index ef2c532e..ea7fd6e3 100644 --- a/app/controllers/connections_controller.rb +++ b/app/controllers/connections_controller.rb @@ -10,7 +10,7 @@ class ConnectionsController < ApplicationController @connection = current_family.connections.find(params[:id]) @connection.destroy - GenerateMetricsJob.perform_async(current_family.id) + GenerateMetricsJob.perform(current_family.id) redirect_to connections_path end diff --git a/app/controllers/conversations_controller.rb b/app/controllers/conversations_controller.rb index 06661cd7..2bef2067 100644 --- a/app/controllers/conversations_controller.rb +++ b/app/controllers/conversations_controller.rb @@ -37,8 +37,8 @@ class ConversationsController < ApplicationController reply.user = nil reply.role = "assistant" reply.save - - AskQuestionJob.perform_async(@conversation.id, reply.id) + + AskQuestionJob.perform(@conversation.id, reply.id) #conversation.broadcast_append_to "conversation_area", partial: "conversations/message", locals: { message: reply }, target: "conversation_area_#{conversation.id}" diff --git a/app/models/security.rb b/app/models/security.rb index 95ca7195..e3855b16 100644 --- a/app/models/security.rb +++ b/app/models/security.rb @@ -7,6 +7,6 @@ class Security < ApplicationRecord after_create :sync_price_history def sync_price_history - SyncSecurityHistoryJob.perform_async(self.id) + SyncSecurityHistoryJob.perform(self.id) end end diff --git a/lib/tasks/maintenance.rake b/lib/tasks/maintenance.rake index 066a691c..8e64f4df 100644 --- a/lib/tasks/maintenance.rake +++ b/lib/tasks/maintenance.rake @@ -2,48 +2,48 @@ namespace :maintenance do desc "Quick Update" task :quick_update => :environment do Connection.all.each do |connection| - SyncPlaidItemAccountsJob.perform_async(connection.item_id) - SyncPlaidHoldingsJob.perform_async(connection.item_id) - SyncPlaidInvestmentTransactionsJob.perform_async(connection.item_id) + SyncPlaidItemAccountsJob.perform(connection.item_id) + SyncPlaidHoldingsJob.perform(connection.item_id) + SyncPlaidInvestmentTransactionsJob.perform(connection.item_id) GenerateMetricsJob.perform_in(1.minute, connection.family_id) end - EnrichTransactionsJob.perform_async + EnrichTransactionsJob.perform # Sync security prices that haven't been synced in the last 24 hours or are nil Security.where("last_synced_at IS NULL OR last_synced_at < ?", 24.hours.ago).each do |security| - SyncSecurityHistoryJob.perform_async(security.id) + SyncSecurityHistoryJob.perform(security.id) end # Sync security real time prices that haven't been synced in the last 30 minutes or are nil Security.where("real_time_price_updated_at IS NULL OR real_time_price_updated_at < ?", 30.minutes.ago).each do |security| - RealTimeSyncJob.perform_async(security.id) + RealTimeSyncJob.perform(security.id) end Account.all.each do |account| - GenerateBalanceJob.perform_async(account.id) + GenerateBalanceJob.perform(account.id) end Account.property.each do |account| - SyncPropertyValuesJob.perform_async(account.id) + SyncPropertyValuesJob.perform(account.id) end Family.all.each do |family| - GenerateCategoricalMetricsJob.perform_async(family.id) + GenerateCategoricalMetricsJob.perform(family.id) end end desc "Institution Sync" task :institution_sync => :environment do - SyncPlaidInstitutionsJob.perform_async + SyncPlaidInstitutionsJob.perform_now end desc "Security Details Sync" task :security_details_sync => :environment do # Get Security where logo is nil Security.where(logo: nil).each do |security| - SyncSecurityDetailsJob.perform_async(security.id) + SyncSecurityDetailsJob.perform(security.id) end end @@ -65,4 +65,4 @@ namespace :maintenance do end end end -end \ No newline at end of file +end