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

Missing location in played game #59

Open
vincelnx opened this issue Aug 8, 2019 · 0 comments
Open

Missing location in played game #59

vincelnx opened this issue Aug 8, 2019 · 0 comments

Comments

@vincelnx
Copy link

vincelnx commented Aug 8, 2019

Hello,
I think, there is a issue when searching a location in a played game session.
The location information is empty when you get a bgg play session

In [54]: t.plays(name=username, min_date=mindate.date())[0].location

In [55]: t.plays(name=username, min_date=mindate.date())[0].players[0].location

In [56]:

The procedure add_play_from_xml seems to search data on the player item.

    player_data = {"username": player.attrib.get("username"),
                       "user_id": int(player.attrib.get("userid", -1)),
                       "name": player.attrib.get("name"),
                       "startposition": player.attrib.get("startposition"),
                       "new": player.attrib.get("new"),
                       "win": player.attrib.get("win"),
                       "rating": player.attrib.get("rating"),
                       "score": player.attrib.get("score"),
                       "color": player.attrib.get("color"),
                       "location": player.attrib.get("location")}

I 've changed the loaders/play.py to avoid this issue.
line 60 : add "location":play.attrib["location"], in the add_play_from_xml procedure

    data = {"id": int(play.attrib["id"]),
            "date": play.attrib["date"],
            "quantity": int(play.attrib["quantity"]),
            "duration": int(play.attrib["length"]),
            "location":play.attrib["location"],
      "incomplete": int(play.attrib["incomplete"]),
            "nowinstats": int(play.attrib["nowinstats"]),
            # for User plays, will be overwritten with the user id when adding the play.
            "user_id": int(play.attrib.get("userid", -1)),
            "game_id": xml_subelement_attr(play, "item", attribute="objectid", convert=int),
            "game_name": xml_subelement_attr(play, "item", attribute="name"),
            "comment": xml_subelement_text(play, "comments"),
            "players": player_list}`

In [8]: t=BGGClient()

In [9]: BGGClient().plays(name=username, min_date=mindate.date())[0]
Out[9]: <boardgamegeek.objects.plays.PlaySession at 0x6c839e8>

In [10]: BGGClient().plays(name=username, min_date=mindate.date())[0].location
Out[10]: 'XXXXXXX'

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

1 participant