Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated Activities. #153

Open
deanblacc opened this issue Aug 27, 2015 · 4 comments
Open

Duplicated Activities. #153

deanblacc opened this issue Aug 27, 2015 · 4 comments

Comments

@deanblacc
Copy link

Hello,
Im finding that after marking activities as read and seen using the mark_all method that a new activity with all the same attributes has been added to the aggregated feed. The only difference being that the new one has seen_at and read_at set to None.

As a result, it looks like the user always have a new notification.
Any idea under what circumstances this might occur ?

Cheers.

@Atorich
Copy link

Atorich commented Nov 20, 2015

+1

P.S. Using redis storage, RedisNotificationFeed

@Atorich
Copy link

Atorich commented Nov 20, 2015

I have made some code research and it seems that
https://github.com/tschellenbach/Stream-Framework/blob/master/stream_framework/feeds/aggregated_feed/base.py#L227

this code doesn't work right way. There is no such activity in the storage that presents in to_remove list.

@Atorich
Copy link

Atorich commented Nov 20, 2015

I've found that this problem caused by activity serialization issue: the same Activity may be serialized/deserialized/serialized again and serialized(1) will not be equals serialized(2).

This simple test demonstates it:

# -*- coding: utf-8 -*-
import itertools
from app.event_feed.manager import get_notification_manager

manager = get_notification_manager(user_id=1)

# there is some activites
activites = manager.all()

storage = manager.feed.timeline_storage
serialize = storage.serializer.dumps
deserialize = storage.serializer.loads

activity = activites[0]
serialized = []

for i in xrange(0, 3):
    v = serialize(activity)
    activity = deserialize(v)
    serialized.append(v)

combinations = itertools.combinations(serialized, 2)

for v1, v2 in combinations:
    assert v1 == v2, "Not equals: \n%s\n%s" % ([v1], [v2])  # using lists to avoid line breaks in serialized data

Result:

AssertionError: Not equals: 
["v32-14480368794430000000150002;;1448036879.443569;;1448036879.443569;;1448040340.245328;;-1;;0,2,150,1,1448036879.443569,(dp0\nS'post'\np1\n(dp2\nVstatus\np3\nI3\nsVupdated_date\np4\nV20.11.2015\np5\nsVdeleted_date\np6\nNsVpublished_date\np7\nV20.11.2015\np8\nsVpublished_time\np9\nV16:27\np10\nsVweight\np11\nF0.0848528137\nsVauthor\np12\n(dp13\nVusername\np14\nVadmin\np15\nsVid\np16\nI1\nsVemail\np17\[email protected]\np18\nssVdeleted\np19\nNsVtext\np20\nV<p>asfasdfasdf</p>\np21\nsVtitle\np22\nVasdfasdfdasf\np23\nsVupdated_time\np24\nV16:27\np25\nsVrate\np26\nF0.0\nsVdeleted_time\np27\nNsVcreated_time\np28\nV16:15\np29\nsVauthor_id\np30\nI1\nsVid\np31\nI604\nsVtags\np32\n(lp33\nVAsfdasf\np34\nasVcreated_date\np35\nV12.11.2015\np36\nssS'earnings'\np37\nF7.0\nsS'post_title'\np38\ng23\ns.;;0"]
["v32-14480368794430000000150002;;1448036879.443569;;1448036879.443569;;1448040340.245328;;-1;;0,2,150,1,1448036879.443569,(dp0\nS'post'\np1\n(dp2\nVstatus\np3\nI3\nsVupdated_date\np4\nV20.11.2015\np5\nsVpublished_time\np6\nV16:27\np7\nsVweight\np8\nF0.0848528137\nsVauthor\np9\n(dp10\nVusername\np11\nVadmin\np12\nsVid\np13\nI1\nsVemail\np14\[email protected]\np15\nssVdeleted\np16\nNsVtext\np17\nV<p>asfasdfasdf</p>\np18\nsVid\np19\nI604\nsVtitle\np20\nVasdfasdfdasf\np21\nsVupdated_time\np22\nV16:27\np23\nsVrate\np24\nF0.0\nsVdeleted_time\np25\nNsVpublished_date\np26\nV20.11.2015\np27\nsVcreated_time\np28\nV16:15\np29\nsVdeleted_date\np30\nNsVauthor_id\np31\nI1\nsVtags\np32\n(lp33\nVAsfdasf\np34\nasVcreated_date\np35\nV12.11.2015\np36\nssS'earnings'\np37\nF7.0\nsS'post_title'\np38\ng21\ns.;;0"]

As you can see above, there is the difference in serialized fields order.
So the problem is in pickle-ing extra_context (dict fields ordering).
Example: http://stackoverflow.com/questions/23069908/pickle-order-mystery

@Atorich
Copy link

Atorich commented Nov 21, 2015

Oh, it references #53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants