FAQ
| This is a
LIVE
service |
Changelog
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sync Tool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
Information Services
DevOps
Education Space Scheduling and Modelling (ESSM)
Sync Tool
Commits
6b9136c4
Commit
6b9136c4
authored
3 years ago
by
Robin Goodall
Browse files
Options
Downloads
Patches
Plain Diff
add get_all_staff and get_staff_by_id ops
parent
b928dabc
No related branches found
No related tags found
No related merge requests found
Pipeline
#115215
passed with warnings
3 years ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
essmsync/booker.py
+42
-1
42 additions, 1 deletion
essmsync/booker.py
operations.md
+8
-0
8 additions, 0 deletions
operations.md
with
50 additions
and
1 deletion
essmsync/booker.py
+
42
−
1
View file @
6b9136c4
...
...
@@ -171,6 +171,45 @@ def op_get_all_rooms():
_op_get_list
(
'
rooms
'
,
'
all_rooms
'
)
def
op_get_all_staff
():
"""
Get list of all staff and put in `booker.all_staff`
"""
_op_get_list
(
'
staff
'
,
'
all_staff
'
)
def
op_get_staff_by_id
():
"""
Get dict of all staff keyed on Booker.Id with filtered dict of data and
put in `booker.staff_by_id`
"""
all_staff
=
state
.
get
(
'
booker.all_staff
'
,
op_get_all_staff
)
# Ignore staff without an Id (hopefully none) and filter which pieces of
# data to keep
filtered_keys
=
[
'
Id
'
,
'
OptimeIndex
'
,
'
email
'
,
'
forename
'
,
'
surname
'
]
staff_by_id
=
{
_sanitised_staff_id
(
s
[
'
Id
'
]):
{
k
:
v
for
k
,
v
in
s
.
items
()
if
k
in
filtered_keys
}
for
s
in
all_staff
if
_valid_staff_id
(
s
.
get
(
'
Id
'
))
}
LOG
.
info
(
f
'
Booker staff by id:
{
len
(
staff_by_id
)
}
'
)
state
.
set
(
'
booker.staff_by_id
'
,
staff_by_id
)
def
_valid_staff_id
(
id
):
"""
Smells like a crsid?
"""
if
id
is
None
:
return
False
id
=
_sanitised_staff_id
(
id
)
return
re
.
fullmatch
(
'
[a-z][a-z0-9]{2,7}
'
,
id
)
def
_sanitised_staff_id
(
id
):
"""
Clean up Ids that have whitespace and are uppercase
"""
return
id
.
strip
().
lower
()
# List operations filtered by rooms with TermTime equipment
def
op_get_rooms
():
...
...
@@ -529,7 +568,9 @@ def _get_booked_by_list():
if only a single value is present.
"""
booked_by
=
state
.
get
(
'
booker.booked_by
'
,
'
essm-sync
'
)
# Unfortunately, user hasn't been created the same in each Booker instance
# so add both to the list
booked_by
=
state
.
get
(
'
booker.booked_by
'
,
[
'
essm-sync
'
,
'
devops+essm
'
])
if
not
isinstance
(
booked_by
,
list
):
return
[
booked_by
]
return
booked_by
...
...
This diff is collapsed.
Click to expand it.
operations.md
+
8
−
0
View file @
6b9136c4
...
...
@@ -51,6 +51,14 @@ Get list of all rooms and put them in the `booker.all_rooms` state key.
#### get_all_sites
Get list of all sites and put them in the
`booker.all_sites`
state key.
#### get_all_staff
Get list of all staff and put them in the
`booker.all_staff`
state key.
#### get_staff_by_id
Get all staff, filter to those with "crsid-looking" Ids, and create a dict keyed
on a sanitised Id with a dict for the value containing limited data. Put this in
the
`booker.staff_by_id`
state key.
#### get_buildings
Get a list of buildings related to the filtered rooms list (see get_rooms)
and put them in the
`booker.buildings`
state key.
...
...
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