Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Kaffeekasse 2000XT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Lehrstuhl für Informatik 4 (Systemsoftware)
PASST
Projekte
Kaffeekasse 2000XT
Commits
b4fa6cc8
Commit
b4fa6cc8
authored
5 years ago
by
Fabian Krüger
Browse files
Options
Downloads
Patches
Plain Diff
updatd getFrequentUsersList
parent
05c7c423
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
store/backend.py
+46
-11
46 additions, 11 deletions
store/backend.py
store/store_config.py
+1
-1
1 addition, 1 deletion
store/store_config.py
with
47 additions
and
12 deletions
store/backend.py
+
46
−
11
View file @
b4fa6cc8
...
...
@@ -29,26 +29,61 @@ class UserLogic:
return
False
"""
Collects the users that have the most log ins on a client within a given time period.
Collects the users that have the most log ins on a client within a given time period. The rest of the list is filled
first with all other logins and than all users that have never logged in
Returns a list of dictionaries on succes: [{
'
user__nickname
'
:
'
...
'
,
'
user__id
'
: ...,
'
total
'
: ...}, ...]
@config-param max_users: the maximum of users that should be shown. Depends on N_USERS_LOGIN
@config-param max_days: the maximum of days that have passed since the last login. Depends on T_USERS_LOGIN_D
@config-param max_users: the maximum of users that should be shown
from the most recent ones
. Depends on N_USERS_LOGIN
@config-param max_days: the maximum of days that have passed since the last
login to count as recent
login. Depends on T_USERS_LOGIN_D
"""
# @staticmethod
# def getFrequentUsersList():
# max_users = config['N_USERS_LOGIN']
# max_days = config['T_USERS_LOGIN_D']
# time_stamp = date.today() - timedelta(days=max_days)
# logins = Login.objects.filter(time_stamp__gte=time_stamp.strftime("%Y-%m-%d") + " 00:00")
# logins = logins.select_related('user')
# logins = logins.values('user__nickname', 'user__id')
# logins = logins.annotate(total=Count('user__id'))
# if max_users <= 0:
# logins = logins.order_by('total').reverse()
# else:
# logins = logins.order_by('total').reverse()[:max_users]
# return list(logins)
@staticmethod
def
getFrequentUsersList
():
max_users
=
config
[
'
N_USERS_LOGIN
'
]
max_days
=
config
[
'
T_USERS_LOGIN_D
'
]
time_stamp
=
date
.
today
()
-
timedelta
(
days
=
max_days
)
logins
=
Login
.
objects
.
filter
(
time_stamp__gte
=
time_stamp
.
strftime
(
"
%Y-%m-%d
"
)
+
"
00:00
"
)
logins
=
logins
.
select_related
(
'
user
'
)
logins
=
logins
.
values
(
'
user__nickname
'
,
'
user__id
'
)
logins
=
logins
.
annotate
(
total
=
Count
(
'
user__id
'
))
recent_logins
=
Login
.
objects
.
filter
(
time_stamp__gte
=
time_stamp
.
strftime
(
"
%Y-%m-%d
"
)
+
"
00:00
"
)
recent_logins
=
recent_logins
.
select_related
(
'
user
'
)
recent_logins
=
recent_logins
.
values
(
'
user__nickname
'
,
'
user__id
'
)
recent_logins
=
recent_logins
.
annotate
(
total
=
Count
(
'
user__id
'
))
if
max_users
<=
0
:
logins
=
logins
.
order_by
(
'
total
'
).
reverse
()
recent_
logins
=
recent_
logins
.
order_by
(
'
total
'
).
reverse
()
else
:
logins
=
logins
.
order_by
(
'
total
'
).
reverse
()[:
max_users
]
return
list
(
logins
)
recent_logins
=
recent_logins
.
order_by
(
'
total
'
).
reverse
()[:
max_users
]
old_logins
=
Login
.
objects
.
all
()
old_logins
=
old_logins
.
select_related
(
'
user
'
)
old_logins
=
old_logins
.
values
(
'
user__nickname
'
,
'
user__id
'
)
old_logins
=
old_logins
.
exclude
(
user__id__in
=
[
d
[
'
user__id
'
]
for
d
in
list
(
recent_logins
)])
old_logins
=
old_logins
.
annotate
(
total
=
Count
(
'
user__id
'
))
old_logins
=
old_logins
.
order_by
(
'
total
'
).
reverse
()
no_logins
=
User
.
objects
.
exclude
(
id__in
=
[
d
[
'
user__id
'
]
for
d
in
list
(
recent_logins
)
+
list
(
old_logins
)])
no_logins
=
no_logins
.
order_by
(
'
nickname
'
)
no_logins
=
no_logins
.
values
(
'
nickname
'
,
'
id
'
)
no_logins
=
no_logins
.
annotate
(
total
=
Count
(
'
id
'
))
for
login
in
no_logins
:
login
[
'
user__id
'
]
=
login
.
pop
(
'
id
'
)
login
[
'
user__nickname
'
]
=
login
.
pop
(
'
nickname
'
)
login
[
'
total
'
]
=
0
return
list
(
recent_logins
)
+
list
(
old_logins
)
+
list
(
no_logins
)
class
ProductLogic
:
...
...
This diff is collapsed.
Click to expand it.
store/store_config.py
+
1
−
1
View file @
b4fa6cc8
...
...
@@ -16,7 +16,7 @@ KAFFEEKASSE = {'N_LAST_BOUGHT_PRODUCTS': 5,
'
T_ANNULLABLE_PURCHASE_M
'
:
60
,
'
N_MOST_BOUGHT_PRODUCTS
'
:
5
,
'
T_MOST_BOUGHT_PRODUCTS_D
'
:
30
,
'
N_USERS_LOGIN
'
:
-
1
,
'
N_USERS_LOGIN
'
:
30
,
'
T_USERS_LOGIN_D
'
:
356
,
'
N_LAST_CHARGES
'
:
10
,
'
T_ANNULLABLE_CHARGE_M
'
:
60
,
...
...
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