iwla

iwla Commit Details

Date:2014-12-12 14:01:23 (6 years 7 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:bb7ce4af907b0f2064c1c7a225f230d5f64f3035
Parents: f116eacbcc623232270e60874da4dccc1a13975a
Message:Start refactoring statistics computation

Changes:
Miwla.py (4 diffs)

File differences

iwla.py
449449
450450
451451
452
452
453453
454454
455455
456456
457457
458
459458
460459
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480460
481461
482462
......
484464
485465
486466
487
467
468
469
470
471
488472
489473
490474
......
529513
530514
531515
516
532517
533518
534519
535
520
521
522
523
524
525
526
527
528
529
530
531
532
536533
537
538534
539535
540536
......
545541
546542
547543
548
549
550
551
552
553
554
555
556
544
545
546
557547
558548
559549
self._generateDisplayWholeMonthStats()
self.display.build(conf.DISPLAY_ROOT)
def _generateStats(self, visits):
def _createEmptyStats(self):
stats = {}
stats['viewed_bandwidth'] = 0
stats['not_viewed_bandwidth'] = 0
stats['viewed_pages'] = 0
stats['viewed_hits'] = 0
#stats['requests'] = set()
stats['nb_visitors'] = 0
for (k, super_hit) in visits.items():
if super_hit['robot']:
stats['not_viewed_bandwidth'] += super_hit['bandwidth']
continue
#print "[%s] =>\t%d/%d" % (k, super_hit['viewed_pages'], super_hit['viewed_hits'])
if conf.count_hit_only_visitors or\
super_hit['viewed_pages']:
stats['nb_visitors'] += 1
stats['viewed_bandwidth'] += super_hit['bandwidth']
stats['viewed_pages'] += super_hit['viewed_pages']
stats['viewed_hits'] += super_hit['viewed_hits']
# for p in super_hit['requests']:
# if not p['is_page']: continue
# req = p['extract_request']
# stats['requests'].add(req['extract_uri'])
return stats
def _generateMonthStats(self):
visits = self.current_analysis['visits']
stats = self._generateStats(visits)
stats = self._createEmptyStats()
for (day, stat) in self.current_analysis['days_stats'].items():
for k in stats.keys():
stats[k] += stat[k]
duplicated_stats = {k:v for (k,v) in stats.items()}
cur_time = self.meta_infos['last_time']
def _generateDayStats(self):
visits = self.current_analysis['visits']
cur_time = self.meta_infos['last_time']
self._callPlugins(conf.PRE_HOOK_DIRECTORY)
stats = self._generateStats(visits)
stats = self._createEmptyStats()
for (k, super_hit) in visits.items():
if super_hit['robot']:
stats['not_viewed_bandwidth'] += super_hit['bandwidth']
continue
if (conf.count_hit_only_visitors or\
super_hit['viewed_pages']) and\
super_hit['last_access'].tm_mday == cur_time.tm_mday:
stats['nb_visitors'] += 1
stats['viewed_bandwidth'] += super_hit['bandwidth']
stats['viewed_pages'] += super_hit['viewed_pages']
stats['viewed_hits'] += super_hit['viewed_hits']
cur_time = self.meta_infos['last_time']
print "== Stats for %d/%02d/%d ==" % (cur_time.tm_year, cur_time.tm_mon, cur_time.tm_mday)
if cur_time.tm_mday > 1:
last_day -= 1
if last_day:
for k in stats.keys():
stats[k] -= self.current_analysis['days_stats'][last_day][k]
stats['nb_visitors'] = 0
for (k,v) in visits.items():
if v['robot']: continue
if conf.count_hit_only_visitors and\
(not v['viewed_pages']):
continue
if v['last_access'].tm_mday == cur_time.tm_mday:
stats['nb_visitors'] += 1
if k != 'nb_visitors':
print '%s : %d %d' % (k, stats[k], self.current_analysis['days_stats'][last_day][k])
stats[k] -= self.current_analysis['days_stats'][last_day][k]
print stats
self.current_analysis['days_stats'][cur_time.tm_mday] = stats

Archive Download the corresponding diff file

Branches

Tags