Feeds : display last access date for merged feed parsers
This commit is contained in:
@@ -30,6 +30,9 @@ Find feeds parsers (first hit in feeds conf value and no viewed pages if it's a
|
||||
If merge_feeds_parsers is set to True, merge feeds parsers with the same user agent
|
||||
as it must be the same person with a different IP address.
|
||||
|
||||
Warning : When merge_feeds_parsers is activated, last access display date is the more
|
||||
recent date of all merged parsers found
|
||||
|
||||
Plugin requirements :
|
||||
None
|
||||
|
||||
@@ -101,24 +104,26 @@ class IWLAPostAnalysisFeeds(IPlugin):
|
||||
if self.merged_feeds.get(key, None) is None:
|
||||
# Merged
|
||||
self.merged_feeds[key] = hit
|
||||
else:
|
||||
elif hit['remote_ip'] != self.merged_feeds[key]['remote_ip']:
|
||||
# Next time
|
||||
# Current must be ignored
|
||||
hit['feed_parser'] = self.NOT_A_FEED_PARSER
|
||||
last_access = hit['last_access']
|
||||
# Previous matched hit must be set as merged
|
||||
isFeedParser = self.MERGED_FEED_PARSER
|
||||
hit = self.merged_feeds[key]
|
||||
if hit['last_access'] < last_access:
|
||||
hit['feed_parser_last_access'] = last_access
|
||||
else:
|
||||
hit['feed_parser_last_access'] = hit['last_access']
|
||||
hit['feed_parser'] = isFeedParser
|
||||
|
||||
def mergeFeedsParsers(self, isFeedParser, hit):
|
||||
if isFeedParser:
|
||||
# One hit only match
|
||||
if True or (hit['viewed_hits'][0] + hit['not_viewed_hits'][0]) == 1:
|
||||
for r in self.merge_feeds_parsers_list:
|
||||
if r.match(hit['remote_addr']) or r.match(hit['remote_ip']):
|
||||
#print('hit match %s' % (hit['remote_addr']))
|
||||
self._appendToMergeCache(isFeedParser, r, hit)
|
||||
return
|
||||
for r in self.merge_feeds_parsers_list:
|
||||
if r.match(hit['remote_addr']) or r.match(hit['remote_ip']):
|
||||
self._appendToMergeCache(isFeedParser, r, hit)
|
||||
return
|
||||
#print("No match for %s : %d" % (hit['remote_addr'], hit['viewed_hits'][0] + hit['not_viewed_hits'][0]))
|
||||
# Other cases, look for user agent
|
||||
user_agent = hit['requests'][0]['http_user_agent'].lower()
|
||||
|
||||
Reference in New Issue
Block a user