pluto-models 1.5.2 → 1.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
  SHA1:
3
- metadata.gz: a3f3aa900ee09c45deb0049eaba8d2d50c37a226
4
- data.tar.gz: 608cac74375d1b22df6d0486729b251c84f6cc3c
3
+ metadata.gz: 92f609c55f1c97dce198ee7f9a8513d1937efc92
4
+ data.tar.gz: b688795ca55c96259a5ef2494fb3fe24fd63fb65
5
5
  SHA512:
6
- metadata.gz: 980818918cfd27d11e3ffd7593977be648e0bfed4d44b5e64ee2f60f67794d71ff3e61bbceffb5ec0c76bfae17f2c6416c21c5bf722b85dd815663718742dcdf
7
- data.tar.gz: 3b613701225714e04afd3ebceefdd75e7fb8714d5391868e085add8ca21c08ffaa59967a7cba64f425eb1bc487d89d2e7b5f37756d838bd1983722da5496d181
6
+ metadata.gz: e603bb5436e331469dc36edea780f52e831ccce781e43f79bcaf7c83fdb57f1599271a889b6b670b18ddc0542d2e69901c2f7f5526c11ba1b062f525d1096b5f
7
+ data.tar.gz: 62499df65996003274e377b6a9c9c5c8e2f398c1dbac7601b9daf4d3201295f89c13d4b8ce9f0641d8123e292444801d2d6a56bce45e25c8d0e7db66200ae997
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ Hoe.spec 'pluto-models' do
20
20
  self.extra_deps = [
21
21
  ['props', '>= 1.2.0'],
22
22
  ['logutils', '>= 0.6.1'],
23
- ['feedparser', '>= 2.1.1'],
23
+ ['feedparser', '>= 2.1.2'],
24
24
  ['feedfilter', '>= 1.1.1'],
25
25
  ['textutils', '>= 1.4.0'],
26
26
  ['activerecord'],
@@ -89,85 +89,87 @@ class Feed < ActiveRecord::Base
89
89
 
90
90
  logger = LogUtils::Logger.root
91
91
 
92
- ######
93
- ## check for filters (includes/excludes) if present
94
- ## for now just check for includes
95
- ##
96
- if includes.present?
97
- includesFilter = FeedFilter::IncludeFilters.new( includes )
98
- else
99
- includesFilter = nil
100
- end
101
-
102
- data.items.each do |item|
103
- if includesFilter && includesFilter.match_item?( item ) == false
104
- logger.info "** SKIPPING | #{item.title}"
105
- logger.info " no include terms match: #{includes}"
106
- next ## skip to next item
107
- end
108
-
109
- item_rec = Item.find_by_guid( item.guid )
110
- if item_rec.nil?
111
- item_rec = Item.new
112
- logger.info "** NEW | #{item.title}"
92
+ ## note: handle case with empty feed, that is, feed with NO items / entries
93
+ ## (e.g. data.items.size == 0).
94
+ if data.items.size > 0
95
+
96
+ ######
97
+ ## check for filters (includes/excludes) if present
98
+ ## for now just check for includes
99
+ ##
100
+ if includes.present?
101
+ includesFilter = FeedFilter::IncludeFilters.new( includes )
113
102
  else
114
- ## todo: check if any attribs changed
115
- logger.info "UPDATE | #{item.title}"
103
+ includesFilter = nil
116
104
  end
117
105
 
118
- item_rec.debug = debug? ? true : false # pass along debug flag
106
+ data.items.each do |item|
107
+ if includesFilter && includesFilter.match_item?( item ) == false
108
+ logger.info "** SKIPPING | #{item.title}"
109
+ logger.info " no include terms match: #{includes}"
110
+ next ## skip to next item
111
+ end
119
112
 
120
- item_rec.feed_id = id # feed_rec.id - add feed_id fk_ref
121
- item_rec.fetched = fetched # feed_rec.fetched
113
+ item_rec = Item.find_by_guid( item.guid )
114
+ if item_rec.nil?
115
+ item_rec = Item.new
116
+ logger.info "** NEW | #{item.title}"
117
+ else
118
+ ## todo: check if any attribs changed
119
+ logger.info "UPDATE | #{item.title}"
120
+ end
122
121
 
123
- item_rec.update_from_struct!( item )
122
+ item_rec.debug = debug? ? true : false # pass along debug flag
124
123
 
125
- end # each item
124
+ item_rec.feed_id = id # feed_rec.id - add feed_id fk_ref
125
+ item_rec.fetched = fetched # feed_rec.fetched
126
126
 
127
+ item_rec.update_from_struct!( item )
128
+ end # each item
127
129
 
128
- ###
129
- # delete (old) feed items if no longer in feed AND
130
- # date range is in (lastest/current) feed list
131
- #
132
- # thanks to Harry Wood
133
- # see https://github.com/feedreader/pluto/pull/16
134
- # for more comments
135
130
 
136
- #
137
- # todo/fix: use a delete feature/command line flag to make it optional - why? why not?
131
+ ###
132
+ # delete (old) feed items if no longer in feed AND
133
+ # date range is in (lastest/current) feed list
134
+ #
135
+ # thanks to Harry Wood
136
+ # see https://github.com/feedreader/pluto/pull/16
137
+ # for more comments
138
138
 
139
+ # todo/fix: use a delete feature/command line flag to make it optional - why? why not?
139
140
 
140
- guids_in_feed = data.items.map {|item| item.guid}
141
- earliest_still_in_feed = data.items.min_by(&:published).published
141
+ guids_in_feed = data.items.map {|item| item.guid }
142
+ earliest_still_in_feed = data.items.min_by {|item| item.published }.published
142
143
 
143
- items_no_longer_present =
144
- Item
145
- .where(feed_id: id)
146
- .where.not(published: nil)
147
- .where("published > ?", earliest_still_in_feed)
148
- .where.not(guid: guids_in_feed)
144
+ items_no_longer_present =
145
+ Item
146
+ .where(feed_id: id)
147
+ .where.not(published: nil)
148
+ .where("published > ?", earliest_still_in_feed)
149
+ .where.not(guid: guids_in_feed)
149
150
 
150
- unless items_no_longer_present.empty?
151
- logger.info "#{items_no_longer_present.size} items no longer present in the feed (presumed removed at source). Deleting from pluto db"
152
- items_no_longer_present.each do |item|
153
- logger.info "** DELETE | #{item.title}"
154
- item.destroy
151
+ unless items_no_longer_present.empty?
152
+ logger.info "#{items_no_longer_present.size} items no longer present in the feed (presumed removed at source). Deleting from planet db"
153
+ items_no_longer_present.each do |item|
154
+ logger.info "** DELETE | #{item.title}"
155
+ item.destroy
156
+ end
155
157
  end
156
- end
157
158
 
158
159
 
159
- # update cached value last published for item
160
- ## todo/check: force reload of items - why? why not??
161
- last_item_rec = items.latest.limit(1).first # note limit(1) will return relation/arrar - use first to get first element or nil from ary
162
- if last_item_rec.present?
163
- if last_item_rec.updated?
164
- self.items_last_updated = last_item_rec.updated
165
- ## save! ## note: will get save w/ update_from_struct! - why? why not??
166
- else # try published
167
- self.items_last_updated = last_item_rec.published
168
- ## save! ## note: will get save w/ update_from_struct! - why? why not??
160
+ # update cached value last published for item
161
+ ## todo/check: force reload of items - why? why not??
162
+ last_item_rec = items.latest.limit(1).first # note limit(1) will return relation/arrar - use first to get first element or nil from ary
163
+ if last_item_rec.present?
164
+ if last_item_rec.updated?
165
+ self.items_last_updated = last_item_rec.updated
166
+ ## save! ## note: will get save w/ update_from_struct! - why? why not??
167
+ else # try published
168
+ self.items_last_updated = last_item_rec.published
169
+ ## save! ## note: will get save w/ update_from_struct! - why? why not??
170
+ end
169
171
  end
170
- end
172
+ end # check for if data.items.size > 0 (that is, feed has feed items/entries)
171
173
 
172
174
  update_from_struct!( data )
173
175
  end # method deep_update_from_struct!
@@ -4,7 +4,7 @@ module Pluto
4
4
 
5
5
  MAJOR = 1
6
6
  MINOR = 5
7
- PATCH = 2
7
+ PATCH = 3
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pluto-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-26 00:00:00.000000000 Z
11
+ date: 2020-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: props
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 2.1.1
47
+ version: 2.1.2
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 2.1.1
54
+ version: 2.1.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: feedfilter
57
57
  requirement: !ruby/object:Gem::Requirement