nexo 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 762b84bd5b5d458091d881a7227c7680048e1ae206e4eef1e6d94246e7be238b
4
- data.tar.gz: e5358a64b012b93ffbc7a2f67c21e5179df2d7a7a5581771c1ee97c2466b20e9
3
+ metadata.gz: bf53f0b9f6a1041943a11b96d6688fc0506528d29d855615fb651f56d7dfdb81
4
+ data.tar.gz: 1b707625c9f1f621daf84912c2bb2de01e008f4b7d7024c31dae0c7fa6019448
5
5
  SHA512:
6
- metadata.gz: ecf2eb80621fdce1e6d137dc6d5122fe66db21d893349a86e75d1e4251f73dd120eb6cc3e7f2d899b461a118a20dee7e4fa60ed919819a15204a4787fcde7ca2
7
- data.tar.gz: 2389d6ea2996feeeae34a3256ca89037f5d2b0acf658d6e02345d349b5e44712870fd32ed3e7e3421dcd37a1068be3aa83ecba5e74cf221ad312f4797659ca88
6
+ metadata.gz: 536a191c758d2ac7ccab8a5780a1d568820723571b9682382b71b5324de83109179882a1777b2a7380061e8289efec8c9c0e470c8f758ba2ec26a1c57117e575
7
+ data.tar.gz: 2f5509307f988bcf11bd57e7582713f7d2dd187f53a6e915ca43050c476363ea427c43cd811ce7a968c90422bf560e79f530aec7f4d4a4fcb001856a2e448514
@@ -7,6 +7,9 @@ module Nexo
7
7
 
8
8
  queue_as :api_clients
9
9
 
10
+ # TODO!: configure good job queues and thread pools
11
+ # https://github.com/bensheldon/good_job?tab=readme-ov-file#optimize-queues-threads-and-processes
12
+ # TODO: make this configurable, so other job backends are allowed
10
13
  good_job_control_concurrency_with(
11
14
  perform_limit: 1,
12
15
 
@@ -18,7 +21,10 @@ module Nexo
18
21
  retry_on(
19
22
  GoodJob::ActiveJobExtensions::Concurrency::ConcurrencyExceededError,
20
23
  attempts: Float::INFINITY,
21
- wait: ->(executions) { ((executions**3) + (Kernel.rand * (executions**3) * 0.5)) + 2 }
24
+ wait: :polynomially_longer,
25
+ jitter: 0.99,
26
+ # wait: ->(executions) { ((executions**4) + (Kernel.rand * (executions**4) * jitter)) + 2 }
27
+ # wait: ->(executions) { ((executions**3) + (Kernel.rand * (executions**3) * 0.5)) + 2 }
22
28
  )
23
29
  end
24
30
  end
@@ -14,6 +14,8 @@ module Nexo
14
14
  class SyncElementJob < BaseJob
15
15
  limits_concurrency key: ->(element) { element.to_gid }
16
16
 
17
+ # TODO!: set priority based on date distance to today
18
+
17
19
  # discard_on Errors::SyncElementJobError
18
20
  # retry_on StandardError, wait: :polynomially_longer
19
21
 
@@ -26,6 +26,18 @@ module Nexo
26
26
  private
27
27
 
28
28
  def validate_element_state!
29
+ if element.synchronizable.blank?
30
+ raise Errors::SynchronizableNotFound
31
+ end
32
+
33
+ if element.synchronizable.respond_to?(:discarded?) && element.synchronizable.discarded?
34
+ raise Errors::SynchronizableDiscarded
35
+ end
36
+
37
+ if element.folder.discarded?
38
+ raise Errors::FolderDiscarded
39
+ end
40
+
29
41
  if element.synchronizable.conflicted?
30
42
  raise Errors::ElementConflicted
31
43
  end
@@ -7,6 +7,8 @@ module Nexo
7
7
  class ElementAlreadySynced < Error; end
8
8
  class MoreThanOneElementInFolderForSynchronizable < Error; end
9
9
  class InvalidFolderState < Error; end
10
+ class FolderDiscarded < Error; end
11
+ class SynchronizableDiscarded < Error; end
10
12
 
11
13
  # on ControllerHelper
12
14
  class InvalidParamsError < Error; end
@@ -29,8 +29,7 @@ module Nexo
29
29
  enum :service, google: 0
30
30
  enum :tcp_status, authorized: 0, disabled: 1, expired: 2
31
31
 
32
- validates :service, :user_integrations_allowed,
33
- :tcp_status, :secret, presence: true
32
+ validates :service, :tcp_status, :secret, presence: true
34
33
 
35
34
  serialize :secret, coder: JSON
36
35
 
@@ -5,7 +5,6 @@ class CreateNexoClients < ActiveRecord::Migration[7.2]
5
5
  t.string :secret
6
6
  t.integer :tcp_status
7
7
  t.integer :brand_name
8
- t.boolean :user_integrations_allowed
9
8
 
10
9
  t.timestamps
11
10
  end
data/db/seeds.rb CHANGED
@@ -1,3 +1,28 @@
1
1
  module Nexo
2
- # Nexo seeds
2
+ ENV.fetch('SEED_GOOGLE_APIS_CLIENT_SECRET', nil) || puts("WARN: env variable SEED_GOOGLE_APIS_CLIENT_SECRET not found")
3
+ ENV.fetch('SEED_GOOGLE_APIS_TOKEN', nil) || puts("WARN: env variable SEED_GOOGLE_APIS_TOKEN not found")
4
+
5
+ if ENV.fetch('SEED_GOOGLE_APIS_CLIENT_SECRET', nil)
6
+ client = Client.create!(
7
+ tcp_status: 0,
8
+ service: "google",
9
+ secret: JSON.parse(ENV.fetch('SEED_GOOGLE_APIS_CLIENT_SECRET'))
10
+ )
11
+ user = User.first
12
+ integration = Nexo::Integration.create!(
13
+ user:,
14
+ client:,
15
+ name: "Default integration",
16
+ scope: [ "auth_calendar_app_created" ]
17
+ )
18
+
19
+ if ENV.fetch('SEED_GOOGLE_APIS_TOKEN', nil)
20
+ Nexo::Token.create!(
21
+ integration:,
22
+ secret: ENV.fetch('SEED_GOOGLE_APIS_TOKEN'),
23
+ tpt_status: :active,
24
+ environment: "development"
25
+ )
26
+ end
27
+ end
3
28
  end
data/lib/nexo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # :nocov: non-viable
2
2
  module Nexo
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  # :nocov:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso