get user id from order
This commit is contained in:
@@ -40,19 +40,19 @@ class LifecycleEvents(str, Enum):
|
||||
"""Lifecycle events related to scheduling actions."""
|
||||
|
||||
# Reminder if the user does not access within 3 days
|
||||
# REMINDER_NO_ACCESS_3_DAYS = 'schedules#reminder_no_access_3_days'
|
||||
# REMINDER_NO_ACCESS_3_DAYS = 'SCHEDULES#REMINDER_NO_ACCESS_3_DAYS'
|
||||
DOES_NOT_ACCESS = 'schedules#does_not_access'
|
||||
|
||||
# When there is no activity 7 days after the first access
|
||||
# NO_ACTIVITY_7_DAYS = 'schedules#no_activity_7_days'
|
||||
# NO_ACTIVITY_7_DAYS = 'SCHEDULES#NO_ACTIVITY_7_DAYS'
|
||||
NO_ACTIVITY = 'schedules#no_activity'
|
||||
|
||||
# Reminder 30 days before the access period expires
|
||||
# ACCESS_PERIOD_REMINDER_30_DAYS = 'schedules#access_period_reminder_30_days'
|
||||
# ACCESS_PERIOD_REMINDER_30_DAYS = 'SCHEDULES#ACCESS_PERIOD_REMINDER_30_DAYS'
|
||||
ACCESS_PERIOD_ENDS = 'schedules#access_period_ends'
|
||||
|
||||
# Reminder for certificate expiration set to 30 days from now
|
||||
CERT_EXPIRATION_REMINDER_30_DAYS = 'schedules#cert_expiration_reminder_30_days'
|
||||
CERT_EXP_REMINDER_30_DAYS = 'SCHEDULES#CERT_EXP_REMINDER_30_DAYS'
|
||||
|
||||
# Archive the course after the certificate expires
|
||||
# SET_AS_ARCHIVE = 'schedules#set_as_archive'
|
||||
|
||||
@@ -54,8 +54,8 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
'id': f'vacancies#{tenant_id}',
|
||||
'sk': f'{order_id}#{uuid4()}',
|
||||
# Post-migration: uncomment the follow lines
|
||||
# 'id': f'slots#org#{tenant_id}',
|
||||
# 'sk': f'order#{order_id}#enrollment#{uuid4()}',
|
||||
# 'id': f'SLOT#ORG#{tenant_id}',
|
||||
# 'sk': f'ORDER#{order_id}#ENROLLMENT#{uuid4()}',
|
||||
'course': asdict(slot),
|
||||
'created_at': now_,
|
||||
},
|
||||
@@ -80,6 +80,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
class Course:
|
||||
id: str
|
||||
name: str
|
||||
# Post-migration: remove the following line
|
||||
time_in_days: int
|
||||
|
||||
|
||||
@@ -93,6 +94,7 @@ def _get_courses(ids: set) -> tuple[Course, ...]:
|
||||
Course(
|
||||
id=idx,
|
||||
name=obj['name'],
|
||||
# Post-migration: remove the following line
|
||||
time_in_days=int(obj['access_period']),
|
||||
)
|
||||
for idx, obj in result.items()
|
||||
|
||||
@@ -6,7 +6,6 @@ from aws_lambda_powertools.utilities.data_classes import (
|
||||
event_source,
|
||||
)
|
||||
from aws_lambda_powertools.utilities.typing import LambdaContext
|
||||
from glom import glom
|
||||
from layercake.dateutils import now
|
||||
from layercake.dynamodb import (
|
||||
DynamoDBPersistenceLayer,
|
||||
@@ -44,12 +43,9 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> list[str]
|
||||
if item['unit_price'] > 0
|
||||
}
|
||||
|
||||
result = order_layer.collection.query(KeyPair(order_id, 'assignees#'))
|
||||
user_id = glom(result, 'items.0.sk').removeprefix('assignees#')
|
||||
|
||||
courses = _get_courses(set(items.keys()))
|
||||
user = User(
|
||||
id=user_id,
|
||||
id=order['user_id'],
|
||||
name=order['name'],
|
||||
email=order['email'],
|
||||
cpf=order['cpf'],
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
from uuid import uuid4
|
||||
|
||||
import jsonlines
|
||||
import pytest
|
||||
|
||||
PYTEST_TABLE_NAME = 'pytest'
|
||||
PYTEST_TABLE_NAME = f'pytest-{uuid4()}'
|
||||
PK = 'id'
|
||||
SK = 'sk'
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import app.events.stopgap.enroll as app
|
||||
import app.events.stopgap.patch_enroll as app
|
||||
from aws_lambda_powertools.utilities.typing import LambdaContext
|
||||
from layercake.dynamodb import (
|
||||
DynamoDBPersistenceLayer,
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
{"id": {"S": "6a403773-aeac-4e6a-ac39-dc958e4be52a"},"sk": {"S": "0"},"access_period": {"N": "360"},"cert": {"M": {"exp_interval": {"N": "360"}}},"created_at": {"S": "2025-07-14T15:09:18.559528-03:00"},"metadata__konviva_class_id": {"N": "281"},"name": {"S": "Reciclagem em NR-11 - Operador de Empilhadeira"},"tenant_id": {"S": "*"}}
|
||||
{"id": {"S": "123"},"sk": {"S": "0"},"access_period": {"N": "360"},"cert": {"M": {"exp_interval": {"N": "360"}}},"created_at": {"S": "2025-07-14T15:09:18.559528-03:00"},"metadata__konviva_class_id": {"N": "281"},"name": {"S": "pytest"},"tenant_id": {"S": "*"}}
|
||||
{"id": {"S": "5OxmMjL-ujoR5IMGegQz"},"sk": {"S": "konviva"},"created_at": {"S": "2025-07-11T13:52:35.521154-03:00"},"konvivaId": {"N": "26943"}}
|
||||
{"id": {"S": "cpYSbBcie2NDbZhDKCxCih"}, "sk": {"S": "0"},"cpf": {"S": "02713421535"},"create_date": {"S": "2025-07-21T16:19:43.297712-03:00"},"due_date": {"S": "2025-07-22T16:13:41.056000-03:00"},"email": {"S": "sergio@somosbeta.com.br"},"name": {"S": "Sérgio Rafael Siqueira"},"payment_date": {"S": "2025-07-21T16:21:47.161889-03:00"},"payment_method": {"S": "PIX"},"phone_number": {"S": "+5574998189595"},"status": {"S": "PAID"},"total": {"N": "99"},"update_date": {"S": "2025-07-21T16:21:47.161889-03:00"}}
|
||||
{"id": {"S": "cpYSbBcie2NDbZhDKCxCih"}, "sk": {"S": "assignees#5OxmMjL-ujoR5IMGegQz"},"create_date": {"S": "2025-07-21T16:20:43.631344-03:00"},"scope": {"S": "USER"}}
|
||||
{"id": {"S": "cpYSbBcie2NDbZhDKCxCih"}, "sk": {"S": "0"},"cpf": {"S": "02713421535"},"create_date": {"S": "2025-07-21T16:19:43.297712-03:00"},"due_date": {"S": "2025-07-22T16:13:41.056000-03:00"},"email": {"S": "sergio@somosbeta.com.br"},"name": {"S": "Sérgio Rafael Siqueira"},"payment_date": {"S": "2025-07-21T16:21:47.161889-03:00"},"payment_method": {"S": "PIX"},"phone_number": {"S": "+5574998189595"},"status": {"S": "PAID"},"total": {"N": "99"},"update_date": {"S": "2025-07-21T16:21:47.161889-03:00"}, "user_id": {"S": "5OxmMjL-ujoR5IMGegQz"}}
|
||||
{"id": {"S": "cpYSbBcie2NDbZhDKCxCih"}, "sk": {"S": "items"},"items": {"L": [{"M": {"id": {"S": "6a403773-aeac-4e6a-ac39-dc958e4be52a"},"name": {"S": "Reciclagem em NR-11 - Operador de Empilhadeira"},"quantity": {"N": "1"},"unit_price": {"N": "99"}}}]}}
|
||||
{"id": {"S": "cpYSbBcie2NDbZhDKCxCih"}, "sk": {"S": "generated_items"},"create_date": {"S": "2025-07-21T16:21:50.143551-03:00"},"scope": {"S": "SINGLE_USER"},"status": {"S": "SUCCESS"},"update_date": {"S": "2025-07-21T16:21:53.994941-03:00"}}
|
||||
Reference in New Issue
Block a user