toggl_cache 0.2.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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +4 -0
  3. data/VERSION +1 -1
  4. data/lib/toggl_cache.rb +15 -11
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5c97e1c35e17dd0e4e74f0194eefb1b9d100199
4
- data.tar.gz: c4b6bfe066da7c539256d39dc98c00539795e7ec
3
+ metadata.gz: 6e83c9bbbb499c8115a5f60c5606c6ad9589af93
4
+ data.tar.gz: e09117cc40b710b0096fd83ad602b946e11dcb7e
5
5
  SHA512:
6
- metadata.gz: d4f4ce467a89a23278e731de36b6a2e0df90d6164eb742a87e496f9c42667c232d7764df84b0a0c2b90a0ad0780d640fd65a7715c098ca70f29a04864fa34f41
7
- data.tar.gz: 167afe2ed80546b63b0007e69dab6bd1d5ce2fd7a49deff03cf975a4578bbe16194c0cfcaf9e1d5b88812cc1ad9714230f5368a9b7ad6930c01fdb387c1f02f1
6
+ metadata.gz: 9b721bf3650aaf6081615573f114838d07bc6cebbf6efd440afb4b8f2ddfffa78327600d6e002194fd1d0ad09c21dd3e5d6f24a6af8f05263e65c50b01419f02
7
+ data.tar.gz: cc31f8dad8f31396c37fc6758004df251703cc6653bcc8785b36be17b4f5c6979d67dc1b161e4bb91b214b345576876fb57fb2f8c686502a13a507ee8a1e6a4c
data/HISTORY.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # History
2
2
 
3
+ ## 2017-04-01 - 0.2.1
4
+
5
+ - Hotfix: bugs in `TogglCache`.
6
+
3
7
  ## 2017-03-25 - 0.2.0
4
8
 
5
9
  Synchronizing deleted records and old changes.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/lib/toggl_cache.rb CHANGED
@@ -33,7 +33,8 @@ module TogglCache
33
33
  logger.info "Syncing reports from #{date_since} to #{date_until}."
34
34
  clear_cache(
35
35
  time_since: Time.parse("#{date_since} 00:00:00Z"),
36
- time_until: Time.parse("#{date_until} 23:59:59Z")
36
+ time_until: Time.parse("#{date_until} 23:59:59Z"),
37
+ logger: logger
37
38
  )
38
39
  fetch_reports(
39
40
  client: client,
@@ -48,7 +49,7 @@ module TogglCache
48
49
  # report in the cache to now. Proceeds by comparing reports total
49
50
  # duration from Toggl (using the Reports API) and the total contained
50
51
  # in the cache. If a difference is detected, proceeds monthly and
51
- # clear and reconstructs the cache for the invovled month.
52
+ # clear and reconstructs the cache for the concerned month.
52
53
  #
53
54
  # TODO: enable detecting a change in project/task level aggregates.
54
55
  def self.sync_check_and_fix(logger: default_logger)
@@ -77,8 +78,8 @@ module TogglCache
77
78
  logger.info "Checked total for #{year}/#{month}: ✅ (#{month_toggl})"
78
79
  else
79
80
  logger.info "Checked total for #{year}/#{month}: ❌ (Toggl: #{month_toggl}, cache: #{month_cache})"
80
- TogglCache.clear_cache(year: year, month: month)
81
- TogglCache.sync_reports_for_month(year: year, month: month)
81
+ TogglCache.clear_cache_for_month(year: year, month: month, logger: logger)
82
+ TogglCache.sync_reports_for_month(year: year, month: month, logger: logger)
82
83
  end
83
84
  end
84
85
  end
@@ -87,20 +88,22 @@ module TogglCache
87
88
  # An easy-to-use method to sync reports for a given month. Simply
88
89
  # performs a call to `sync_reports`.
89
90
  #
90
- # @param year [Integer]
91
- # @param month [Integer
92
- def self.sync_reports_for_month(year:, month:)
91
+ # @param year: [Integer]
92
+ # @param month: [Integer
93
+ # @param logger: [Logger] (optional)
94
+ def self.sync_reports_for_month(year:, month:, logger: default_logger)
93
95
  date_since = Date.civil(year, month, 1)
94
96
  date_until = Date.civil(year, month, -1)
95
97
  sync_reports(
96
98
  date_since: date_since,
97
- date_until: date_until
99
+ date_until: date_until,
100
+ logger: logger
98
101
  )
99
102
  end
100
103
 
101
104
  # Remove TogglCache's reports between the specified dates.
102
- def self.clear_cache(time_since:, time_until:)
103
- logger.info "Clearing cache from #{date_since} to #{date_until}."
105
+ def self.clear_cache(time_since:, time_until:, logger: default_logger)
106
+ logger.info "Clearing cache from #{time_since} to #{time_until}."
104
107
  reports = Data::ReportRepository.new
105
108
  reports.delete_starting(
106
109
  time_since: time_since,
@@ -114,7 +117,8 @@ module TogglCache
114
117
  date_until = Date.civil(year, month, -1)
115
118
  clear_cache(
116
119
  time_since: Time.parse("#{date_since} 00:00:00Z"),
117
- time_until: Time.parse("#{date_until} 23:59:59Z")
120
+ time_until: Time.parse("#{date_until} 23:59:59Z"),
121
+ logger: logger
118
122
  )
119
123
  end
120
124
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toggl_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Romain Champourlier