fairvotereform / RankIt

https://rankit.vote
1 stars 2 forks source link

As a poll creator, I can export results to RCVIS via API #116

Closed ggordn3r closed 4 years ago

ggordn3r commented 4 years ago

99 enabled this via CSV download/upload. Now we're looking to take out a step.

Armin, the developer on RCVIS, is willing to integrate directly if we can pipe out the JSON created by the tabulation. It looks something like this: https://github.com/artoonie/rcvis/blob/master/testData/medium-rcvis.json

To coordinate with Armin, email armin.samii@gmail.com

proggeramlug commented 4 years ago

Okay, this is now on rankit.skelpo.com !

It (for now) only outputs the JSON. Waiting for Armin to provide me with an endpoint.

ggordn3r commented 4 years ago

I tried downloading the JSON results from a poll and uploading them to https://www.rcvis.com/upload.html but received the error below:

Cannot parse that JSON file!

Did it come from opavote or the RCVRC universal tabulator? If so, please contact us with the JSON and how you obtained it, and we will try to figure this out together:

Preferred method: Make an issue on Github Issues

Email: team@rcvis.com

Here is the JSON that was generated:

{"config":{"contest":"Which is the better hardware store","date":"52313-12-27","jurisdiction":"","office":"","threshold":2},"results":[{"round":1,"tally":{"Lowes":1,"Home Depot":1},"tallyResults":[{"elected":"Home Depot"}]}]}

Can you confirm the format is correct while we wait for the endpoint? Or just follow up with Armin on this issue via email?

proggeramlug commented 4 years ago

This is now implemented to the point that we are successfully uploading to RCVIS - however, I do not know yet how we get the link to show the visualization. Or can you specify what we want to do with this once uploaded?

ggordn3r commented 4 years ago

Armin's URL provides the expected behavior. I should immediately see my poll results in his visualizations: https://rcvis.com/visualize=results18json-1

Sounds like you're waiting on him to add that to the API.

In the meantime, two errors to be fixed:

1) The button should say "Export Results to RCVIS" and use the icon fa fa-share-alt

2) I'm unable to test the current behavior because I'm getting authorization issues in the Console: image

proggeramlug commented 4 years ago

Okay, Armin delivered what we need and now it should work as expected. :)

ggordn3r commented 4 years ago

Still getting an error in console on some tested polls.

I got this while logged in as an admin, both on a poll I created and one built by another user:

Screenshot (27)

When I logged in as a non-admin user, it failed the first time I clicked, but when I clicked again it opened the visualization in a new tab as expected. Here's the console from that session.

Screenshot (28)

proggeramlug commented 4 years ago

Found one bug and fixed it - I think that might be the one responsible for your problems - try again please.

ggordn3r commented 4 years ago

The polls are now going through, which is great. However, there seem to be some discrepancies between our tabulation and their visualization. See, for example:

4 Rounds on RankIt: https://rankit.skelpo.com/results/OpdLCmLbgPv60lRs9ngq/summary 1 Round on RCVIS: https://www.rcvis.com/v/data-10

5 Rounds on Rankit: https://rankit.skelpo.com/results/rDZnWYOUBh5BbaSUvF1b/summary 2 Rounds on RCVIS: https://www.rcvis.com/v/data-11

Are we passing over round-by-round data? If so, how is this possible? Expected behavior is that the number of rounds (and votes for each candidate in each round) are the same in both places.

proggeramlug commented 4 years ago

there was one bug not showing all rounds, however, there is another problem: What we are doing doesn't seem to fit the visualizer. For example here: https://rankit.skelpo.com/results/OpdLCmLbgPv60lRs9ngq/summary

We have 4 rounds but only one winner (in the first round). So the other rounds are (at least in the database) somewhat empty, no one is eliminated nor is anyone winning. The elimination part we can probably figure out because correct me if I am wrong but someone is always eliminated?

But that's the problem now, can you check what to do best?

ggordn3r commented 4 years ago

Hey Ralph--that's incorrect. You linked to the Final Results (/summary) but we should be piping over all rounds.

If you click "See Results by Round" you'll see that there is no winner in the first round: https://rankit.skelpo.com/results/OpdLCmLbgPv60lRs9ngq/1

Rather, it takes 4 rounds to get to a winner: https://rankit.skelpo.com/results/OpdLCmLbgPv60lRs9ngq/4

Maybe you're looking at the wrong object?

proggeramlug commented 4 years ago

Okay, I think I finally figured this out. The problem here had to do with how we capture results. The PR I just merged today is taking care of this though, so going forward this is fixed.

2 important notes here:

  1. Only polls where a new vote has been submitted (so the results have been recalculated) are going to show effect here.
  2. I tried to keep old polls working but we need TESTING here.
ggordn3r commented 4 years ago

Getting closer. I interpreted your comment as you wanted me to test old polls first, so here's what I found:

When I tested this poll again, I got about:blank in a new tab. Tried twice. https://rankit.skelpo.com/polls/rDZnWYOUBh5BbaSUvF1b

When I tested this poll again, the rounds came through! However, it looks like the vote counts didn't: https://rankit.skelpo.com/polls/OpdLCmLbgPv60lRs9ngq The vote totals for each round in our results are changing with the percentages: https://rankit.skelpo.com/results/OpdLCmLbgPv60lRs9ngq/1 But the vote totals in the RCVIS visualizations stay static every round: https://www.rcvis.com/v/data-17#tabular-candidate-by-round

proggeramlug commented 4 years ago

Hmm, probably an error in the import. We are delivering this here:

{
  "config": {
    "contest": "What movie should we watch on Friday night?",
    "date": "2020-07-29",
    "jurisdiction": "RankIt Export",
    "office": "None given",
    "threshold": "9"
  },
  "results": [
    {
      "round": 1,
      "tally": {
        "Monty Python and the Holy Grail": "1",
        "Wayne's World": "4",
        "Naked Gun": "6",
        "Bill and Ted Excellent Adventure": "2",
        "Spaceballs": "4"
      },
      "tallyResults": [
        {
          "eliminated": "Monty Python and the Holy Grail"
        }
      ]
    },
    {
      "round": 2,
      "tally": {
        "Wayne's World": "4",
        "Naked Gun": "6",
        "Spaceballs": "4",
        "Bill and Ted Excellent Adventure": "3"
      },
      "tallyResults": [
        {
          "eliminated": "Bill and Ted Excellent Adventure"
        }
      ]
    },
    {
      "round": 3,
      "tally": {
        "Wayne's World": "5",
        "Spaceballs": "5",
        "Naked Gun": "7"
      },
      "tallyResults": [
        {
          "eliminated": "Wayne's World"
        }
      ]
    },
    {
      "round": 4,
      "tally": {
        "Spaceballs": "7",
        "Naked Gun": "8"
      },
      "tallyResults": [
        {
          "elected": "Naked Gun",
          "eliminated": "Spaceballs"
        }
      ]
    }
  ]
}

Notice how in round 3 we are defining "7" votes but the chart only shows 6?

ggordn3r commented 4 years ago

Ok, I'll email Armin about it.

ggordn3r commented 4 years ago

Armin got back to us--sounds like his algorithm expects an explicit "transfer" variable. Refer back to his email, I'll let you take it from here.

proggeramlug commented 4 years ago

I think the transfer object works for us - check it out! https://www.rcvis.com/v/data-21

(It's already ready to test)

ggordn3r commented 4 years ago

Both users testing this report that when they click "Export Results to RCVIS, it opens a new tab but goes to about:blank instead of the expected URL on RCVIS:

2020-08-25

proggeramlug commented 4 years ago

That's the dcase if there is a problem - can we get the poll IDs to reproduce?

ggordn3r commented 4 years ago

Here are the two polls reported: https://rankit.skelpo.com/polls/eaub53HYQM70lX5J8az7 https://rankit.skelpo.com/polls/wTmvs5mhEozssqqk3Unh

proggeramlug commented 4 years ago

I've adjusted it so that instead of an empty window there will be a download. This download we can debug then. In these cases I have no idea what the problem is, I'll ask Armin.

proggeramlug commented 4 years ago

Okay, found the problem for those too and fixed it!

ggordn3r commented 4 years ago

Tester reported the following. Looks like something may be wrong with the transfer object during surplus transfers and/or the export currently isn't able to define multiple winners in 1 round.

I retested the export feature using this poll: https://rankit.skelpo.com/results/wTmvs5mhEozssqqk3Unh/summary Here is the URL for the exported data: https://www.rcvis.com/v/data-30

The issues I have experienced with it so far are:

· None of the display options in RCVIS recognize that ‘The Wasted Vote’ is a winner, even though it had the most first-choice votes and passed the victory threshold for a 3 winner poll (screenshot 3). In contrast, Rankit does recognize it as a winner

· It isn’t clear what RCVIS is doing in the second round, since the display looks exactly the same as round 1 (screenshots 1 and 2). In round two on rankit.skelpo.vote, it was doing a surplus reallocation. Maybe RCVIS has a hard time visualizing the surplus reallocation step.

proggeramlug commented 4 years ago

Found the problem and fixed it!

proggeramlug commented 4 years ago

Need to reexport of course

ggordn3r commented 4 years ago

Ok, something odd happened. He gave me this link to retest: https://www.rcvis.com/v/data-39#barchart-interactive

But it's a totally different poll than the one at the same URL in his screenshot below: Round 1

Did something happen that would cause a URL overwrite when you switched to live?

proggeramlug commented 4 years ago

Hmm, that is an issue with the URL structure - I'll tell Armin about it. But we can fix it by giving random names to our files. Try again, we are now giving random names.