New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add lambda function for attendance check using dynamodb and s3 #1
Conversation
lambda_dynamodb_trigger.py
Outdated
|
||
#If reaction time is not later than 1hour | ||
if time_diff <= 3600: | ||
response = table.get_item(Key={'user_id': user_id}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response를 가져올때 사용자의 날짜의 출석정보만 가져올수 있나요? 아님 이 response 가 길어질듯 하네요. (예: 일년 출첵이면 300개 이상.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 그렇게 처리하겠습니다!
date = date.strftime('D%Y%m%d') | ||
|
||
#If reaction time is not later than 1hour | ||
if time_diff <= 3600: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이건 cron으로 돈다고 가정하고 하는 것이죠?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아닙니다! connect_up_slack 에 등록되는 순간 이벤트가 발생하는식으로 진행 될 때, 만약에 출석체크 포스팅이 올라간 시점과 학생들이 reaction을 추가한 시점이 너무 차이가 나면, 출석으로 인정을 하지 않기 위해 넣어 놓은 부분입니다! (1시간 이내에 눌러야함!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그런제한은 하드코딩하기 보다 나중에 csv등에서 룰로 처리 하는 것이 좋을듯 합니다.
lambda_dynamodb_trigger.py
Outdated
table.update_item( | ||
Key={ 'user_id': user_id }, | ||
UpdateExpression='SET {} = :val'.format(date), | ||
ExpressionAttributeValues={ ':val': 1 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
실제 출석 시간을 넣어도 좋겠습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네 알겠습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timestamp로 넣으면 가독성이 떨어질 것 같은데, 시간:분:초 만 넣는 식으로 진행을 해볼까요?
일단 머지하고 제가 좀더 테스트 해볼께요. |
일단, 제공해주신 샘플데이터를 활용한 상태로 테스트를 마친 상태입니다!
몇 가지 확인을 못한 점은, DynamoDB Scan말고 Query를 쓰고 싶었는데 인덱스 설정을 변경을 해야하는 것 같아서 일단 Scan으로 event_ts를 찾는 방식으로 처리했습니다.
그리고 현재는 모든 유저를 하나씩 Slack에 요청하는 상태인데, 한번에 여러 유저를 요청 할 수 있는 방법이 있는지는 아직 확인 하지 못했습니다. 그래서 일단은 Lambda 실행 시간을 조금 넉넉히 줘야 할 것 같습니다.