Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
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
Timo Ley
synapse
Commits
d74054af
Commit
d74054af
authored
5 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Shuffle the code
parent
bca3455b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/storage/data_stores/main/room.py
+16
-25
16 additions, 25 deletions
synapse/storage/data_stores/main/room.py
with
16 additions
and
25 deletions
synapse/storage/data_stores/main/room.py
+
16
−
25
View file @
d74054af
...
@@ -448,35 +448,21 @@ class RoomWorkerStore(SQLBaseStore):
...
@@ -448,35 +448,21 @@ class RoomWorkerStore(SQLBaseStore):
"""
"""
mxc_re
=
re
.
compile
(
"
^mxc://([^/]+)/([^/#?]+)
"
)
mxc_re
=
re
.
compile
(
"
^mxc://([^/]+)/([^/#?]+)
"
)
next_token
=
None
sql
=
"""
SELECT stream_ordering, json FROM events
JOIN event_json USING (room_id, event_id)
WHERE room_id = ?
%(where_clause)s
AND contains_url = ? AND outlier = ?
ORDER BY stream_ordering DESC
LIMIT ?
"""
txn
.
execute
(
sql
%
{
"
where_clause
"
:
""
},
(
room_id
,
True
,
False
,
100
))
local_media_mxcs
=
[]
local_media_mxcs
=
[]
remote_media_mxcs
=
[]
remote_media_mxcs
=
[]
while
True
:
while
True
:
# The first time round we just want to get the most recent
# events, then we bound by stream ordering
if
next_token
is
None
:
sql
=
"""
SELECT stream_ordering, json FROM events
JOIN event_json USING (room_id, event_id)
WHERE room_id = ?
AND contains_url = ? AND outlier = ?
ORDER BY stream_ordering DESC
LIMIT ?
"""
txn
.
execute
(
sql
,
(
room_id
,
True
,
False
,
100
))
else
:
sql
=
"""
SELECT stream_ordering, json FROM events
JOIN event_json USING (room_id, event_id)
WHERE room_id = ?
AND stream_ordering < ?
AND contains_url = ? AND outlier = ?
ORDER BY stream_ordering DESC
LIMIT ?
"""
txn
.
execute
(
sql
,
(
room_id
,
next_token
,
True
,
False
,
100
))
next_token
=
None
next_token
=
None
for
stream_ordering
,
content_json
in
txn
:
for
stream_ordering
,
content_json
in
txn
:
next_token
=
stream_ordering
next_token
=
stream_ordering
...
@@ -501,6 +487,11 @@ class RoomWorkerStore(SQLBaseStore):
...
@@ -501,6 +487,11 @@ class RoomWorkerStore(SQLBaseStore):
# We've gone through the whole room, so we're finished.
# We've gone through the whole room, so we're finished.
break
break
txn
.
execute
(
sql
%
{
"
where_clause
"
:
"
AND stream_ordering < ?
"
},
(
room_id
,
next_token
,
True
,
False
,
100
),
)
return
local_media_mxcs
,
remote_media_mxcs
return
local_media_mxcs
,
remote_media_mxcs
...
...
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