fnp
/
wolnelektury.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
c4c73f2
)
Updating stats.
author
Radek Czajka
<rczajka@rczajka.pl>
Tue, 1 Jun 2021 10:24:53 +0000
(12:24 +0200)
committer
Radek Czajka
<rczajka@rczajka.pl>
Tue, 1 Jun 2021 10:24:53 +0000
(12:24 +0200)
src/stats/models.py
patch
|
blob
|
history
diff --git
a/src/stats/models.py
b/src/stats/models.py
index
c1b4d16
..
7d850af
100644
(file)
--- a/
src/stats/models.py
+++ b/
src/stats/models.py
@@
-15,7
+15,6
@@
class Visits(models.Model):
@classmethod
def build_month(cls, year, month):
Book = apps.get_model('catalogue', 'Book')
@classmethod
def build_month(cls, year, month):
Book = apps.get_model('catalogue', 'Book')
- ### TODO: Delete existing?
date = f'{year}-{month:02d}'
url = f'{settings.PIWIK_URL}?date={date}&filter_limit=-1&format=CSV&idSite={settings.PIWIK_SITE_ID}&language=pl&method=Actions.getPageUrls&module=API&period=month&segment=&token_auth={settings.PIWIK_TOKEN}&flat=1'
date = f'{year}-{month:02d}'
url = f'{settings.PIWIK_URL}?date={date}&filter_limit=-1&format=CSV&idSite={settings.PIWIK_SITE_ID}&language=pl&method=Actions.getPageUrls&module=API&period=month&segment=&token_auth={settings.PIWIK_TOKEN}&flat=1'
@@
-33,7
+32,7
@@
class Visits(models.Model):
except Book.DoesNotExist:
continue
else:
except Book.DoesNotExist:
continue
else:
- cls.objects.create(
+ cls.objects.
update_or_
create(
book=book, year=year, month=month,
book=book, year=year, month=month,
- views=views, unique_views=uviews
+ defaults={'views': views, 'unique_views': uviews}
)
)