Remove some debug output

This commit is contained in:
Mark Veidemanis 2022-02-13 22:18:19 +00:00
parent cd10deaa71
commit b3e71f84d1
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
2 changed files with 18 additions and 18 deletions

View File

@ -319,7 +319,7 @@ class Agora(object):
date_parsed = datetime.strptime(date, "%Y-%m-%dT%H:%M:%S.%fZ") date_parsed = datetime.strptime(date, "%Y-%m-%dT%H:%M:%S.%fZ")
now = datetime.now() now = datetime.now()
sec_ago_date = (now - date_parsed).total_seconds() sec_ago_date = (now - date_parsed).total_seconds()
self.log.debug("Seconds ago date for {date} ^ {now}: {x}", date=date, now=str(now), x=sec_ago_date) # self.log.debug("Seconds ago date for {date} ^ {now}: {x}", date=date, now=str(now), x=sec_ago_date)
return sec_ago_date < 172800 return sec_ago_date < 172800
@handle_exceptions @handle_exceptions
@ -458,7 +458,7 @@ class Agora(object):
try: try:
rates[cg_asset_name][currency.lower()] rates[cg_asset_name][currency.lower()]
except KeyError: except KeyError:
self.log.error("Error getting public ads for currency {currency}", currency=currency) # self.log.error("Error getting public ads for currency {currency}", currency=currency)
continue continue
ads_list = self.enum_public_ads(asset, currency, providers) ads_list = self.enum_public_ads(asset, currency, providers)
if not ads_list: if not ads_list:
@ -495,7 +495,7 @@ class Agora(object):
if rtrn["success"]: if rtrn["success"]:
ads[ad_index][4] = True ads[ad_index][4] = True
throttled = 0 throttled = 0
self.log.info("Successfully updated ad: {id}", id=ad_id) # self.log.info("Successfully updated ad: {id}", id=ad_id)
continue continue
else: else:
if rtrn["response"]["error"]["error_code"] == 429: if rtrn["response"]["error"]["error_code"] == 429:

View File

@ -93,54 +93,54 @@ class Markets(object):
:return: the rate we should use for this currency :return: the rate we should use for this currency
:rtype: float :rtype: float
""" """
self.log.debug("Autoprice starting for {x}", x=currency) # self.log.debug("Autoprice starting for {x}", x=currency)
# Find cheapest ad # Find cheapest ad
# Filter by 3rd index on each ad list to find the cheapest # Filter by 3rd index on each ad list to find the cheapest
min_margin_ad = min(ads, key=lambda x: x[6]) min_margin_ad = min(ads, key=lambda x: x[6])
self.log.debug("Minimum margin ad: {x}", x=min_margin_ad) # self.log.debug("Minimum margin ad: {x}", x=min_margin_ad)
# Find second cheapest that is not us # Find second cheapest that is not us
# Remove results from ads that are us # Remove results from ads that are us
ads_without_us = [ad for ad in ads if not ad[1] == settings.Agora.Username] ads_without_us = [ad for ad in ads if not ad[1] == settings.Agora.Username]
self.log.debug("Ads without us: {x}", x=ads_without_us) # self.log.debug("Ads without us: {x}", x=ads_without_us)
# Find ads above our min that are not us # Find ads above our min that are not us
ads_above_our_min_not_us = [ad for ad in ads_without_us if ad[6] > float(settings.Agora.MinMargin)] ads_above_our_min_not_us = [ad for ad in ads_without_us if ad[6] > float(settings.Agora.MinMargin)]
self.log.debug("Ads above our min not us: {x}", x=ads_above_our_min_not_us) # self.log.debug("Ads above our min not us: {x}", x=ads_above_our_min_not_us)
# Check that this list without us is not empty # Check that this list without us is not empty
if ads_without_us: if ads_without_us:
# Find the cheapest from these # Find the cheapest from these
min_margin_ad_not_us = min(ads_without_us, key=lambda x: x[6]) min_margin_ad_not_us = min(ads_without_us, key=lambda x: x[6])
self.log.debug("Min margin ad not us: {x}", x=min_margin_ad_not_us) # self.log.debug("Min margin ad not us: {x}", x=min_margin_ad_not_us)
# Lowball the lowest ad that is not ours # Lowball the lowest ad that is not ours
lowball_lowest_not_ours = min_margin_ad_not_us[6] # - 0.005 lowball_lowest_not_ours = min_margin_ad_not_us[6] # - 0.005
self.log.debug("Lowball lowest not ours: {x}", x=lowball_lowest_not_ours) # self.log.debug("Lowball lowest not ours: {x}", x=lowball_lowest_not_ours)
# Check if the username field of the cheapest ad matches ours # Check if the username field of the cheapest ad matches ours
if min_margin_ad[1] == settings.Agora.Username: if min_margin_ad[1] == settings.Agora.Username:
self.log.debug("We are the cheapest for: {x}", x=currency) # self.log.debug("We are the cheapest for: {x}", x=currency)
# We are the cheapest! # We are the cheapest!
# Are all of the ads ours? # Are all of the ads ours?
all_ads_ours = all([ad[1] == settings.Agora.Username for ad in ads]) all_ads_ours = all([ad[1] == settings.Agora.Username for ad in ads])
if all_ads_ours: if all_ads_ours:
self.log.debug("All ads are ours for: {x}", x=currency) # self.log.debug("All ads are ours for: {x}", x=currency)
# Now we know it's safe to return the maximum value # Now we know it's safe to return the maximum value
return float(settings.Agora.MaxMargin) return float(settings.Agora.MaxMargin)
else: else:
self.log.debug("All ads are NOT ours for: {x}", x=currency) # self.log.debug("All ads are NOT ours for: {x}", x=currency)
# All the ads are not ours, but we are first... # All the ads are not ours, but we are first...
# Check if the lowballed, lowest (that is not ours) ad's margin # Check if the lowballed, lowest (that is not ours) ad's margin
# is less than our minimum # is less than our minimum
if lowball_lowest_not_ours < float(settings.Agora.MinMargin): if lowball_lowest_not_ours < float(settings.Agora.MinMargin):
self.log.debug("Lowball lowest not ours less than MinMargin") # self.log.debug("Lowball lowest not ours less than MinMargin")
return float(settings.Agora.MinMargin) return float(settings.Agora.MinMargin)
elif lowball_lowest_not_ours > float(settings.Agora.MaxMargin): elif lowball_lowest_not_ours > float(settings.Agora.MaxMargin):
self.log.debug("Lowball lowest not ours more than MaxMargin") # self.log.debug("Lowball lowest not ours more than MaxMargin")
return float(settings.Agora.MaxMargin) return float(settings.Agora.MaxMargin)
else: else:
self.log.debug("Returning lowballed figure: {x}", x=lowball_lowest_not_ours) # self.log.debug("Returning lowballed figure: {x}", x=lowball_lowest_not_ours)
return lowball_lowest_not_ours return lowball_lowest_not_ours
else: else:
self.log.debug("We are NOT the cheapest for: {x}", x=currency) # self.log.debug("We are NOT the cheapest for: {x}", x=currency)
# We are not the cheapest :( # We are not the cheapest :(
# Check if this list is empty # Check if this list is empty
if not ads_above_our_min_not_us: if not ads_above_our_min_not_us:
@ -150,7 +150,7 @@ class Markets(object):
cheapest_ad = min(ads_above_our_min_not_us, key=lambda x: x[4]) cheapest_ad = min(ads_above_our_min_not_us, key=lambda x: x[4])
cheapest_ad_margin = cheapest_ad[6] # - 0.005 cheapest_ad_margin = cheapest_ad[6] # - 0.005
if cheapest_ad_margin > float(settings.Agora.MaxMargin): if cheapest_ad_margin > float(settings.Agora.MaxMargin):
self.log.debug("Cheapest ad not ours more than MaxMargin") # self.log.debug("Cheapest ad not ours more than MaxMargin")
return float(settings.Agora.MaxMargin) return float(settings.Agora.MaxMargin)
self.log.debug("Cheapest ad above our min that is not us: {x}", x=cheapest_ad) # self.log.debug("Cheapest ad above our min that is not us: {x}", x=cheapest_ad)
return cheapest_ad_margin return cheapest_ad_margin