Skip to content

Commit

Permalink
updated pk
Browse files Browse the repository at this point in the history
  • Loading branch information
Jish2 committed Nov 2, 2023
1 parent adf5458 commit c7d8960
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 39 deletions.
17 changes: 9 additions & 8 deletions code/student/user.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import boto3, os

class Student:
uid: int
object_id: str
name: str
email: str
linkedin: str
Expand All @@ -16,7 +16,7 @@ class Student:
work_auth: bool
sponsor: bool

def __init__(self, uid, name, email, linkedin, degree, majors, minors, gpa, year, bio, skills, position, work_auth, sponsor):
def __init__(self, object_id, name, email, linkedin, degree, majors, minors, gpa, year, bio, skills, position, work_auth, sponsor):
self.uid: uid
self.name: name
self.email: email
Expand All @@ -32,20 +32,21 @@ def __init__(self, uid, name, email, linkedin, degree, majors, minors, gpa, year
self.work_auth: work_auth
self.sponsor: sponsor

client = boto3.client('dynamodb', region_name='us-east-2')
client = boto3.client('dynamodb', region_name=os.environ.get('AWS_REGION', 'us-east-2'))

dynamo_table = "infra-resume-book-users"

def get_user(id: int) -> str | None:
response = client.get_item(
TableName=dynamo_table,
Key={
"uin": id
"object_id": id
}
)
print(response["Item"])


def update_user(id: int, body: str) -> str | None:
def update_user(id: str, body: str) -> str | None:
temp = {}
attributes = {"name", "email", "linkedin", "degree", "majors", "minors", "gpa", "year", "bio", "skills", "position", "work_auth", "sponsor"}
for key, value in body.items():
Expand All @@ -60,7 +61,7 @@ def update_user(id: int, body: str) -> str | None:
response = client.update_item(
TableName=dynamo_table,
Key={
'uin': id
'object_id': id
},
UpdateExpression=update_expression,
ExpressionAttributeValues=expression_attribute_values,
Expand Down Expand Up @@ -99,11 +100,11 @@ def update_user(id: int, body: str) -> str | None:
# ':ma': {'BOOL': sponsor},
# }

def register_user(uid, name, email, linkedin, degree, majors, minors, gpa, year, bio, skills, position, work_auth, sponsor):
def register_user(id, name, email, linkedin, degree, majors, minors, gpa, year, bio, skills, position, work_auth, sponsor):
client.put_item(
TableName=dynamo_table,
Item={
"uid": {'N': uid},
"object_id": {'N': id},
"name": {'S': name},
"email": {'S': email},
"linkedin": {'S': linkedin},
Expand Down
31 changes: 0 additions & 31 deletions create_table.py

This file was deleted.

0 comments on commit c7d8960

Please sign in to comment.