Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rabbitmq_agents
Manage
Activity
Members
Labels
Plan
Issues
14
Issue boards
Milestones
Wiki
Code
Merge requests
8
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
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
rc
rabbitmq_agents
Commits
ef25c506
Commit
ef25c506
authored
3 years ago
by
Bo-Chun Chen
Browse files
Options
Downloads
Patches
Plain Diff
Update init state script with updated_by field
parent
1f237b33
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!147
Merge previous default branch feat-cod-rmq into main
,
!127
Add updated_by field to user_state table
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
init_user_state.py
+14
-2
14 additions, 2 deletions
init_user_state.py
with
14 additions
and
2 deletions
init_user_state.py
+
14
−
2
View file @
ef25c506
...
@@ -4,6 +4,7 @@ import dataset
...
@@ -4,6 +4,7 @@ import dataset
import
sys
import
sys
import
subprocess
import
subprocess
import
rabbit_config
as
rcfg
import
rabbit_config
as
rcfg
import
rc_util
from
datetime
import
datetime
from
datetime
import
datetime
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
...
@@ -15,6 +16,7 @@ args = parser.parse_args()
...
@@ -15,6 +16,7 @@ args = parser.parse_args()
default_state
=
"
ok
"
default_state
=
"
ok
"
today
=
datetime
.
now
()
today
=
datetime
.
now
()
updated_by
=
rc_util
.
get_caller_info
()
# Chunk size for insert into db
# Chunk size for insert into db
size
=
1000
size
=
1000
...
@@ -38,7 +40,12 @@ if len(users) > 50:
...
@@ -38,7 +40,12 @@ if len(users) > 50:
while
start
<
len
(
users
):
while
start
<
len
(
users
):
end
=
start
+
size
if
start
+
size
<
len
(
users
)
else
len
(
users
)
end
=
start
+
size
if
start
+
size
<
len
(
users
)
else
len
(
users
)
data
=
[
data
=
[
dict
(
username
=
user
,
state
=
default_state
,
date
=
today
)
dict
(
username
=
user
,
state
=
default_state
,
date
=
today
,
updated_by
=
updated_by
,
)
for
user
in
users
[
start
:
end
]
for
user
in
users
[
start
:
end
]
]
]
if
args
.
dry_run
:
if
args
.
dry_run
:
...
@@ -54,5 +61,10 @@ else:
...
@@ -54,5 +61,10 @@ else:
print
(
f
"
Table insert user:
{
user
}
, state:
{
default_state
}
"
)
print
(
f
"
Table insert user:
{
user
}
, state:
{
default_state
}
"
)
else
:
else
:
table
.
insert
(
table
.
insert
(
{
"
username
"
:
user
,
"
state
"
:
default_state
,
"
date
"
:
today
}
{
"
username
"
:
user
,
"
state
"
:
default_state
,
"
date
"
:
today
,
"
updated_by
"
:
updated_by
,
}
)
)
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