Skip to content

Commit

Permalink
refactor: streamline DynamoDB table initialization in fare calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
LokoMoloko98 committed Jan 21, 2025
1 parent 3b59196 commit 11b5399
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions swift-lift-fare-calculation/swift-lift-fare-calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
print("Packages have imported successfully")

# Initialize DynamoDB
client = boto3.client('dynamodb')
dynamodb = boto3.resource('dynamodb')
trips_table_name = "Swift-lift-club-portal-trips"
trips_table = dynamodb.Table(trips_table_name)

# DynamoDB table name
TRIPS_TABLE = "Swift-lift-club-portal-trips"

def lambda_handler(event, context):
body = {}
Expand All @@ -28,7 +29,6 @@ def lambda_handler(event, context):
raise ValueError("passenger_id and total_trips must be provided")

# Fetch missed trips for the passenger
trips_table = dynamodb.Table(TRIPS_TABLE)
response = trips_table.get_item(Key={"passenger_id": passenger_id})
if 'Item' not in response:
raise ValueError("Passenger data not found")
Expand Down

0 comments on commit 11b5399

Please sign in to comment.