Über Open CoDE
Software
Wiki
Diskussionen
GitLab
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mindwendel-test-pull-mirror
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
oss-gerardo-testing
ci-cd-component-testing
mindwendel-test-pull-mirror
Commits
e56f240e
Unverified
Commit
e56f240e
authored
1 year ago
by
Nicholas
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
[Chore] Improve logging for user deletion #186 (#187)
parent
11c37a6c
No related branches found
Branches containing commit
Tags
0.1.0-beta
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/mindwendel/accounts.ex
+27
-1
27 additions, 1 deletion
lib/mindwendel/accounts.ex
with
27 additions
and
1 deletion
lib/mindwendel/accounts.ex
+
27
−
1
View file @
e56f240e
...
...
@@ -4,6 +4,8 @@ defmodule Mindwendel.Accounts do
alias
Mindwendel
.
Accounts
.
User
alias
Mindwendel
.
Brainstormings
.
Brainstorming
require
Logger
@doc
"""
Finds an existing user or creates a new user based on an UUID.
...
...
@@ -115,6 +117,30 @@ defmodule Mindwendel.Accounts do
def
delete_inactive_users
(
after_days
\\
30
)
do
date_time
=
Timex
.
now
()
|>
Timex
.
shift
(
days:
-
1
*
after_days
)
Repo
.
delete_all
(
from
u
in
User
,
where:
u
.
updated_at
<
^
date_time
)
users_count
=
Repo
.
aggregate
(
User
,
:count
,
:id
)
inactive_users_query
=
from
u
in
User
,
where:
u
.
updated_at
<
^
date_time
inactive_users_count
=
Repo
.
aggregate
(
inactive_users_query
,
:count
,
:id
)
Logger
.
info
(
"Delete inactive users. Count:
#{
inactive_users_count
}
/
#{
users_count
}
"
)
Logger
.
info
(
"Starting to delete inactive users:"
)
inactive_users
=
Repo
.
all
(
inactive_users_query
)
Enum
.
each
(
inactive_users
,
fn
inactive_user
->
try
do
delete_user
(
inactive_user
)
rescue
e
->
Logger
.
error
(
"Error while deleting inactive user:
#{
inactive_user
.
id
}
"
)
Logger
.
error
(
e
)
end
end
)
Logger
.
info
(
"Finished deleting old inactive users"
)
end
def
delete_user
(%
User
{}
=
user
)
do
Repo
.
delete
(
user
)
end
end
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