{"action":"closed","number":595,"pull_request":{"url":"https://api.github.com/repos/opendatateam/udata/pulls/595","id":90240686,"html_url":"https://github.com/opendatateam/udata/pull/595","diff_url":"https://github.com/opendatateam/udata/pull/595.diff","patch_url":"https://github.com/opendatateam/udata/pull/595.patch","issue_url":"https://api.github.com/repos/opendatateam/udata/issues/595","number":595,"state":"closed","locked":false,"title":"Display the correct number of followers in the reuses list (fixes #20)","user":{"login":"jphnoel","id":7070530,"avatar_url":"https://avatars.githubusercontent.com/u/7070530?v=3","gravatar_id":"","url":"https://api.github.com/users/jphnoel","html_url":"https://github.com/jphnoel","followers_url":"https://api.github.com/users/jphnoel/followers","following_url":"https://api.github.com/users/jphnoel/following{/other_user}","gists_url":"https://api.github.com/users/jphnoel/gists{/gist_id}","starred_url":"https://api.github.com/users/jphnoel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jphnoel/subscriptions","organizations_url":"https://api.github.com/users/jphnoel/orgs","repos_url":"https://api.github.com/users/jphnoel/repos","events_url":"https://api.github.com/users/jphnoel/events{/privacy}","received_events_url":"https://api.github.com/users/jphnoel/received_events","type":"User","site_admin":false},"body":"This PR aims at solving #20, which is easy to reproduce in a dev environment.\r\n\r\nThere were actually several problems:\r\n1. There was an obvious bug in the template search-result.html.\r\n2. There were also some bugs in metrics.py, which occured probably only in the dev environment.\r\n3. When clicking on the 'Follow' button, a POST request was sent to the server, which crashed, in slug_fields.py, which prevented the metrics from being updated.\r\n\r\nWhen the problem 3 occurs, I have the following traces in the standard output:\r\n```\r\nERROR: Exception on /api/1/reuses/57ff416b82412f3ecd7495f7/followers/ [POST]\r\n  | Traceback (most recent call last):\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/flask/app.py\", line 1639, in full_dispatch_request\r\n  |     rv = self.dispatch_request()\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/flask/app.py\", line 1625, in dispatch_request\r\n  |     return self.view_functions[rule.endpoint](**req.view_args)\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/flask_restplus/cors.py\", line 38, in wrapped_function\r\n  |     resp = make_response(f(*args, **kwargs))\r\n  |   File \"/home/jpnoel/udata/udata/api/__init__.py\", line 92, in wrapper\r\n  |     return func(*args, **kwargs)\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/flask_restplus/api.py\", line 309, in wrapper\r\n  |     resp = resource(*args, **kwargs)\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/flask/views.py\", line 84, in view\r\n  |     return self.dispatch_request(*args, **kwargs)\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/flask_restplus/resource.py\", line 44, in dispatch_request\r\n  |     resp = meth(*args, **kwargs)\r\n  |   File \"/home/jpnoel/udata/udata/api/__init__.py\", line 83, in wrapper\r\n  |     return func(*args, **kwargs)\r\n  |   File \"/home/jpnoel/udata/udata/core/followers/api.py\", line 60, in post\r\n  |     follower=current_user.id, following=model, until=None)\r\n  |   File \"/home/jpnoel/udata/udata/models/__init__.py\", line 141, in get_or_create\r\n  |     doc.save(write_concern=write_concern)\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/mongoengine/document.py\", line 403, in save\r\n  |     signals.post_save.send(self.__class__, document=self, created=created)\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/blinker/base.py\", line 267, in send\r\n  |     for receiver in self.receivers_for(sender)]\r\n  |   File \"/home/jpnoel/udata/udata/core/followers/models.py\", line 48, in emit_new_follower\r\n  |     on_follow.send(document)\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/blinker/base.py\", line 267, in send\r\n  |     for receiver in self.receivers_for(sender)]\r\n  |   File \"/home/jpnoel/udata/udata/core/followers/metrics.py\", line 21, in callback\r\n  |     new_class(follow.following).trigger_update()\r\n  |   File \"/home/jpnoel/udata/udata/core/metrics/__init__.py\", line 115, in trigger_update\r\n  |     self.need_update.send(self)\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/blinker/base.py\", line 267, in send\r\n  |     for receiver in self.receivers_for(sender)]\r\n  |   File \"/home/jpnoel/udata/udata/core/metrics/__init__.py\", line 23, in update_on_demand\r\n  |     update_metric.delay(metric)\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/celery/app/task.py\", line 461, in delay\r\n  |     return self.apply_async(args, kwargs)\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/celery/app/task.py\", line 573, in apply_async\r\n  |     **dict(self._get_exec_options(), **options)\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/celery/app/base.py\", line 354, in send_task\r\n  |     reply_to=reply_to or self.oid, **options\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/celery/app/amqp.py\", line 310, in publish_task\r\n  |     **kwargs\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/kombu/messaging.py\", line 165, in publish\r\n  |     compression, headers)\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/kombu/messaging.py\", line 241, in _prepare\r\n  |     body) = dumps(body, serializer=serializer)\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/kombu/serialization.py\", line 164, in dumps\r\n  |     payload = encoder(data)\r\n  |   File \"/usr/lib/python2.7/contextlib.py\", line 35, in __exit__\r\n  |     self.gen.throw(type, value, traceback)\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/kombu/serialization.py\", line 59, in _reraise_errors\r\n  |     reraise(wrapper, wrapper(exc), sys.exc_info()[2])\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/kombu/serialization.py\", line 55, in _reraise_errors\r\n  |     yield\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/kombu/serialization.py\", line 164, in dumps\r\n  |     payload = encoder(data)\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/kombu/serialization.py\", line 356, in pickle_dumps\r\n  |     return dumper(obj, protocol=pickle_protocol)\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/mongoengine/base/document.py\", line 195, in __getstate__\r\n  |     data['_data'] = self.to_mongo()\r\n  |   File \"/home/jpnoel/.virtualenvs/udata/local/lib/python2.7/site-packages/mongoengine/base/document.py\", line 345, in to_mongo\r\n  |     value = field.generate()\r\n  |   File \"/home/jpnoel/udata/udata/models/slug_fields.py\", line 44, in generate\r\n  |     return populate_slug(self.instance, self)\r\n  |   File \"/home/jpnoel/udata/udata/models/slug_fields.py\", line 91, in populate_slug\r\n  |     value = value.lower()\r\n  | EncodeError: 'NoneType' object has no attribute 'lower'\r\n```\r\n\r\nTo fix the problem 3, I must remove the `only('id')` part in followers/api.py.\r\n\r\nBut this is not really satisfactory, indeed:\r\n\r\n- I do not exactly understand the problem 3, even if it seems to be related to the serialization, when sending a message to the celery worker to update the metrics \r\n- [This test ](https://github.com/opendatateam/udata/blob/dev/udata/tests/api/test_reuses_api.py#L217) should fail without the modification on followers/api.py, but it does not.","created_at":"2016-10-20T16:58:48Z","updated_at":"2016-10-25T13:36:32Z","closed_at":"2016-10-25T13:36:32Z","merged_at":"2016-10-25T13:36:32Z","merge_commit_sha":"26af341b2b7ae70ef516e019e850a402e4b2cd0a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/opendatateam/udata/pulls/595/commits","review_comments_url":"https://api.github.com/repos/opendatateam/udata/pulls/595/comments","review_comment_url":"https://api.github.com/repos/opendatateam/udata/pulls/comments{/number}","comments_url":"https://api.github.com/repos/opendatateam/udata/issues/595/comments","statuses_url":"https://api.github.com/repos/opendatateam/udata/statuses/3549bf2bd856ec9713a5465a4969cff25958a65f","head":{"label":"jphnoel:20","ref":"20","sha":"3549bf2bd856ec9713a5465a4969cff25958a65f","user":{"login":"jphnoel","id":7070530,"avatar_url":"https://avatars.githubusercontent.com/u/7070530?v=3","gravatar_id":"","url":"https://api.github.com/users/jphnoel","html_url":"https://github.com/jphnoel","followers_url":"https://api.github.com/users/jphnoel/followers","following_url":"https://api.github.com/users/jphnoel/following{/other_user}","gists_url":"https://api.github.com/users/jphnoel/gists{/gist_id}","starred_url":"https://api.github.com/users/jphnoel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jphnoel/subscriptions","organizations_url":"https://api.github.com/users/jphnoel/orgs","repos_url":"https://api.github.com/users/jphnoel/repos","events_url":"https://api.github.com/users/jphnoel/events{/privacy}","received_events_url":"https://api.github.com/users/jphnoel/received_events","type":"User","site_admin":false},"repo":{"id":67027070,"name":"udata","full_name":"jphnoel/udata","owner":{"login":"jphnoel","id":7070530,"avatar_url":"https://avatars.githubusercontent.com/u/7070530?v=3","gravatar_id":"","url":"https://api.github.com/users/jphnoel","html_url":"https://github.com/jphnoel","followers_url":"https://api.github.com/users/jphnoel/followers","following_url":"https://api.github.com/users/jphnoel/following{/other_user}","gists_url":"https://api.github.com/users/jphnoel/gists{/gist_id}","starred_url":"https://api.github.com/users/jphnoel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jphnoel/subscriptions","organizations_url":"https://api.github.com/users/jphnoel/orgs","repos_url":"https://api.github.com/users/jphnoel/repos","events_url":"https://api.github.com/users/jphnoel/events{/privacy}","received_events_url":"https://api.github.com/users/jphnoel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jphnoel/udata","description":"Customizable and skinnable social platform dedicated to (open)data.","fork":true,"url":"https://api.github.com/repos/jphnoel/udata","forks_url":"https://api.github.com/repos/jphnoel/udata/forks","keys_url":"https://api.github.com/repos/jphnoel/udata/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jphnoel/udata/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jphnoel/udata/teams","hooks_url":"https://api.github.com/repos/jphnoel/udata/hooks","issue_events_url":"https://api.github.com/repos/jphnoel/udata/issues/events{/number}","events_url":"https://api.github.com/repos/jphnoel/udata/events","assignees_url":"https://api.github.com/repos/jphnoel/udata/assignees{/user}","branches_url":"https://api.github.com/repos/jphnoel/udata/branches{/branch}","tags_url":"https://api.github.com/repos/jphnoel/udata/tags","blobs_url":"https://api.github.com/repos/jphnoel/udata/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jphnoel/udata/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jphnoel/udata/git/refs{/sha}","trees_url":"https://api.github.com/repos/jphnoel/udata/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jphnoel/udata/statuses/{sha}","languages_url":"https://api.github.com/repos/jphnoel/udata/languages","stargazers_url":"https://api.github.com/repos/jphnoel/udata/stargazers","contributors_url":"https://api.github.com/repos/jphnoel/udata/contributors","subscribers_url":"https://api.github.com/repos/jphnoel/udata/subscribers","subscription_url":"https://api.github.com/repos/jphnoel/udata/subscription","commits_url":"https://api.github.com/repos/jphnoel/udata/commits{/sha}","git_commits_url":"https://api.github.com/repos/jphnoel/udata/git/commits{/sha}","comments_url":"https://api.github.com/repos/jphnoel/udata/comments{/number}","issue_comment_url":"https://api.github.com/repos/jphnoel/udata/issues/comments{/number}","contents_url":"https://api.github.com/repos/jphnoel/udata/contents/{+path}","compare_url":"https://api.github.com/repos/jphnoel/udata/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jphnoel/udata/merges","archive_url":"https://api.github.com/repos/jphnoel/udata/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jphnoel/udata/downloads","issues_url":"https://api.github.com/repos/jphnoel/udata/issues{/number}","pulls_url":"https://api.github.com/repos/jphnoel/udata/pulls{/number}","milestones_url":"https://api.github.com/repos/jphnoel/udata/milestones{/number}","notifications_url":"https://api.github.com/repos/jphnoel/udata/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jphnoel/udata/labels{/name}","releases_url":"https://api.github.com/repos/jphnoel/udata/releases{/id}","deployments_url":"https://api.github.com/repos/jphnoel/udata/deployments","created_at":"2016-08-31T10:15:53Z","updated_at":"2016-08-31T10:15:55Z","pushed_at":"2016-10-25T13:27:26Z","git_url":"git://github.com/jphnoel/udata.git","ssh_url":"git@github.com:jphnoel/udata.git","clone_url":"https://github.com/jphnoel/udata.git","svn_url":"https://github.com/jphnoel/udata","homepage":"http://udata.readthedocs.org","size":7370,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"opendatateam:dev","ref":"dev","sha":"9123873be31ad20e2f0e023ab050c4634ee1b2d2","user":{"login":"opendatateam","id":19330690,"avatar_url":"https://avatars.githubusercontent.com/u/19330690?v=3","gravatar_id":"","url":"https://api.github.com/users/opendatateam","html_url":"https://github.com/opendatateam","followers_url":"https://api.github.com/users/opendatateam/followers","following_url":"https://api.github.com/users/opendatateam/following{/other_user}","gists_url":"https://api.github.com/users/opendatateam/gists{/gist_id}","starred_url":"https://api.github.com/users/opendatateam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opendatateam/subscriptions","organizations_url":"https://api.github.com/users/opendatateam/orgs","repos_url":"https://api.github.com/users/opendatateam/repos","events_url":"https://api.github.com/users/opendatateam/events{/privacy}","received_events_url":"https://api.github.com/users/opendatateam/received_events","type":"Organization","site_admin":false},"repo":{"id":19141754,"name":"udata","full_name":"opendatateam/udata","owner":{"login":"opendatateam","id":19330690,"avatar_url":"https://avatars.githubusercontent.com/u/19330690?v=3","gravatar_id":"","url":"https://api.github.com/users/opendatateam","html_url":"https://github.com/opendatateam","followers_url":"https://api.github.com/users/opendatateam/followers","following_url":"https://api.github.com/users/opendatateam/following{/other_user}","gists_url":"https://api.github.com/users/opendatateam/gists{/gist_id}","starred_url":"https://api.github.com/users/opendatateam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opendatateam/subscriptions","organizations_url":"https://api.github.com/users/opendatateam/orgs","repos_url":"https://api.github.com/users/opendatateam/repos","events_url":"https://api.github.com/users/opendatateam/events{/privacy}","received_events_url":"https://api.github.com/users/opendatateam/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opendatateam/udata","description":"Customizable and skinnable social platform dedicated to (open)data.","fork":false,"url":"https://api.github.com/repos/opendatateam/udata","forks_url":"https://api.github.com/repos/opendatateam/udata/forks","keys_url":"https://api.github.com/repos/opendatateam/udata/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opendatateam/udata/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opendatateam/udata/teams","hooks_url":"https://api.github.com/repos/opendatateam/udata/hooks","issue_events_url":"https://api.github.com/repos/opendatateam/udata/issues/events{/number}","events_url":"https://api.github.com/repos/opendatateam/udata/events","assignees_url":"https://api.github.com/repos/opendatateam/udata/assignees{/user}","branches_url":"https://api.github.com/repos/opendatateam/udata/branches{/branch}","tags_url":"https://api.github.com/repos/opendatateam/udata/tags","blobs_url":"https://api.github.com/repos/opendatateam/udata/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opendatateam/udata/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opendatateam/udata/git/refs{/sha}","trees_url":"https://api.github.com/repos/opendatateam/udata/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opendatateam/udata/statuses/{sha}","languages_url":"https://api.github.com/repos/opendatateam/udata/languages","stargazers_url":"https://api.github.com/repos/opendatateam/udata/stargazers","contributors_url":"https://api.github.com/repos/opendatateam/udata/contributors","subscribers_url":"https://api.github.com/repos/opendatateam/udata/subscribers","subscription_url":"https://api.github.com/repos/opendatateam/udata/subscription","commits_url":"https://api.github.com/repos/opendatateam/udata/commits{/sha}","git_commits_url":"https://api.github.com/repos/opendatateam/udata/git/commits{/sha}","comments_url":"https://api.github.com/repos/opendatateam/udata/comments{/number}","issue_comment_url":"https://api.github.com/repos/opendatateam/udata/issues/comments{/number}","contents_url":"https://api.github.com/repos/opendatateam/udata/contents/{+path}","compare_url":"https://api.github.com/repos/opendatateam/udata/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opendatateam/udata/merges","archive_url":"https://api.github.com/repos/opendatateam/udata/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opendatateam/udata/downloads","issues_url":"https://api.github.com/repos/opendatateam/udata/issues{/number}","pulls_url":"https://api.github.com/repos/opendatateam/udata/pulls{/number}","milestones_url":"https://api.github.com/repos/opendatateam/udata/milestones{/number}","notifications_url":"https://api.github.com/repos/opendatateam/udata/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opendatateam/udata/labels{/name}","releases_url":"https://api.github.com/repos/opendatateam/udata/releases{/id}","deployments_url":"https://api.github.com/repos/opendatateam/udata/deployments","created_at":"2014-04-25T09:57:34Z","updated_at":"2016-10-24T18:11:08Z","pushed_at":"2016-10-25T13:36:32Z","git_url":"git://github.com/opendatateam/udata.git","ssh_url":"git@github.com:opendatateam/udata.git","clone_url":"https://github.com/opendatateam/udata.git","svn_url":"https://github.com/opendatateam/udata","homepage":"http://udata.readthedocs.org","size":7918,"stargazers_count":47,"watchers_count":47,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":21,"mirror_url":null,"open_issues_count":61,"forks":21,"open_issues":61,"watchers":47,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/opendatateam/udata/pulls/595"},"html":{"href":"https://github.com/opendatateam/udata/pull/595"},"issue":{"href":"https://api.github.com/repos/opendatateam/udata/issues/595"},"comments":{"href":"https://api.github.com/repos/opendatateam/udata/issues/595/comments"},"review_comments":{"href":"https://api.github.com/repos/opendatateam/udata/pulls/595/comments"},"review_comment":{"href":"https://api.github.com/repos/opendatateam/udata/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/opendatateam/udata/pulls/595/commits"},"statuses":{"href":"https://api.github.com/repos/opendatateam/udata/statuses/3549bf2bd856ec9713a5465a4969cff25958a65f"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"jphnoel","id":7070530,"avatar_url":"https://avatars.githubusercontent.com/u/7070530?v=3","gravatar_id":"","url":"https://api.github.com/users/jphnoel","html_url":"https://github.com/jphnoel","followers_url":"https://api.github.com/users/jphnoel/followers","following_url":"https://api.github.com/users/jphnoel/following{/other_user}","gists_url":"https://api.github.com/users/jphnoel/gists{/gist_id}","starred_url":"https://api.github.com/users/jphnoel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jphnoel/subscriptions","organizations_url":"https://api.github.com/users/jphnoel/orgs","repos_url":"https://api.github.com/users/jphnoel/repos","events_url":"https://api.github.com/users/jphnoel/events{/privacy}","received_events_url":"https://api.github.com/users/jphnoel/received_events","type":"User","site_admin":false},"comments":0,"review_comments":5,"commits":2,"additions":13,"deletions":9,"changed_files":3}}
{"actor":{"display_login":"jphnoel"}}