Skip to content

Commit

Permalink
Merge pull request #17 from allora-network/clement/fix-token-name-for-db
Browse files Browse the repository at this point in the history
Fix default arg (as called by the updater) for token_name
  • Loading branch information
xmariachi authored Jul 15, 2024
2 parents e3884cd + 3807472 commit a3e5323
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@

TOKEN = os.environ['TOKEN']
TOKEN_CG_ID = os.environ['TOKEN_CG_ID']
TOKEN_NAME = f"{TOKEN}USD"

API_PORT = int(os.environ.get('API_PORT', 5000))
ALLORA_VALIDATOR_API_URL = str(os.environ.get('ALLORA_VALIDATOR_API_URL','http://localhost:1317/emissions/v1/network_loss/'))
app = Flask(__name__)

DATABASE_PATH = os.environ.get('DATABASE_PATH', 'prices.db')
GEN_TEST_DATA = bool(os.environ.get('GEN_TEST_DATA', False))
WORKER_ADDRESS_TEST_1 = str(os.environ.get('WORKER_ADDRESS_TEST_1', "allo1tvh6nv02vq6m4mevsa9wkscw53yxvfn7xt8rud"))

TOKEN_NAME = f"{TOKEN}USD"

HTTP_RESPONSE_CODE_200 = 200
HTTP_RESPONSE_CODE_400 = 400
HTTP_RESPONSE_CODE_404 = 404
HTTP_RESPONSE_CODE_500 = 500

app = Flask(__name__)

# Define retry decorator
@retrying.retry(wait_exponential_multiplier=1000, wait_exponential_max=10000, stop_max_attempt_number=5)
def fetch_prices(url):
Expand All @@ -37,14 +37,15 @@ def check_create_table():
conn = sqlite3.connect(DATABASE_PATH)
cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS prices
(timestamp INTEGER PRIMARY KEY, token TEXT, price REAL)''')
(timestamp INTEGER, token TEXT, price REAL,
PRIMARY KEY (timestamp, token))''')
conn.commit()
conn.close()


@app.route('/update/<token_name>/<token_from>/<token_to>')
@app.route('/update')
def update_price(token_name=TOKEN, token_from=TOKEN_CG_ID, token_to='usd'):
def update_price(token_name=TOKEN_NAME, token_from=TOKEN_CG_ID, token_to='usd'):
# Attempt initializing the token data if not already
try:
init_price_token(token_name, token_from, token_to)
Expand Down

0 comments on commit a3e5323

Please sign in to comment.