Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
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
TeDomum
Matrix
Commits
fce01140
Commit
fce01140
authored
10 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Start removing Tables
parent
7e282a53
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/storage/room.py
+17
-18
17 additions, 18 deletions
synapse/storage/room.py
synapse/storage/transactions.py
+12
-8
12 additions, 8 deletions
synapse/storage/transactions.py
with
29 additions
and
26 deletions
synapse/storage/room.py
+
17
−
18
View file @
fce01140
...
...
@@ -15,11 +15,9 @@
from
twisted.internet
import
defer
from
sqlite3
import
IntegrityError
from
synapse.api.errors
import
StoreError
from
._base
import
SQLBaseStore
,
Table
from
._base
import
SQLBaseStore
import
collections
import
logging
...
...
@@ -27,8 +25,9 @@ import logging
logger
=
logging
.
getLogger
(
__name__
)
OpsLevel
=
collections
.
namedtuple
(
"
OpsLevel
"
,
(
"
ban_level
"
,
"
kick_level
"
,
"
redact_level
"
)
OpsLevel
=
collections
.
namedtuple
(
"
OpsLevel
"
,
(
"
ban_level
"
,
"
kick_level
"
,
"
redact_level
"
,)
)
...
...
@@ -47,13 +46,14 @@ class RoomStore(SQLBaseStore):
StoreError if the room could not be stored.
"""
try
:
yield
self
.
_simple_insert
(
RoomsTable
.
table_name
,
dict
(
room_id
=
room_id
,
creator
=
room_creator_user_id
,
is_public
=
is_public
))
except
IntegrityError
:
raise
StoreError
(
409
,
"
Room ID in use.
"
)
yield
self
.
_simple_insert
(
RoomsTable
.
table_name
,
{
"
room_id
"
:
room_id
,
"
creator
"
:
room_creator_user_id
,
"
is_public
"
:
is_public
,
}
)
except
Exception
as
e
:
logger
.
error
(
"
store_room with room_id=%s failed: %s
"
,
room_id
,
e
)
raise
StoreError
(
500
,
"
Problem creating room.
"
)
...
...
@@ -66,9 +66,10 @@ class RoomStore(SQLBaseStore):
Returns:
A namedtuple containing the room information, or an empty list.
"""
query
=
RoomsTable
.
select_statement
(
"
room_id=?
"
)
return
self
.
_execute
(
"
get_room
"
,
RoomsTable
.
decode_single_result
,
query
,
room_id
,
return
self
.
_simple_select_one
(
table
=
RoomsTable
.
table_name
,
keyvalues
=
{
"
room_id
"
:
room_id
},
retcols
=
RoomsTable
.
fields
,
)
@defer.inlineCallbacks
...
...
@@ -196,7 +197,7 @@ class RoomStore(SQLBaseStore):
defer
.
returnValue
((
name
,
aliases
))
class
RoomsTable
(
Table
):
class
RoomsTable
(
object
):
table_name
=
"
rooms
"
fields
=
[
...
...
@@ -204,5 +205,3 @@ class RoomsTable(Table):
"
is_public
"
,
"
creator
"
]
EntryType
=
collections
.
namedtuple
(
"
RoomEntry
"
,
fields
)
This diff is collapsed.
Click to expand it.
synapse/storage/transactions.py
+
12
−
8
View file @
fce01140
...
...
@@ -46,15 +46,19 @@ class TransactionStore(SQLBaseStore):
)
def
_get_received_txn_response
(
self
,
txn
,
transaction_id
,
origin
):
where_clause
=
"
transaction_id = ? AND origin = ?
"
query
=
ReceivedTransactionsTable
.
select_statement
(
where_clause
)
txn
.
execute
(
query
,
(
transaction_id
,
origin
))
results
=
ReceivedTransactionsTable
.
decode_results
(
txn
.
fetchall
())
result
=
self
.
_simple_select_one_txn
(
txn
,
table
=
ReceivedTransactionsTable
.
table_name
,
keyvalues
=
{
"
transaction_id
"
:
transaction_id
,
"
origin
"
:
origin
,
},
retcols
=
ReceivedTransactionsTable
.
fields
,
allow_none
=
True
,
)
if
result
s
and
result
s
[
0
]
.
response_code
:
return
(
result
s
[
0
].
response_code
,
result
s
[
0
].
response_json
)
if
result
and
result
.
response_code
:
return
result
[
"
response_code
"
]
,
result
[
"
response_json
"
]
else
:
return
None
...
...
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