Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
255267d4
Commit
255267d4
authored
Jun 16, 2016
by
David Ormsbee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create forums config model for adjusting connection timeouts.
parent
32b8391c
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
9 deletions
+64
-9
common/djangoapps/django_comment_common/admin.py
+9
-0
common/djangoapps/django_comment_common/migrations/0002_forumsconfig.py
+31
-0
common/djangoapps/django_comment_common/models.py
+12
-0
lms/djangoapps/django_comment_client/base/tests.py
+4
-4
lms/djangoapps/django_comment_client/forum/tests.py
+4
-4
lms/lib/comment_client/utils.py
+4
-1
No files found.
common/djangoapps/django_comment_common/admin.py
0 → 100644
View file @
255267d4
"""
Admin for managing the connection to the Forums backend service.
"""
from
django.contrib
import
admin
from
.models
import
ForumsConfig
admin
.
site
.
register
(
ForumsConfig
)
common/djangoapps/django_comment_common/migrations/0002_forumsconfig.py
0 → 100644
View file @
255267d4
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
django.db.models.deletion
from
django.conf
import
settings
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
migrations
.
swappable_dependency
(
settings
.
AUTH_USER_MODEL
),
(
'django_comment_common'
,
'0001_initial'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'ForumsConfig'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
verbose_name
=
'ID'
,
serialize
=
False
,
auto_created
=
True
,
primary_key
=
True
)),
(
'change_date'
,
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'Change date'
)),
(
'enabled'
,
models
.
BooleanField
(
default
=
False
,
verbose_name
=
'Enabled'
)),
(
'connection_timeout'
,
models
.
FloatField
(
default
=
5.0
)),
(
'changed_by'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
PROTECT
,
editable
=
False
,
to
=
settings
.
AUTH_USER_MODEL
,
null
=
True
,
verbose_name
=
'Changed by'
)),
],
options
=
{
'ordering'
:
(
'-change_date'
,),
'abstract'
:
False
,
},
),
]
common/djangoapps/django_comment_common/models.py
View file @
255267d4
...
...
@@ -7,6 +7,7 @@ from django.dispatch import receiver
from
django.db.models.signals
import
post_save
from
django.utils.translation
import
ugettext_noop
from
config_models.models
import
ConfigurationModel
from
student.models
import
CourseEnrollment
from
xmodule.modulestore.django
import
modulestore
...
...
@@ -137,3 +138,14 @@ def all_permissions_for_user_in_course(user, course_id): # pylint: disable=inva
if
not
permission_blacked_out
(
course
,
all_roles
,
permission
.
name
)
}
return
permissions
class
ForumsConfig
(
ConfigurationModel
):
"""Config for the connection to the cs_comments_service forums backend."""
# For now, just tweak the connection timeout settings. We can add more later.
connection_timeout
=
models
.
FloatField
(
default
=
5.0
)
def
__unicode__
(
self
):
"""Simple representation so the admin screen looks less ugly."""
return
u"ForumsConfig: timeout={}"
.
format
(
self
.
connection_timeout
)
lms/djangoapps/django_comment_client/base/tests.py
View file @
255267d4
...
...
@@ -372,8 +372,8 @@ class ViewsQueryCountTestCase(UrlResetMixin, ModuleStoreTestCase, MockRequestSet
return
inner
@ddt.data
(
(
ModuleStoreEnum
.
Type
.
mongo
,
3
,
4
,
29
),
(
ModuleStoreEnum
.
Type
.
split
,
3
,
13
,
29
),
(
ModuleStoreEnum
.
Type
.
mongo
,
3
,
4
,
30
),
(
ModuleStoreEnum
.
Type
.
split
,
3
,
13
,
30
),
)
@ddt.unpack
@count_queries
...
...
@@ -381,8 +381,8 @@ class ViewsQueryCountTestCase(UrlResetMixin, ModuleStoreTestCase, MockRequestSet
self
.
create_thread_helper
(
mock_request
)
@ddt.data
(
(
ModuleStoreEnum
.
Type
.
mongo
,
3
,
3
,
2
3
),
(
ModuleStoreEnum
.
Type
.
split
,
3
,
10
,
2
3
),
(
ModuleStoreEnum
.
Type
.
mongo
,
3
,
3
,
2
4
),
(
ModuleStoreEnum
.
Type
.
split
,
3
,
10
,
2
4
),
)
@ddt.unpack
@count_queries
...
...
lms/djangoapps/django_comment_client/forum/tests.py
View file @
255267d4
...
...
@@ -342,11 +342,11 @@ class SingleThreadQueryCountTestCase(ModuleStoreTestCase):
@ddt.data
(
# old mongo with cache
(
ModuleStoreEnum
.
Type
.
mongo
,
1
,
6
,
4
,
1
6
,
8
),
(
ModuleStoreEnum
.
Type
.
mongo
,
50
,
6
,
4
,
1
6
,
8
),
(
ModuleStoreEnum
.
Type
.
mongo
,
1
,
6
,
4
,
1
8
,
10
),
(
ModuleStoreEnum
.
Type
.
mongo
,
50
,
6
,
4
,
1
8
,
10
),
# split mongo: 3 queries, regardless of thread response size.
(
ModuleStoreEnum
.
Type
.
split
,
1
,
3
,
3
,
1
6
,
8
),
(
ModuleStoreEnum
.
Type
.
split
,
50
,
3
,
3
,
1
6
,
8
),
(
ModuleStoreEnum
.
Type
.
split
,
1
,
3
,
3
,
1
8
,
10
),
(
ModuleStoreEnum
.
Type
.
split
,
50
,
3
,
3
,
1
8
,
10
),
)
@ddt.unpack
def
test_number_of_mongo_queries
(
...
...
lms/lib/comment_client/utils.py
View file @
255267d4
...
...
@@ -53,6 +53,8 @@ def request_timer(request_id, method, url, tags=None):
def
perform_request
(
method
,
url
,
data_or_params
=
None
,
raw
=
False
,
metric_action
=
None
,
metric_tags
=
None
,
paged_results
=
False
):
# To avoid dependency conflict
from
django_comment_common.models
import
ForumsConfig
if
metric_tags
is
None
:
metric_tags
=
[]
...
...
@@ -77,13 +79,14 @@ def perform_request(method, url, data_or_params=None, raw=False,
data
=
None
params
=
merge_dict
(
data_or_params
,
request_id_dict
)
with
request_timer
(
request_id
,
method
,
url
,
metric_tags
):
config
=
ForumsConfig
.
current
()
response
=
requests
.
request
(
method
,
url
,
data
=
data
,
params
=
params
,
headers
=
headers
,
timeout
=
5
timeout
=
config
.
connection_timeout
)
metric_tags
.
append
(
u'status_code:{}'
.
format
(
response
.
status_code
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment