Skip to content

Commit

Permalink
Merge pull request #74 from harshraj22/quick_fix
Browse files Browse the repository at this point in the history
Quick fix
  • Loading branch information
harshraj22 authored May 5, 2023
2 parents 5d0356a + 56270e6 commit f9c4fad
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/data_population/populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ class Username(BaseModel):

@app.post('/sync', status_code=200)
def sync(username: Username):
print(f'Syncing {username} to redis')
logger.info(f'Syncing {username} to redis')
user_record = f"""SELECT * FROM subscription_details where username = '{username.username}'"""
print(user_record)
logger.info('User Record:', user_record)
cursor_object.execute(user_record)
result = cursor_object.fetchall()

for username, subscription_tier, request_limit, retention_period in result:
r.set(f'{ALLOWED_PREFIX}-{username}', request_limit)


@app.on_event("startup")
@app.get('/sync_all', status_code=200)
def sync_all():
user_record = """SELECT * FROM subscription_details """
Expand All @@ -51,7 +52,7 @@ def sync_all():
# >>> print(result)
# [('free_user', 'Free', 10, 1), ('basic_user', 'Basic', 100, 15), ('advanced_user', 'Advanced', 1000, 60), ('test', 'Advanced', 1000, 60)]

logger.debug(result)
logger.info(result)

for username, subscription_tier, request_limit, retention_period in result:
r.set(f'{ALLOWED_PREFIX}-{username}', request_limit)
Expand Down

0 comments on commit f9c4fad

Please sign in to comment.