Skip to content

Instantly share code, notes, and snippets.

@philipokiokio
Last active August 19, 2023 14:08
Show Gist options
  • Save philipokiokio/62df7226e33d42ac1a0f6f05e1bf89a9 to your computer and use it in GitHub Desktop.
Save philipokiokio/62df7226e33d42ac1a0f6f05e1bf89a9 to your computer and use it in GitHub Desktop.
Fraud Gaming Prevention with Hash Maps
#This Function incoprate cases that could exist with regards to storing and retrieving the data in a Hash Map /Dictionary
def gaming_refree(camp_data:Camp, link_code:str,gaming_data:dict):
url:str = ""
if len(gaming_data) > 0:
# There is camp data in the cookie so we check if this campaign is in the data store
for _, value in dict(camp_data.payload).items():
if type(value) == dict and value["code"] == link_code:
# when the camp data is not in the cookie
if gaming_data.get(camp_data.slug) is None:
camp_data.payload[_]["count"] += 1
gaming_data[camp_data.slug] = {_: camp_data.payload[_]["url"]}
url = value["url"]
else:
# The camp_data slug is stored in the cookie but the url of interest is not
if gaming_data[
_data.slug].get(_) is None:
camp_data[_]["count"] += 1
gaming_data[camp_data.slug][_] = camp_data.payload[_][
"url"
]
url = value["url"]
else:
# The camp_data is in the cookie and the Link is stored in the cookie
url = gaming_data[camp_data.slug].get(_)
else:
# There is no data in the cookie data store, add the camp_data and the
for _, value in dict(camp_data.payload).items():
if type(value) == dict and value["code"] == link_code:
new_payload[_]["count"] += 1
gaming_data[camp_data.slug] = {_: camp_data.payload[_]["url"]}
url = value["url"]
return url, gaming_data, camp_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment