Show More
@@ -398,12 +398,14 b' class MyAccountView(BaseAppView, DataGri' | |||||
398 | def my_account_bookmarks(self): |
|
398 | def my_account_bookmarks(self): | |
399 | c = self.load_default_context() |
|
399 | c = self.load_default_context() | |
400 | c.active = 'bookmarks' |
|
400 | c.active = 'bookmarks' | |
|
401 | c.bookmark_items = UserBookmark.get_bookmarks_for_user( | |||
|
402 | self._rhodecode_db_user.user_id, cache=False) | |||
401 | return self._get_template_context(c) |
|
403 | return self._get_template_context(c) | |
402 |
|
404 | |||
403 | def _process_bookmark_entry(self, entry, user_id): |
|
405 | def _process_bookmark_entry(self, entry, user_id): | |
404 | position = safe_int(entry.get('position')) |
|
406 | position = safe_int(entry.get('position')) | |
405 | cur_position = safe_int(entry.get('cur_position')) |
|
407 | cur_position = safe_int(entry.get('cur_position')) | |
406 |
if position is None |
|
408 | if position is None: | |
407 | return |
|
409 | return | |
408 |
|
410 | |||
409 | # check if this is an existing entry |
|
411 | # check if this is an existing entry |
@@ -5151,13 +5151,19 b' class UserBookmark(Base, BaseModel):' | |||||
5151 | .filter(UserBookmark.position == position).scalar() |
|
5151 | .filter(UserBookmark.position == position).scalar() | |
5152 |
|
5152 | |||
5153 | @classmethod |
|
5153 | @classmethod | |
5154 | def get_bookmarks_for_user(cls, user_id): |
|
5154 | def get_bookmarks_for_user(cls, user_id, cache=True): | |
5155 |
|
|
5155 | bookmarks = cls.query() \ | |
5156 | .filter(UserBookmark.user_id == user_id) \ |
|
5156 | .filter(UserBookmark.user_id == user_id) \ | |
5157 | .options(joinedload(UserBookmark.repository)) \ |
|
5157 | .options(joinedload(UserBookmark.repository)) \ | |
5158 | .options(joinedload(UserBookmark.repository_group)) \ |
|
5158 | .options(joinedload(UserBookmark.repository_group)) \ | |
5159 |
.order_by(UserBookmark.position.asc()) |
|
5159 | .order_by(UserBookmark.position.asc()) | |
5160 | .all() |
|
5160 | ||
|
5161 | if cache: | |||
|
5162 | bookmarks = bookmarks.options( | |||
|
5163 | FromCache("sql_cache_short", "get_user_{}_bookmarks".format(user_id)) | |||
|
5164 | ) | |||
|
5165 | ||||
|
5166 | return bookmarks.all() | |||
5161 |
|
5167 | |||
5162 | def __unicode__(self): |
|
5168 | def __unicode__(self): | |
5163 | return u'<UserBookmark(%s @ %r)>' % (self.position, self.redirect_url) |
|
5169 | return u'<UserBookmark(%s @ %r)>' % (self.position, self.redirect_url) |
General Comments 0
You need to be logged in to leave comments.
Login now