{"action":"created","issue":{"url":"https://api.github.com/repos/votinginfoproject/data-processor/issues/198","repository_url":"https://api.github.com/repos/votinginfoproject/data-processor","labels_url":"https://api.github.com/repos/votinginfoproject/data-processor/issues/198/labels{/name}","comments_url":"https://api.github.com/repos/votinginfoproject/data-processor/issues/198/comments","events_url":"https://api.github.com/repos/votinginfoproject/data-processor/issues/198/events","html_url":"https://github.com/votinginfoproject/data-processor/pull/198","id":161259641,"number":198,"title":"Write 5.1 XML from CSV imports","user":{"login":"tie-rack","id":3526,"avatar_url":"https://avatars.githubusercontent.com/u/3526?v=3","gravatar_id":"","url":"https://api.github.com/users/tie-rack","html_url":"https://github.com/tie-rack","followers_url":"https://api.github.com/users/tie-rack/followers","following_url":"https://api.github.com/users/tie-rack/following{/other_user}","gists_url":"https://api.github.com/users/tie-rack/gists{/gist_id}","starred_url":"https://api.github.com/users/tie-rack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tie-rack/subscriptions","organizations_url":"https://api.github.com/users/tie-rack/orgs","repos_url":"https://api.github.com/users/tie-rack/repos","events_url":"https://api.github.com/users/tie-rack/events{/privacy}","received_events_url":"https://api.github.com/users/tie-rack/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"cap10morgan","id":59748,"avatar_url":"https://avatars.githubusercontent.com/u/59748?v=3","gravatar_id":"","url":"https://api.github.com/users/cap10morgan","html_url":"https://github.com/cap10morgan","followers_url":"https://api.github.com/users/cap10morgan/followers","following_url":"https://api.github.com/users/cap10morgan/following{/other_user}","gists_url":"https://api.github.com/users/cap10morgan/gists{/gist_id}","starred_url":"https://api.github.com/users/cap10morgan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cap10morgan/subscriptions","organizations_url":"https://api.github.com/users/cap10morgan/orgs","repos_url":"https://api.github.com/users/cap10morgan/repos","events_url":"https://api.github.com/users/cap10morgan/events{/privacy}","received_events_url":"https://api.github.com/users/cap10morgan/received_events","type":"User","site_admin":false},"milestone":null,"comments":5,"created_at":"2016-06-20T18:17:04Z","updated_at":"2016-06-22T18:39:28Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/votinginfoproject/data-processor/pulls/198","html_url":"https://github.com/votinginfoproject/data-processor/pull/198","diff_url":"https://github.com/votinginfoproject/data-processor/pull/198.diff","patch_url":"https://github.com/votinginfoproject/data-processor/pull/198.patch"},"body":"Now that 5.1 imports are translated into a tree that represents the resulting XML document, we can actually write that XML to a file.\r\n\r\nThe approach is essentially:\r\n\r\n1. Pull the `xml_tree_values` rows out of the database in insert order.\r\n2. Read through them, one by one, writing a fragment of XML for each row, closing and opening tags as necessary between rows.\r\n\r\nBy inserting the `xml_tree_values` rows in the order that the `write-xml` function needs them, we're able to avoid costly and complex ordering logic. A migration was added to include an auto-incrementing column (`SERIAL` Postgres type) which we `ORDER BY` when pulling the rows. To that end, rows for InternationalizedText elements needed their order swapped (attribute first, then data). Otherwise, we were already inserting in order!\r\n\r\nThe `write-xml` function is pretty stateful and procedural... but it's reading from a database and writing to a file. That's going to be stateful and procedural. Fortunately, it's not too long.\r\n\r\nPivotal stories: [120708367](https://www.pivotaltracker.com/story/show/120708367) and [121595323](https://www.pivotaltracker.com/story/show/121595323)"},"comment":{"url":"https://api.github.com/repos/votinginfoproject/data-processor/issues/comments/227838140","html_url":"https://github.com/votinginfoproject/data-processor/pull/198#issuecomment-227838140","issue_url":"https://api.github.com/repos/votinginfoproject/data-processor/issues/198","id":227838140,"user":{"login":"cap10morgan","id":59748,"avatar_url":"https://avatars.githubusercontent.com/u/59748?v=3","gravatar_id":"","url":"https://api.github.com/users/cap10morgan","html_url":"https://github.com/cap10morgan","followers_url":"https://api.github.com/users/cap10morgan/followers","following_url":"https://api.github.com/users/cap10morgan/following{/other_user}","gists_url":"https://api.github.com/users/cap10morgan/gists{/gist_id}","starred_url":"https://api.github.com/users/cap10morgan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cap10morgan/subscriptions","organizations_url":"https://api.github.com/users/cap10morgan/orgs","repos_url":"https://api.github.com/users/cap10morgan/repos","events_url":"https://api.github.com/users/cap10morgan/events{/privacy}","received_events_url":"https://api.github.com/users/cap10morgan/received_events","type":"User","site_admin":false},"created_at":"2016-06-22T18:39:28Z","updated_at":"2016-06-22T18:39:28Z","body":"Still LGTM"}}
{"actor":{"display_login":"cap10morgan"}}