Skip to content

Commit

Permalink
this was uncommited on production
Browse files Browse the repository at this point in the history
  • Loading branch information
kosarko committed May 24, 2019
1 parent 0f88b59 commit 407908a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 7 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ generate_over_all_reports:
--method=VisitsSummary.get
#overall views country wise
$(SCRIPT) --date=$(START_DATE),$(END_DATE) \
--idSite=2,4 --columns=code,nb_uniq_visitors,nb_visits \
--idSite=2 --columns=code,nb_uniq_visitors,nb_visits \
--method=UserCountry.getCountry
$(SCRIPT) --date=$(START_DATE),$(END_DATE) \
--idSite=4 --columns=code,nb_uniq_visitors,nb_visits \
--method=UserCountry.getCountry
#overall most visited pages
$(SCRIPT) --date=$(START_DATE),$(END_DATE) \
--idSite=2,4 --columns=label,url,nb_visits,nb_hits \
Expand Down Expand Up @@ -137,3 +140,5 @@ generate_others_reports:

all: generate_over_all_reports generate_repository_reports generate_LRT_reports generate_services_reports generate_others_reports
date > $(INDEX)/last_updated.txt
wget -q -O - https://lindat.mff.cuni.cz/statistics/reload > /dev/null

32 changes: 28 additions & 4 deletions scripts/luc/searcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ def search_handle(self, dmy=None, period='year', site_id=None, handle=None, segm
results = dict()

if period == 'year':
results["total"] = {"nb_visits": 0, "nb_hits": 0}
else:
results["total"] = {}

for doc in docs:
Expand All @@ -326,12 +328,16 @@ def search_handle(self, dmy=None, period='year', site_id=None, handle=None, segm
results[year] = {}
if url not in results[year]:
results[year][url] = {"nb_visits": 0, "nb_hits": 0}
if url not in results["total"]:
results["total"][url] = {"nb_visits": 0, "nb_hits": 0}
results[year][url]["nb_visits"] += nb_visits
results[year][url]["nb_hits"] += nb_hits
results["total"][url]["nb_visits"] += nb_visits
results["total"][url]["nb_hits"] += nb_hits

if year not in results["total"]:
results["total"][year] = {"nb_visits": 0, "nb_hits": 0}
results["total"]["nb_visits"] += nb_visits
results["total"]["nb_hits"] += nb_hits
results["total"][year]["nb_visits"] += nb_visits
results["total"][year]["nb_hits"] += nb_hits

elif period == 'month':
if year not in results:
results[year] = {}
Expand All @@ -341,6 +347,14 @@ def search_handle(self, dmy=None, period='year', site_id=None, handle=None, segm
results[year][month][url] = {"nb_visits": 0, "nb_hits": 0}
results[year][month][url]["nb_visits"] += nb_visits
results[year][month][url]["nb_hits"] += nb_hits

if year not in results["total"]:
results["total"][year] = {}
if month not in results["total"][year]:
results["total"][year][month] = {"nb_visits": 0, "nb_hits": 0}
results["total"][year][month]["nb_visits"] += nb_visits
results["total"][year][month]["nb_hits"] += nb_hits

elif period == 'day':
if year not in results:
results[year] = {}
Expand All @@ -353,7 +367,17 @@ def search_handle(self, dmy=None, period='year', site_id=None, handle=None, segm
results[year][month][day][url]["nb_visits"] += nb_visits
results[year][month][day][url]["nb_hits"] += nb_hits

if year not in results["total"]:
results["total"][year] = {}
if month not in results["total"][year]:
results["total"][year][month] = {}
if day not in results["total"][year][month]:
results["total"][year][month][day] = {"nb_visits": 0, "nb_hits": 0}
results["total"][year][month][day]["nb_visits"] += nb_visits
results["total"][year][month][day]["nb_hits"] += nb_hits

return results

def close(self):
self.directory.close()

21 changes: 19 additions & 2 deletions scripts/search_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ def home():
return f.read()


@app.route('/reload')
def reload():
global s
s = searcher.Searcher(index)
return "done"


@app.route('/views')
def search_views():
dmy = request.args.get('date', None)
Expand Down Expand Up @@ -77,13 +84,23 @@ def search_hanlde():
h = request.args.get('h')
seg = request.args.get('segment', None)
sid = [2, 4]
res = dict()
if seg == "views":
sid = 2
segment = "[email protected]/repository/xmlui/handle"
res["response"] = s.search_handle(dmy=dmy, period=period, site_id=sid, handle=h, segment=segment)
elif seg == "downloads":
sid = 4
res = dict()
res["response"] = s.search_handle(dmy=dmy, period=period, site_id=sid, handle=h, segment=segment)
res["response"] = s.search_handle(dmy=dmy, period=period, site_id=sid, handle=h, segment=segment)
else:
res = dict()
sid = 2
segment = "[email protected]/repository/xmlui/handle"
res["response"] = {}
res["response"]["views"] = s.search_handle(dmy=dmy, period=period, site_id=sid, handle=h, segment=segment)
sid = 4
res["response"]["downloads"] = s.search_handle(dmy=dmy, period=period, site_id=sid, handle=h, segment=None)

return jsonify(res)


Expand Down

0 comments on commit 407908a

Please sign in to comment.