Skip to content

Commit

Permalink
Merge pull request #53 from HumanDynamics/fix/get-meeting
Browse files Browse the repository at this point in the history
Support both data log version 2.0 and 2.1
  • Loading branch information
OrenLederman authored Dec 12, 2018
2 parents 5f3d815 + 8d08da2 commit 9bfdc87
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion openbadge-server/openbadge/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,15 +468,24 @@ def get_meta(self):

meta["members"] = []

log_version = meta["data"]["log_version"]
# seek to beginning in case it was written out of order
f.seek(0)
# the following few lines should be members joining
line = simplejson.loads(f.readline())
while "received" not in line["type"] and "ended" not in line["type"]:
# make sure we're getting a member change event
# ANYTHING IS POSSIBLE
if "member" in line["type"] and line["data"]["change"] == "join":
if log_version == "2.0" and line["type"] == "member changed" and line["data"]["change"] == "join":
# in log version 2.0 the type is "member changed"
# and you need to check the `change` property
meta["members"].append(line["data"]["member_key"])
elif log_version == "2.1" and line["type"] == "member joined":
# in log version 2.1 the type is just "member joined"
# and it has no `change` property
# also it uses `key` instead of `member_key`
meta["members"].append(line["data"]["key"])

try:
line = simplejson.loads(f.readline())
if not line: break
Expand Down

0 comments on commit 9bfdc87

Please sign in to comment.