Skip to content

Commit

Permalink
Develop/dogwood/gacco201708 (openedx#2129)
Browse files Browse the repository at this point in the history
* addition of test code of the certificate issuance function openedx#2038 (openedx#2054)

* Mod translation of 'Course End Date:' openedx#2084 (openedx#2090)

* Add menu to ga_operation for ga_analyzer openedx#2039 (openedx#2088)

* Fixed bugs openedx#2039 (openedx#2112)

* Fixed csv format openedx#2039 (openedx#2127)

* Change to split download if there are many display items openedx#916 (openedx#2121)

* Change to split download if there are many display items openedx#916

* Fix UT

* Fix Review

* Fix review2
  • Loading branch information
sakamaki-y authored Sep 6, 2017
1 parent f3426fe commit c2903de
Show file tree
Hide file tree
Showing 32 changed files with 1,516 additions and 43 deletions.
44 changes: 37 additions & 7 deletions biz/djangoapps/ga_achievement/achievement_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ def get_record_document_by_username(self, username):
]
return self.get_document(conditions=conditions, excludes=excludes)

def get_record_documents(self):
def get_record_documents(self, offset=0, limit=0):
"""
Get stored documents which type is marked as 'record'
:param offset: Offset to documents
:param limit: Limit to documents (A limit() value of 0 (i.e. .limit(0)) is equivalent to setting no limit.)
:return: documents for record
e.g.)
[
Expand All @@ -137,12 +139,14 @@ def get_record_documents(self):
self.FIELD_COURSE_ID,
self.FIELD_DOCUMENT_TYPE,
]
return self.get_documents(conditions=conditions, excludes=excludes)
return self.get_documents(conditions=conditions, excludes=excludes, offset=offset, limit=limit)

def get_data_for_w2ui(self):
def get_data_for_w2ui(self, offset=0, limit=0):
"""
Get data for w2ui grid
:param offset: Offset to documents
:param limit: Limit to documents (A limit() value of 0 (i.e. .limit(0)) is equivalent to setting no limit.)
:return: data for w2ui grid
e.g.)
[
Expand All @@ -165,7 +169,7 @@ def get_data_for_w2ui(self):
]
"""
column_document = self.get_column_document()
record_documents = self.get_record_documents()
record_documents = self.get_record_documents(offset=offset, limit=limit)

# Note: json.dumps() of views.py converts OrderedDict into dict (it's orderless!), so items() here.
columns = column_document.items() if column_document is not None else []
Expand Down Expand Up @@ -244,6 +248,17 @@ def get_data_for_csv(self):
records.append(record)
return columns, records

def get_record_count(self):
"""
Get stored documents count
:return: documents count
"""
conditions = {
self.FIELD_DOCUMENT_TYPE: self.FIELD_DOCUMENT_TYPE__RECORD,
}
return self.get_count(conditions=conditions)


class ScoreStore(AchievementStoreBase):
"""
Expand Down Expand Up @@ -299,14 +314,16 @@ def get_column_document(self):
ordered[k] = self.COLUMN_TYPE__TEXT
return ordered

def get_record_documents(self):
def get_record_documents(self, offset=0, limit=0):
"""
Get stored documents which type is marked as 'record'
:param offset: Offset to documents
:param limit: Limit to documents (A limit() value of 0 (i.e. .limit(0)) is equivalent to setting no limit.)
:return: documents for record
"""
# For backward compatibility
record_documents = super(ScoreStore, self).get_record_documents()
record_documents = super(ScoreStore, self).get_record_documents(offset=offset, limit=limit)
if record_documents:
return record_documents

Expand All @@ -315,7 +332,20 @@ def get_record_documents(self):
self.FIELD_CONTRACT_ID,
self.FIELD_COURSE_ID,
]
return self.get_documents(excludes=excludes)
return self.get_documents(excludes=excludes, offset=offset, limit=limit)

def get_record_count(self):
"""
Get stored documents count
:return: documents count
"""
# For backward compatibility
record_count = super(ScoreStore, self).get_record_count()
if record_count:
return record_count

return self.get_count()


class PlaybackStore(AchievementStoreBase):
Expand Down
Loading

0 comments on commit c2903de

Please sign in to comment.