mysociety / popit

DEPRECATED - Development on PopIt has stopped and it is no longer being maintained
https://goo.gl/Vvej4Q
Other
76 stars 33 forks source link

adding an identifier in the PopIt web interface removes post_id from memberships #728

Closed mhl closed 9 years ago

mhl commented 9 years ago

This can be reproduced on the staging server at the moment. For example, if there was a person as follows:

{
  "result": {
    "id": "566",
    "birth_date": "1966-10-09",
    "email": "david.cameron@conservatives.com",
    "gender": "male",
    "html_url": "http://yournextmp-staging.popit.staging.mysociety.org/persons/566",
    "name": "David Cameron",
    "party_memberships": {
      "2010": {
        "id": "party:52",
        "name": "Conservative Party"
      }
    },
    "standing_in": {
      "2010": {
        "mapit_url": "http://mapit.mysociety.org/area/65622",
        "name": "Witney",
        "post_id": "65622"
      }
    },
    "url": "http://yournextmp-staging.popit.staging.mysociety.org/api/v0.1/persons/566",
    "versions": [
      {
        "version_id": "5bf3beee9a537440",
        "timestamp": "2014-11-21T18:10:06.022786",
        "information_source": "Imported from YourNextMP data from 2010",
        "data": {
          "wikipedia_url": null,
          "twitter_username": null,
          "standing_in": {
            "2010": {
              "post_id": "65622",
              "name": "Witney",
              "mapit_url": "http://mapit.mysociety.org/area/65622"
            }
          },
          "slug": "david-cameron",
          "phone": "01993 702 302",
          "party_ppc_page_url": null,
          "party_memberships": {
            "2010": {
              "name": "Conservative Party",
              "id": "party:52"
            }
          },
          "name": "David Cameron",
          "identifiers": [
            {
              "scheme": "yournextmp-candidate",
              "identifier": "4203"
            }
          ],
          "id": "566",
          "homepage_url": null,
          "gender": "male",
          "facebook_personal_url": null,
          "facebook_page_url": null,
          "email": "david.cameron@conservatives.com",
          "birth_date": "1966-10-09"
        }
      }
    ],
    "memberships": [
      {
        "id": "546f7ffed484cf5c585094c6",
        "end_date": "2010-05-06",
        "html_url": "http://yournextmp-staging.popit.staging.mysociety.org/memberships/546f7ffed484cf5c585094c6",
        "organization_id": "party:52",
        "person_id": "566",
        "start_date": "2005-05-06",
        "url": "http://yournextmp-staging.popit.staging.mysociety.org/api/v0.1/memberships/546f7ffed484cf5c585094c6",
        "links": [],
        "contact_details": []
      },
      {
        "id": "546f7ffed484cf5c585094c7",
        "end_date": "2010-05-06",
        "html_url": "http://yournextmp-staging.popit.staging.mysociety.org/memberships/546f7ffed484cf5c585094c7",
        "person_id": "566",
        "post_id": "65622",
        "role": "Candidate",
        "start_date": "2005-05-06",
        "url": "http://yournextmp-staging.popit.staging.mysociety.org/api/v0.1/memberships/546f7ffed484cf5c585094c7",
        "links": [],
        "contact_details": []
      }
    ],
    "links": [],
    "contact_details": [],
    "identifiers": [
      {
        "id": "547787c3737edc5252ce5f83",
        "identifier": "4203",
        "scheme": "yournextmp-candidate"
      }
    ],
    "other_names": []
  }
}

... and after adding an identifier:

{
  "result": {
    "id": "566",
    "birth_date": "1966-10-09",
    "email": "david.cameron@conservatives.com",
    "gender": "male",
    "html_url": "http://yournextmp-staging.popit.staging.mysociety.org/persons/566",
    "name": "David Cameron",
    "party_memberships": {
      "2010": {
        "id": "party:52",
        "name": "Conservative Party"
      }
    },
    "standing_in": {
      "2010": {
        "mapit_url": "http://mapit.mysociety.org/area/65622",
        "name": "Witney",
        "post_id": "65622"
      }
    },
    "url": "http://yournextmp-staging.popit.staging.mysociety.org/api/v0.1/persons/566",
    "versions": [
      {
        "version_id": "5bf3beee9a537440",
        "timestamp": "2014-11-21T18:10:06.022786",
        "information_source": "Imported from YourNextMP data from 2010",
        "data": {
          "wikipedia_url": null,
          "twitter_username": null,
          "standing_in": {
            "2010": {
              "post_id": "65622",
              "name": "Witney",
              "mapit_url": "http://mapit.mysociety.org/area/65622"
            }
          },
          "slug": "david-cameron",
          "phone": "01993 702 302",
          "party_ppc_page_url": null,
          "party_memberships": {
            "2010": {
              "name": "Conservative Party",
              "id": "party:52"
            }
          },
          "name": "David Cameron",
          "identifiers": [
            {
              "scheme": "yournextmp-candidate",
              "identifier": "4203"
            }
          ],
          "id": "566",
          "homepage_url": null,
          "gender": "male",
          "facebook_personal_url": null,
          "facebook_page_url": null,
          "email": "david.cameron@conservatives.com",
          "birth_date": "1966-10-09"
        }
      }
    ],
    "memberships": [
      {
        "id": "546f7ffed484cf5c585094c6",
        "end_date": "2010-05-06",
        "html_url": "http://yournextmp-staging.popit.staging.mysociety.org/memberships/546f7ffed484cf5c585094c6",
        "organization_id": "party:52",
        "person_id": "566",
        "start_date": "2005-05-06",
        "url": "http://yournextmp-staging.popit.staging.mysociety.org/api/v0.1/memberships/546f7ffed484cf5c585094c6",
        "area": {
          "name": ""
        },
        "role": "",
        "links": [],
        "contact_details": []
      },
      {
        "id": "546f7ffed484cf5c585094c7",
        "end_date": "2010-05-06",
        "html_url": "http://yournextmp-staging.popit.staging.mysociety.org/memberships/546f7ffed484cf5c585094c7",
        "person_id": "566",
        "post_id": "65622",
        "role": "Candidate",
        "start_date": "2005-05-06",
        "url": "http://yournextmp-staging.popit.staging.mysociety.org/api/v0.1/memberships/546f7ffed484cf5c585094c7",
        "area": {
          "name": ""
        },
        "organization_id": "commons",
        "links": [],
        "contact_details": []
      }
    ],
    "links": [],
    "contact_details": [],
    "identifiers": [
      {
        "id": "54c689285a23a00a4eb848bb",
        "identifier": "4203",
        "scheme": "yournextmp-candidate"
      },
      {
        "id": "54c689285a23a00a4eb848ba",
        "identifier": "1234",
        "scheme": "made-up-schema"
      }
    ],
    "other_names": []
  }
}

The diff between those is:

--- cameron-before.json 2015-01-26 18:35:55.268019097 +0000
+++ cameron-after-identifier.json   2015-01-26 18:36:35.548020601 +0000
@@ -70,6 +70,10 @@
         "person_id": "566",
         "start_date": "2005-05-06",
         "url": "http://yournextmp-staging.popit.staging.mysociety.org/api/v0.1/memberships/546f7ffed484cf5c585094c6",
+        "area": {
+          "name": ""
+        },
+        "role": "",
         "links": [],
         "contact_details": []
       },
@@ -82,6 +86,10 @@
         "role": "Candidate",
         "start_date": "2005-05-06",
         "url": "http://yournextmp-staging.popit.staging.mysociety.org/api/v0.1/memberships/546f7ffed484cf5c585094c7",
+        "area": {
+          "name": ""
+        },
+        "organization_id": "commons",
         "links": [],
         "contact_details": []
       }
@@ -90,9 +98,14 @@
     "contact_details": [],
     "identifiers": [
       {
-        "id": "547787c3737edc5252ce5f83",
+        "id": "54c689285a23a00a4eb848bb",
         "identifier": "4203",
         "scheme": "yournextmp-candidate"
+      },
+      {
+        "id": "54c689285a23a00a4eb848ba",
+        "identifier": "1234",
+        "scheme": "made-up-schema"
       }
     ],
     "other_names": []

This should not have caused the "organization_id": "commons" or "area": {"name": ""} to be added to any membership.

(I've also seen, but can't reproduce, an instance where the post_id for a person's membership disappeared, but I can't rule out that that might have been a bug in YourNextMP yet, or it might be due to the same cause as https://github.com/mysociety/popit/issues/729.)