Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
librestash
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nik | Klampfradler
librestash
Commits
91f324d9
Verified
Commit
91f324d9
authored
7 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Add first time-based stats.
parent
045b04ea
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
librestash/lib/model.py
+1
-0
1 addition, 0 deletions
librestash/lib/model.py
librestash/lib/stats/__init__.py
+1
-0
1 addition, 0 deletions
librestash/lib/stats/__init__.py
librestash/lib/stats/time.py
+53
-0
53 additions, 0 deletions
librestash/lib/stats/time.py
with
55 additions
and
0 deletions
librestash/lib/model.py
+
1
−
0
View file @
91f324d9
...
@@ -47,6 +47,7 @@ class Log(Base):
...
@@ -47,6 +47,7 @@ class Log(Base):
geocacher_account_id
=
Column
(
Integer
,
ForeignKey
(
'
geocacher_accounts.id
'
))
geocacher_account_id
=
Column
(
Integer
,
ForeignKey
(
'
geocacher_accounts.id
'
))
geocacher_account
=
relationship
(
'
GeocacherAccount
'
,
back_populates
=
'
logs
'
)
geocacher_account
=
relationship
(
'
GeocacherAccount
'
,
back_populates
=
'
logs
'
)
geocacher
=
association_proxy
(
'
geocacher_account
'
,
'
geocacher
'
)
platform_prefix
=
association_proxy
(
'
listing
'
,
'
platform_prefix
'
)
platform_prefix
=
association_proxy
(
'
listing
'
,
'
platform_prefix
'
)
...
...
This diff is collapsed.
Click to expand it.
librestash/lib/stats/__init__.py
+
1
−
0
View file @
91f324d9
...
@@ -15,3 +15,4 @@ def all_stats(db, geocacher_name):
...
@@ -15,3 +15,4 @@ def all_stats(db, geocacher_name):
return
res
return
res
from
.basic
import
*
from
.basic
import
*
from
.time
import
*
This diff is collapsed.
Click to expand it.
librestash/lib/stats/time.py
0 → 100644
+
53
−
0
View file @
91f324d9
from
.
import
stats_plugin
from
..model
import
Log
def
_finds_by_date
(
db
,
geocacher
):
session
=
db
.
Session
()
logs
=
session
.
query
(
Log
).
filter_by
(
geocacher
=
geocacher
,
type
=
'
Found it
'
).
all
()
res
=
{}
for
log
in
logs
:
date
=
log
.
date
.
date
()
if
not
date
in
res
:
res
[
date
]
=
0
res
[
date
]
+=
1
return
res
@stats_plugin
def
finds_by_day
(
db
,
geocacher
):
data
=
_finds_by_date
(
db
,
geocacher
)
res
=
{}
for
date
,
count
in
data
.
items
():
res
[
date
.
strftime
(
'
%Y-%m-%d
'
)]
=
count
return
res
@stats_plugin
def
finds_by_month
(
db
,
geocacher
):
data
=
_finds_by_date
(
db
,
geocacher
)
res
=
{}
for
date
,
count
in
data
.
items
():
if
not
date
.
strftime
(
'
%Y-%m
'
)
in
res
:
res
[
date
.
strftime
(
'
%Y-%m
'
)]
=
0
res
[
date
.
strftime
(
'
%Y-%m
'
)]
+=
count
return
res
@stats_plugin
def
finds_by_year
(
db
,
geocacher
):
data
=
_finds_by_date
(
db
,
geocacher
)
res
=
{}
for
date
,
count
in
data
.
items
():
if
not
date
.
strftime
(
'
%Y
'
)
in
res
:
res
[
date
.
strftime
(
'
%Y
'
)]
=
0
res
[
date
.
strftime
(
'
%Y
'
)]
+=
count
return
res
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment