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
4a57aec0
Commit
4a57aec0
authored
Mar 23, 2020
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
One more change of data model
parent
347b2322
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
db.ddl
+13
-7
13 additions, 7 deletions
db.ddl
fetch-meetings.py
+32
-31
32 additions, 31 deletions
fetch-meetings.py
with
45 additions
and
38 deletions
db.ddl
+
13
−
7
View file @
4a57aec0
CREATE TABLE zoom_users (
CREATE TABLE zoom_users (
id serial PRIMARY KEY,
-- our internal
u
id serial PRIMARY KEY,
user_id varchar(255) UNIQUE NOT NULL, -- Zoom's
user_id varchar(255) UNIQUE NOT NULL, -- Zoom's
email varchar(255) NOT NULL,
email varchar(255) NOT NULL,
full_name varchar(255) NOT NULL
full_name varchar(255) NOT NULL
);
);
CREATE TABLE zoom_meetings (
CREATE TABLE zoom_meetings (
id serial PRIMARY KEY,
-- our internal
m
id serial PRIMARY KEY,
meeting_id int NOT NULL,
-- Zoom's meeting ID
meeting_id int
UNIQUE
NOT NULL, -- Zoom's meeting ID
uuid varchar(255) NOT NULL, -- Zoom's meeting instance ID
uuid varchar(255) NOT NULL, -- Zoom's meeting instance ID
occurrence_id bigint DEFAULT NULL, -- Occurrence for recurring meetings
host_uid int NOT NULL REFERENCES zoom_users(uid),
host_id int NOT NULL REFERENCES zoom_users(id),
topic varchar(255) DEFAULT '',
topic varchar(255) DEFAULT '',
type int NOT NULL, -- 1=instant, 2=scheduled, 3=recurring no time, 8=recurring fixed time
type int NOT NULL -- 1=instant, 2=scheduled, 3=recurring no time, 8=recurring fixed time
);
CREATE TABLE zoom_schedule (
id serial PRIMARY KEY,
mid int NOT NULL REFERENCES zoom_meetings(mid),
occurrence_id bigint DEFAULT 0, -- Occurrence for recurring meetings, 0 otherwise
start_time timestamp NOT NULL,
start_time timestamp NOT NULL,
duration int NOT NULL -- minutes
duration int NOT NULL, -- minutes
UNIQUE(mid, occurrence_id)
);
);
This diff is collapsed.
Click to expand it.
fetch-meetings.py
+
32
−
31
View file @
4a57aec0
...
@@ -8,7 +8,6 @@ import psycopg2
...
@@ -8,7 +8,6 @@ import psycopg2
import
psycopg2.extras
import
psycopg2.extras
import
time
import
time
import
dateutil.parser
import
dateutil.parser
# import dateutil.tz
import
sys
import
sys
verbose
=
True
verbose
=
True
...
@@ -23,14 +22,11 @@ db_conn = psycopg2.connect(dbname=config['db']['name'], user=config['db']['user'
...
@@ -23,14 +22,11 @@ db_conn = psycopg2.connect(dbname=config['db']['name'], user=config['db']['user'
db
=
db_conn
.
cursor
(
cursor_factory
=
psycopg2
.
extras
.
NamedTupleCursor
)
db
=
db_conn
.
cursor
(
cursor_factory
=
psycopg2
.
extras
.
NamedTupleCursor
)
def
parse_time
(
iso_time
,
tz_name
):
def
parse_time
(
iso_time
):
utc
=
dateutil
.
parser
.
isoparse
(
iso_time
)
return
dateutil
.
parser
.
isoparse
(
iso_time
)
# tz = dateutil.tz.gettz(tz_name)
# return utc.astimezone(tz)
return
utc
def
add_recurring
(
u
id
,
meet
):
def
add_recurring
(
m
id
,
meet
):
time
.
sleep
(
0.2
)
time
.
sleep
(
0.2
)
resp
=
client
.
meeting
.
get
(
host_id
=
meet
[
'
host_id
'
],
id
=
meet
[
'
id
'
])
resp
=
client
.
meeting
.
get
(
host_id
=
meet
[
'
host_id
'
],
id
=
meet
[
'
id
'
])
resp
.
raise_for_status
()
resp
.
raise_for_status
()
...
@@ -40,43 +36,47 @@ def add_recurring(uid, meet):
...
@@ -40,43 +36,47 @@ def add_recurring(uid, meet):
for
occ
in
details
[
"
occurrences
"
]:
for
occ
in
details
[
"
occurrences
"
]:
db
.
execute
(
"""
db
.
execute
(
"""
INSERT INTO zoom_
meetings
INSERT INTO zoom_
schedule
(m
eeting_id, uu
id, occurrence_id,
host_id, topic, type,
start_time, duration)
(mid, occurrence_id, start_time, duration)
VALUES (%s, %s, %s,
%s, %s, %s, %s,
%s)
VALUES (%s, %s, %s, %s)
"""
,
(
"""
,
(
meet
[
'
id
'
],
mid
,
meet
[
'
uuid
'
],
occ
[
'
occurrence_id
'
],
occ
[
'
occurrence_id
'
],
uid
,
parse_time
(
occ
[
'
start_time
'
]),
meet
[
'
topic
'
],
meet
[
'
type
'
],
parse_time
(
occ
[
'
start_time
'
],
meet
[
'
timezone
'
]),
occ
[
'
duration
'
],
occ
[
'
duration
'
],
))
))
def
add_meeting
(
uid
,
meet
):
def
add_meeting
(
uid
,
meet
):
type
=
meet
[
'
type
'
]
if
type
==
3
:
# Type 3 meetings (scheduled with no time) are ignored
return
if
type
==
8
:
# Recurring meetings: need to ask for the list of occurrences
add_recurring
(
uid
,
meet
)
return
db
.
execute
(
"""
db
.
execute
(
"""
INSERT INTO zoom_meetings
INSERT INTO zoom_meetings
(meeting_id, uuid, host_id, topic, type, start_time, duration)
(meeting_id, uuid, host_uid, topic, type)
VALUES (%s, %s, %s, %s, %s, %s, %s)
VALUES (%s, %s, %s, %s, %s)
RETURNING mid
"""
,
(
"""
,
(
meet
[
'
id
'
],
meet
[
'
id
'
],
meet
[
'
uuid
'
],
meet
[
'
uuid
'
],
uid
,
uid
,
meet
[
'
topic
'
],
meet
[
'
topic
'
],
meet
[
'
type
'
],
meet
[
'
type
'
],
parse_time
(
meet
[
'
start_time
'
],
meet
[
'
timezone
'
]),
))
meeting_row
=
db
.
fetchone
()
mid
=
meeting_row
.
mid
mtype
=
meet
[
'
type
'
]
if
mtype
==
8
:
# Recurring meetings: need to ask for the list of occurrences
add_recurring
(
mid
,
meet
)
elif
'
start_time
'
in
meet
:
# Other meetings usually have a starting time
db
.
execute
(
"""
INSERT INTO zoom_schedule
(mid, occurrence_id, start_time, duration)
VALUES (%s, %s, %s, %s)
"""
,
(
mid
,
0
,
parse_time
(
meet
[
'
start_time
'
]),
meet
[
'
duration
'
],
meet
[
'
duration
'
],
))
))
...
@@ -111,11 +111,12 @@ def get_meetings(uid, user_id):
...
@@ -111,11 +111,12 @@ def get_meetings(uid, user_id):
assert
total_rec
==
expected_rec
,
"
Unexpected number of records, probably because of race condition
"
assert
total_rec
==
expected_rec
,
"
Unexpected number of records, probably because of race condition
"
db
.
execute
(
'
DELETE FROM zoom_schedule
'
)
db
.
execute
(
'
DELETE FROM zoom_meetings
'
)
db
.
execute
(
'
DELETE FROM zoom_meetings
'
)
db
.
execute
(
"
SELECT * FROM zoom_users
"
)
db
.
execute
(
"
SELECT * FROM zoom_users
"
)
users
=
db
.
fetchall
()
users
=
db
.
fetchall
()
for
u
in
users
:
for
u
in
users
:
get_meetings
(
u
.
id
,
u
.
user_id
)
get_meetings
(
u
.
u
id
,
u
.
user_id
)
db_conn
.
commit
()
db_conn
.
commit
()
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
sign in
to comment