fix author

This commit is contained in:
2025-07-31 15:01:53 -03:00
parent 4b7783964f
commit f5bd1e80d6
2 changed files with 22 additions and 14 deletions

View File

@@ -96,7 +96,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
pass pass
try: try:
author = data['author'] author = data.get('author')
course_id = data['course']['id'] course_id = data['course']['id']
course = course_layer.collection.get_items( course = course_layer.collection.get_items(
KeyPair( KeyPair(
@@ -118,15 +118,21 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
'user': pick(('id', 'name'), data['user']), 'user': pick(('id', 'name'), data['user']),
'course': pick(('id', 'name'), data['course']), 'course': pick(('id', 'name'), data['course']),
'unit_price': course['unit_price'], 'unit_price': course['unit_price'],
'author': {
'id': author['user_id'],
'name': author['name'],
},
# Post-migration: uncomment the following line # Post-migration: uncomment the following line
# 'enrolled_at': data['created_at'], # 'enrolled_at': data['created_at'],
'enrolled_at': data['create_date'], 'enrolled_at': data['create_date'],
'created_at': now_, 'created_at': now_,
}, }
| (
{
'author': {
'id': author['user_id'],
'name': author['name'],
}
}
if author
else {}
),
cond_expr='attribute_not_exists(sk)', cond_expr='attribute_not_exists(sk)',
) )
except Exception as exc: except Exception as exc:

View File

@@ -83,8 +83,8 @@
margin-bottom: 0.625rem; margin-bottom: 0.625rem;
} }
.text-nowrap { .whitespace-nowrap {
text-wrap: nowrap; white-space: nowrap;
} }
</style> </style>
</head> </head>
@@ -177,9 +177,9 @@
<tr> <tr>
<td>Colaborador</td> <td>Colaborador</td>
<td>Curso</td> <td>Curso</td>
<td>Matriculado em</td> <td class="whitespace-nowrap">Matriculado em</td>
<td>Autor</td> <td>Autor</td>
<td>Valor unit.</td> <td class="whitespace-nowrap">Valor unit.</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -187,12 +187,14 @@
<tr> <tr>
<td>{{ x.user.name }}</td> <td>{{ x.user.name }}</td>
<td>{{ x.course.name }}</td> <td>{{ x.course.name }}</td>
<td class="text-nowrap"> <td class="whitespace-nowrap">
{{ x.enrolled_at|datetime_format('%d/%m/%Y, %H:%M') {{ x.enrolled_at|datetime_format('%d/%m/%Y, %H:%M')
}} }}
</td> </td>
<td>{{ x.author.name }}</td> <td>{{ x.author.name if x.author else 'N/A' }}</td>
<td class="text-nowrap">{{ x.unit_price|currency }}</td> <td class="whitespace-nowrap">
{{ x.unit_price|currency }}
</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
@@ -204,7 +206,7 @@
> >
Total Total
</td> </td>
<td> <td class="whitespace-nowrap">
{{ items| {{ items|
map(attribute='unit_price')|map('float')|sum|currency map(attribute='unit_price')|map('float')|sum|currency
}} }}