Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this was uncommited on production #4

Merged
merged 1 commit into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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