Skip to content

Commit

Permalink
Caching home cards per company (#1038)
Browse files Browse the repository at this point in the history
* Caching home cards per company

* Ading email validator

* Skipping user sign up

Co-authored-by: Tolga Akin <[email protected]>
  • Loading branch information
akintolga and Tolga Akin authored Apr 23, 2020
1 parent 9e96d68 commit 3258b12
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions newsroom/wire/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ def get_view_data():


def get_items_by_card(cards, company_id):
if app.cache.get(HOME_ITEMS_CACHE_KEY):
return app.cache.get(HOME_ITEMS_CACHE_KEY)
cache_key = '{}{}'.format(HOME_ITEMS_CACHE_KEY, company_id or '')
if app.cache.get(cache_key):
return app.cache.get(cache_key)

items_by_card = {}
for card in cards:
Expand All @@ -83,7 +84,7 @@ def get_items_by_card(cards, company_id):
elif card['type'] == '4-photo-gallery':
items_by_card[card['label']] = app.get_media_cards_external(card)

app.cache.set(HOME_ITEMS_CACHE_KEY, items_by_card, timeout=300)
app.cache.set(cache_key, items_by_card, timeout=300)
return items_by_card


Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
werkzeug>=0.9.4,<=0.11.15
email-validator==1.0.5
-e .
git+git://github.com/superdesk/[email protected]#egg=superdesk-planning
git+git://github.com/superdesk/superdesk-core.git@master#egg=superdesk-core
3 changes: 2 additions & 1 deletion tests/test_auth.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
from flask import url_for
from bson import ObjectId
from pytest import fixture
from pytest import fixture, mark
from superdesk import get_resource_service
from superdesk.utils import get_hash

Expand Down Expand Up @@ -58,6 +58,7 @@ def test_new_user_signup_sends_email(app, client):
assert 'Press co.' in outbox[0].body


@mark.skip(reason="STT doesn't have sign up")
def test_new_user_signup_fails_if_fields_not_provided(client):
# Register a new account
response = client.post(url_for('auth.signup'), data={
Expand Down

0 comments on commit 3258b12

Please sign in to comment.