Skip to content

Commit

Permalink
Merge pull request #379 from claushaas/dev
Browse files Browse the repository at this point in the history
update user hotmart subscriptions creation
  • Loading branch information
claushaas authored Oct 24, 2024
2 parents c375084 + dda54a7 commit 394b7d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
7 changes: 5 additions & 2 deletions app/services/hotmart.service.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,14 @@ export class HotmartService {
logger.logDebug(`Got response: ${JSON.stringify(response.data)}`);

const {data: {items}} = response;
items.sort((a, b) => new Date(b.purchase.approved_date).getTime() - new Date(a.purchase.approved_date).getTime());
console.log(items);
if (items.length > 1) {
items.sort((a, b) => new Date(b.purchase.approved_date).getTime() - new Date(a.purchase.approved_date).getTime());
}

return {
status: 'SUCCESSFUL',
data: items ? this._mapFormationSubscriptions([items[0]], user) : [],
data: items.length > 0 ? this._mapFormationSubscriptions([items[0]], user) : [],
};
} catch (error) {
logger.logError(`Error getting user formation subscriptions on first try: ${JSON.stringify((error as Record<string, string>).data)}`);
Expand Down
12 changes: 6 additions & 6 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const main = async () => {
{
id: 'db66f261-f832-4f0b-9565-53d8f8422d51',
name: 'Formação em Yoga',
slug: 'formacao-em-yoga',
slug: 'formacao-em-yoga-introducao',
description: 'Curso de formação em Yoga',
thumbnailUrl: 'd9fd2efe-ee41-45d6-25a5-4ec50aad7000',
videoSourceUrl: 'd4d143774ac00547befe64063fc8f7e2',
Expand Down Expand Up @@ -51,7 +51,7 @@ const main = async () => {
connect: [
{slug: 'yoga-para-iniciantes'},
{slug: 'escola-online'},
{slug: 'formacao-em-yoga'},
{slug: 'formacao-em-yoga-introducao'},
],
},
},
Expand All @@ -65,19 +65,19 @@ const main = async () => {
delegateAuthTo: {
connect: [
{slug: 'escola-online'},
{slug: 'formacao-em-yoga'},
{slug: 'formacao-em-yoga-introducao'},
],
},
},
});

await prisma.course.update({
where: {
slug: 'formacao-em-yoga',
slug: 'formacao-em-yoga-introducao',
},
data: {
delegateAuthTo: {
connect: {slug: 'formacao-em-yoga'},
connect: {slug: 'formacao-em-yoga-introducao'},
},
},
});
Expand All @@ -92,7 +92,7 @@ const main = async () => {
isLessonsOrderRandom: false,
courses: {
create: {
courseSlug: 'formacao-em-yoga',
courseSlug: 'formacao-em-yoga-introducao',
isPublished: true,
publicationDate: new Date('2024-03-25 17:30:00'),
order: 1,
Expand Down

0 comments on commit 394b7d1

Please sign in to comment.