segmentor 0.0.1 → 0.0.2.1

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: d3a3771e1ca065afddd976a3ce22d403989dd9467d1f371cef6d2cc30d17f259
4
- data.tar.gz: 451cca6659b4d22073d9a4347866bf5723ac4085acd3e71c3888f642d3834bcd
3
+ metadata.gz: a396acf186b75de0636845a28ca0aa06bd16afa02004a058e1c5ef842883136c
4
+ data.tar.gz: 739c511245fcb13837aaafa41c92509c6afff905d8090cea27e9c8674a69be13
5
5
  SHA512:
6
- metadata.gz: 662d9453ae4125ecaa0f8fd4abb41bbd0feba4618b453cf996f62bf395e7a064bec0e399c965b9be21e36fada1b774afd5e3ce27be3f6ae70de4e2df585a16f5
7
- data.tar.gz: c6ebb71294d1f08e9c3e7f6b93a3460294bb0f7f9b2e425e7eeeb25dd11353a53d400918e86838d5cdb7d0e650ea4f3d8b3717ff31cdf094170224cf9565365e
6
+ metadata.gz: 51407c810d6d85e455183cbe1a062149e02a01e1d923fd2d58cdf824b68a7891a46de0befc58daa08a1f7155a34105ffbeb466cb123a471171c56279ae448c75
7
+ data.tar.gz: 01c00358a331d554feb9e002ada1aef5bbebe676b8f1ae1dd6d5aff26d9503cf699d11274fff7db1e30adcfc2395458d05c564975301c9da4b0d7465b5f3b2cc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- segmentor (0.0.1)
4
+ segmentor (0.0.2.1)
5
5
  actionpack (~> 6.1)
6
6
  activerecord (~> 6.1)
7
7
  activesupport (~> 6.1)
@@ -6,7 +6,8 @@ class CreateSegmentorTables < ActiveRecord::Migration[6.1]
6
6
  create_table :segmentor_segments, force: true do |t|
7
7
  t.string :name
8
8
  t.string :description
9
- t.integer :repeat_frequency, default: 0
9
+ t.integer :generate_frequency, default: 0
10
+ t.integer :notify_frequency, default: 0
10
11
  t.boolean :auto_activate, default: false
11
12
 
12
13
  t.timestamps
@@ -23,8 +23,12 @@ module Segmentor
23
23
  self._after_session_change = method_name
24
24
  end
25
25
 
26
- # repeat_frequency is in days, should be between 0 and 365. 0 means no repeat
27
- validates :repeat_frequency, numericality: { only_integer: true,
26
+ # generate_frequency is in days, should be between 0 and 365. 0 means no repeat
27
+ validates :generate_frequency, numericality: { only_integer: true,
28
+ greater_than_or_equal_to: 0,
29
+ less_than_or_equal_to: 365 }
30
+ # generate_frequency is in days, should be between 0 and 365. 0 means no repeat
31
+ validates :notify_frequency, numericality: { only_integer: true,
28
32
  greater_than_or_equal_to: 0,
29
33
  less_than_or_equal_to: 365 }
30
34
 
@@ -98,6 +102,11 @@ module Segmentor
98
102
  latest_session.mark_as_draft!
99
103
  end
100
104
 
105
+ def last_run
106
+ # latest_session is going to be either active, draft or failed
107
+ latest_session.try(:updated_at)
108
+ end
109
+
101
110
  # turns a session from draft into active and marks
102
111
  # the current active session as archived.
103
112
  # if no current active session is found. the latest session is marked as active
@@ -127,10 +136,13 @@ module Segmentor
127
136
  as
128
137
  end
129
138
 
130
- def latest_session
139
+ def latest_session(include_running: false)
140
+ unaccepted_status = [::Segmentor::Session::ARCHIVED]
141
+ unaccepted_status << ::Segmentor::Session::IN_PROGRESS unless include_running
142
+
131
143
  # pick the latest session that's not in progress or archived
132
144
  sessions.where
133
- .not(status: [::Segmentor::Session::ARCHIVED, ::Segmentor::Session::IN_PROGRESS])
145
+ .not(status: unaccepted_status)
134
146
  .order(created_at: :desc)
135
147
  .first
136
148
  end
@@ -52,8 +52,8 @@ module Segmentor
52
52
  # we have a receipt. notify only if:
53
53
  # segment repeat frequency is not NO_REPEAT
54
54
  # receipt is older than segment repeat frequency
55
- segment.repeat_frequency != ::Segmentor::Segment::NO_REPEAT &&
56
- most_recent_receipt.sent_at < segment.repeat_frequency.days.ago
55
+ segment.notify_frequency != ::Segmentor::Segment::NO_REPEAT &&
56
+ most_recent_receipt.sent_at < segment.notify_frequency.days.ago
57
57
  end
58
58
 
59
59
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Segmentor
4
- VERSION ||= "0.0.1"
4
+ VERSION ||= "0.0.2.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: segmentor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Khash Sajadi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-06 00:00:00.000000000 Z
11
+ date: 2022-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack