fuck_facebook 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: acfe1137400e4f4cc8fc79f7d0222eb8617eb72032fade8f975da0c638967a7a
4
- data.tar.gz: ef0b084adbf6017d96b008792efc158bde131df714bbc9382738394bcbf01462
3
+ metadata.gz: 328dfd9c415343629b2aeb3f83e6252fa2ee0c882be23f441442e0170781a0e0
4
+ data.tar.gz: 13369d4a2a3bb32d672385cb47776cdfd37ecb8159c2314d78cefb52ae0376fd
5
5
  SHA512:
6
- metadata.gz: bf839aa8b6b7b0803588021a3d444e6ef641240569a0ed72a98eed6a66f9a123498a8891c1c25218ea47bb005110d64861acb1a277b553f096ced32d40b50c1c
7
- data.tar.gz: ad427fa1ae23c9abf1c2d78db1b547c7f4cc73ce0b12dbefc57c443a5ac2fd7812924c543fb60d1159fe5e421dc0442d6c0ef7fc8e846c6863c4687d3e36fe29
6
+ metadata.gz: 111cd999cfa8dddbfbb72c36ace0dbed922b57a0ed653c3726541bba8f2a17f1bdfc4188e832a07cb6e0cf46938e52218e1973a9ab4b2dce92453d018e2fefee
7
+ data.tar.gz: 44d2fa65bb1b48e4f2294cb314cdd63609135fd4b028e929937f4141064563acba59ec1db3552459d22c92e151d9c42b85941ebd1e423235e67d510880522283
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fuck_facebook (0.5.1)
4
+ fuck_facebook (0.5.2)
5
5
  activesupport (~> 6.1)
6
6
  highline (~> 2.0)
7
7
  mail (~> 2.7)
@@ -1,3 +1,3 @@
1
1
  module FuckFacebook
2
- VERSION = '0.5.2'.freeze
2
+ VERSION = '0.5.3'.freeze
3
3
  end
data/src/fb_duration.rb CHANGED
@@ -3,29 +3,40 @@ require 'active_support/core_ext/numeric/time'
3
3
  class FbDuration
4
4
  DURATION_LETTER_TO_METHOD = {
5
5
  'm' => :minutes,
6
- 'd' => :days,
7
6
  'h' => :hours,
7
+ 'd' => :days,
8
8
  'w' => :weeks,
9
9
  'y' => :years
10
10
  }.freeze
11
11
 
12
12
  DURATION_LETTER_TO_BEGINNING_OF_METHOD = {
13
13
  'm' => :beginning_of_minute,
14
- 'd' => :beginning_of_day,
15
14
  'h' => :beginning_of_hour,
15
+ 'd' => :beginning_of_day,
16
16
  'w' => :beginning_of_week,
17
17
  'y' => :beginning_of_year
18
18
  }.freeze
19
19
 
20
+ # TODO: Fill in d w y extra time to add
21
+ EXTRA_TIME_TO_ADD_TO_FIX_ROUNDING = {
22
+ 'm' => 0,
23
+ 'h' => 5.minutes,
24
+ 'd' => 0,
25
+ 'w' => 0,
26
+ 'y' => 0
27
+ }
28
+
20
29
  def self.parse_to_time(facebook_format_duration)
21
30
  duration = parse(facebook_format_duration)
22
31
  time_to_beginning_of_duration_letter(Time.now - duration, facebook_format_duration)
23
32
  end
24
33
 
25
34
  def self.parse(facebook_format_duration)
26
- segments = facebook_format_duration.split
35
+ number, duration_letter = facebook_format_duration.split
36
+
37
+ extra_rounding_time = EXTRA_TIME_TO_ADD_TO_FIX_ROUNDING[duration_letter]
27
38
 
28
- segments[0].to_i.send(DURATION_LETTER_TO_METHOD[segments[1]])
39
+ number.to_i.send(DURATION_LETTER_TO_METHOD[duration_letter]) + extra_rounding_time
29
40
  end
30
41
 
31
42
  def self.time_to_beginning_of_duration_letter(time, facebook_format_duration)
@@ -53,12 +53,13 @@ class MessageHandler
53
53
  end
54
54
 
55
55
  def messages_after_last_message_time(messages)
56
- last_message_check_time = Storage.get(:last_message_check_time, default: Time.new(2004, 2, 4))
57
- last_check_time_with_buffer = last_message_check_time - 5.minutes
56
+ last_message_time = Storage.get(:last_message_time, default: Time.new(2004, 2, 4))
58
57
 
59
- messages_to_return = messages.select { _1.timestamp > last_check_time_with_buffer }
58
+ messages_to_return = messages.select { _1.timestamp > last_message_time }
60
59
 
61
- Storage.set(:last_message_check_time, Time.now)
60
+ last_message_time = messages.map(&:timestamp).max
61
+
62
+ Storage.set(:last_message_time, last_message_time)
62
63
 
63
64
  messages_to_return
64
65
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuck_facebook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keeyan Nejad
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-25 00:00:00.000000000 Z
11
+ date: 2021-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport