Merge pull request #3728 from edx/gprice/forum-search-logging
Add logging of search quality information
This commit is contained in:
@@ -18,6 +18,8 @@ The primary collection that holds all of the discussion posts written by users i
|
||||
|
||||
A sample of the field/value pairs that are in the mongo file, and descriptions of the attributes that these two types of objects share and that are specific to each type, follow.
|
||||
|
||||
In addition to these collections, events are also emitted to track specific user activities. See :ref:`forum_events`.
|
||||
|
||||
*********
|
||||
Samples
|
||||
*********
|
||||
|
||||
@@ -38,6 +38,8 @@ Event List
|
||||
- :ref:`enrollment` and :ref:`instructor_enrollment`
|
||||
* - ``edx.course.enrollment.deactivated``
|
||||
- :ref:`enrollment` and :ref:`instructor_enrollment`
|
||||
* - ``edx.forum.searched``
|
||||
- :ref:`forum_events`
|
||||
* - ``get_anon_ids``
|
||||
- :ref:`Instructor_Event_Types`
|
||||
* - ``get_student_progress_page``
|
||||
|
||||
@@ -292,6 +292,8 @@ outside the Instructor Dashboard.
|
||||
|
||||
* :ref:`AB_Event_Types`
|
||||
|
||||
* :ref:`forum_events`
|
||||
|
||||
The descriptions that follow include what each event represents, the system
|
||||
component it originates from, the history of any changes made to the event over
|
||||
time, and any additional member fields that the ``context`` and ``event`` fields contain.
|
||||
@@ -1762,6 +1764,33 @@ the child module that was shown to the student.
|
||||
- string
|
||||
- ID of the module that displays to the student.
|
||||
|
||||
.. _forum_events:
|
||||
|
||||
==========================
|
||||
Forum Events
|
||||
==========================
|
||||
|
||||
``edx.forum.searched``
|
||||
----------------------------------
|
||||
|
||||
After a user executes a text search in the navigation sidebar of the Discussion tab of a course, the server emits an ``edx.forum.text_search`` event.
|
||||
|
||||
**Component**: Discussion Tab
|
||||
|
||||
**Event Source**: Server
|
||||
|
||||
**History**: Added 16 May 2014.
|
||||
|
||||
``event`` **Fields**:
|
||||
|
||||
+---------------------+---------------+---------------------------------------------------------------------+
|
||||
| Field | Type | Details |
|
||||
+=====================+===============+=====================================================================+
|
||||
| ``query`` | string | The text entered into the search box by the user. |
|
||||
+---------------------+---------------+---------------------------------------------------------------------+
|
||||
| ``total_results`` | integer | The total number of results matching the query. |
|
||||
+---------------------+---------------+---------------------------------------------------------------------+
|
||||
|
||||
.. _Instructor_Event_Types:
|
||||
|
||||
*************************
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import logging
|
||||
|
||||
from eventtracking import tracker
|
||||
from .utils import merge_dict, strip_blank, strip_none, extract, perform_request
|
||||
from .utils import CommentClientRequestError
|
||||
import models
|
||||
import settings
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class Thread(models.Model):
|
||||
|
||||
@@ -54,6 +58,26 @@ class Thread(models.Model):
|
||||
metric_action='thread.search',
|
||||
paged_results=True
|
||||
)
|
||||
if query_params.get('text'):
|
||||
search_query = query_params['text']
|
||||
course_id = query_params['course_id']
|
||||
total_results = response.get('total_results')
|
||||
# Record search result metric to allow search quality analysis.
|
||||
# course_id is already included in the context for the event tracker
|
||||
tracker.emit(
|
||||
'edx.forum.searched',
|
||||
{
|
||||
'query': search_query,
|
||||
'total_results': total_results,
|
||||
}
|
||||
)
|
||||
log.info(
|
||||
'forum_text_search query="{search_query}" course_id={course_id} total_results={total_results}'.format(
|
||||
search_query=search_query,
|
||||
course_id=course_id,
|
||||
total_results=total_results
|
||||
)
|
||||
)
|
||||
return response.get('collection', []), response.get('page', 1), response.get('num_pages', 1)
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user