Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mffzoom
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wizards
mffzoom
Commits
e043d87e
Commit
e043d87e
authored
5 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
find-collisions
parent
3cf50af3
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
hook/find-collisions.py
+62
-0
62 additions, 0 deletions
hook/find-collisions.py
with
62 additions
and
0 deletions
hook/find-collisions.py
0 → 100755
+
62
−
0
View file @
e043d87e
#!/usr/bin/env python3
import
configparser
import
psycopg2
import
psycopg2.extras
import
datetime
import
dateutil.tz
import
time
config
=
configparser
.
ConfigParser
()
config
.
read
(
'
zoom.ini
'
)
db_conn
=
psycopg2
.
connect
(
dbname
=
config
[
'
db
'
][
'
name
'
],
user
=
config
[
'
db
'
][
'
user
'
],
password
=
config
[
'
db
'
][
'
passwd
'
],
host
=
"
127.0.0.1
"
)
db
=
db_conn
.
cursor
(
cursor_factory
=
psycopg2
.
extras
.
NamedTupleCursor
)
db
.
execute
(
"""
SELECT
m.meeting_id, m.topic, u.uid, u.full_name, s.occurrence_id, s.start_time, s.duration
FROM
zoom_meetings m
JOIN zoom_users u ON u.uid = m.host_uid
JOIN zoom_schedule s ON s.mid = m.mid
WHERE
s.start_time >= NOW()
ORDER BY u.uid, s.start_time
"""
)
class
Meeting
:
def
__init__
(
self
,
row
):
for
f
in
row
.
_fields
:
setattr
(
self
,
f
,
getattr
(
row
,
f
))
self
.
start_time
=
self
.
start_time
.
replace
(
tzinfo
=
dateutil
.
tz
.
tz
.
tzutc
()).
astimezone
(
dateutil
.
tz
.
gettz
())
self
.
end_time
=
self
.
start_time
+
datetime
.
timedelta
(
minutes
=
self
.
duration
)
self
.
time_range
=
self
.
start_time
.
strftime
(
"
%Y-%m-%d %H:%M
"
)
+
"
-
"
+
self
.
end_time
.
strftime
(
"
%H:%M
"
)
def
__str__
(
self
):
return
"
Meeting(
"
+
"
,
"
.
join
([
k
+
"
:
"
+
str
(
getattr
(
self
,
k
))
for
k
in
dir
(
self
)
if
k
[
0
]
!=
'
_
'
])
+
"
)
"
last_uid
=
None
running
=
[]
for
row
in
db
:
m
=
Meeting
(
row
)
# print(m)
if
m
.
uid
!=
last_uid
:
last_uid
=
m
.
uid
running
=
[]
while
running
and
running
[
0
].
end_time
<=
m
.
start_time
:
running
.
pop
(
0
)
colls
=
[
r
for
r
in
running
if
r
.
end_time
>
m
.
start_time
+
datetime
.
timedelta
(
minutes
=
5
)
]
if
colls
:
print
(
f
"
Collison for
{
m
.
time_range
}
{
m
.
topic
}
[
{
m
.
meeting_id
}
:
{
m
.
occurrence_id
}
{
m
.
full_name
}
]
"
)
for
c
in
colls
:
print
(
f
"
\t
{
c
.
time_range
}
{
c
.
topic
}
[
{
c
.
meeting_id
}
:
{
c
.
occurrence_id
}
]
"
)
print
()
pos
=
sum
(
1
for
r
in
running
if
r
.
end_time
<=
m
.
end_time
)
running
.
insert
(
pos
,
m
)
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