Skip to content

Commit

Permalink
Merge pull request #4 from hrsa/develop
Browse files Browse the repository at this point in the history
Release 1.0
  • Loading branch information
hrsa authored May 16, 2024
2 parents a24b8b9 + 578c150 commit 3722826
Show file tree
Hide file tree
Showing 45 changed files with 1,262 additions and 660 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: Test, push and deploy
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]


env:
USER: anton
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
branches: [ "develop", "master" ]

jobs:
build-and-test:
Expand Down
2 changes: 0 additions & 2 deletions app/Http/Controllers/CalendarGeneratorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public function generate(IcsEventRequest $request): JsonResponse

public function guestGenerate(IcsEventRequest $request, UserService $userService)
{
ray('Got a request', request()->all())->orange();

if (User::where('email', $request->email)->exists()) {
return response()->json(['error' => 'You need to verify your account to use Calendize!'], status: Response::HTTP_UNAUTHORIZED);
}
Expand Down
16 changes: 8 additions & 8 deletions app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ public function index(UserService $userService): \Inertia\Response

switch ($payment) {
case 'credits':
$paymentConfirmation['title'] = 'Your payment was successful!';
$paymentConfirmation['content'] = "Thanks! I'm looking forward to working with you!";
$paymentConfirmation['title'] = __('dashboard.popup.credits.title');
$paymentConfirmation['content'] = __('dashboard.popup.credits.content');
break;
case 'beginner':
$paymentConfirmation['title'] = 'beginner';
$paymentConfirmation['content'] = 'Thanks! beginner now!';
$paymentConfirmation['title'] = __('dashboard.popup.beginner.title');
$paymentConfirmation['content'] = __('dashboard.popup.beginner.content');
break;
case 'classic':
$paymentConfirmation['title'] = 'classic';
$paymentConfirmation['content'] = 'Thanks! classic now!';
$paymentConfirmation['title'] = __('dashboard.popup.classic.title');
$paymentConfirmation['content'] = __('dashboard.popup.classic.content');
break;
case 'power':
$paymentConfirmation['title'] = 'power';
$paymentConfirmation['content'] = 'Thanks! power now!';
$paymentConfirmation['title'] = __('dashboard.popup.power.title');
$paymentConfirmation['content'] = __('dashboard.popup.power.content');
break;
}

Expand Down
22 changes: 18 additions & 4 deletions app/Jobs/GenerateCalendarJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,19 @@ public function handle(): void
$this->icsEvent->update(['error' => "I'm sorry, my servers are having hiccups. Please try again in 30-60 minutes!"]);
Log::alert("Mistral error generating IcsEvent #{$this->icsEvent->id}: {$e->getMessage()}");
IcsEventProcessed::dispatch($this->icsEvent);
$this->fail($e);
$this->fail("{$e->getCode()} : {$e->getMessage()}");

return;
}
}

$jsonIcs = $result?->choices[0]->message->content;

if (!$jsonIcs) {
$this->release(300);
$this->icsEvent->update(['error' => "I'm sorry, my servers are having hiccups. Please try again in 30-60 minutes!"]);
Log::alert("Total failure for IcsEvent #{$this->icsEvent->id}");
IcsEventProcessed::dispatch($this->icsEvent);
$this->fail("Total failure for IcsEvent #{$this->icsEvent->id}");
}

$decodedReply = json_decode($jsonIcs, true);
Expand Down Expand Up @@ -96,17 +101,26 @@ private function generateOpenAIResponse(string $systemPrompt): CreateResponse
]);
}

/**
* @throws Exception
*/
private function generateMistralResponse(string $systemPrompt): stdClass
{
$result = Http::mistral()->post('/chat/completions', [
$response = Http::mistral()->timeout(10)->post('/chat/completions', [
'model' => 'mistral-large-latest',
'messages' => [
['role' => 'system', 'content' => $systemPrompt],
['role' => 'user', 'content' => $this->icsEvent->prompt],
],
'max_tokens' => 2800,
'response_format' => ['type' => 'json_object'],
])->json();
]);

if ($response->failed()) {
throw new Exception('Mistral HTTP Error: ' . $response->body(), $response->getStatusCode());
}

$result = $response->json();

return json_decode(json_encode($result));
}
Expand Down
1 change: 0 additions & 1 deletion app/Listeners/OrderRefundedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class OrderRefundedListener
*/
public function handle(OrderRefunded $event): void
{
ray($event);
$lmSqueezyOrder = Order::find($event->order->id);

if ($lmSqueezyOrder?->refunded() && $lmSqueezyOrder->variant_id == config('lemon-squeezy.sales.topup.variant')) {
Expand Down
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 10 additions & 12 deletions database/factories/IcsEventFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,16 @@ public function icsProcessed(): static
$timezone = $this->faker->timezone;
$dateTime = Carbon::create($this->faker->dateTimeThisMonth());

$ics = <<< ICSEVENTDATA
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Calendar//Calendize 2.0//EN
BEGIN:VEVENT
SUMMARY: {$this->faker->words(4, true)}
DTSTART;TZID={$timezone}:{$dateTime}
DTEND;TZID={$timezone}:{$dateTime->addHours($this->faker->numberBetween(1, 3))}
DESCRIPTION:{$this->faker->words(14, true)}
END:VEVENT
END:VCALENDAR
ICSEVENTDATA;
$ics = "BEGIN:VCALENDAR\n" .
"VERSION:2.0\n" .
"PRODID:-//Calendar//Calendize 2.0//EN\n" .
"BEGIN:VEVENT\n" .
"SUMMARY: {$this->faker->words(4, true)}\n" .
"DTSTART;TZID={$timezone}:{$dateTime}\n" .
"DTEND;TZID={$timezone}:{$dateTime->addHours($this->faker->numberBetween(1, 3))}\n" .
"DESCRIPTION:{$this->faker->words(14, true)}\n" .
"END:VEVENT\n" .
'END:VCALENDAR';

return compact('ics');
});
Expand Down
1 change: 1 addition & 0 deletions docker/php-prod.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \

RUN curl -fsSL https://deb.nodesource.com/setup_21.x | bash -
RUN apt-get install -y nodejs
RUN npm install -g [email protected]

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

Expand Down
2 changes: 1 addition & 1 deletion docker/php.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \

RUN curl -fsSL https://deb.nodesource.com/setup_21.x | bash -
RUN apt-get install -y nodejs
RUN npm install -g npm@10.7.0 && npm install -g npm-check-updates
RUN npm install -g npm@10.8.0 && npm install -g npm-check-updates
RUN chown -R ${UID}:${GID} /var/www
RUN chmod 777 -R /var/www
USER ${USER}
Expand Down
22 changes: 22 additions & 0 deletions lang/en/dashboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

return [
'popup' => [
'beginner' => [
'title' => 'Your payment was successful!',
'content' => 'Thanks! Beginner subscription is now active.',
],
'classic' => [
'title' => 'Your payment was successful!',
'content' => 'Thanks! Classic subscription is now active.',
],
'power' => [
'title' => 'Your payment was successful!',
'content' => 'Thanks! Power subscription is now active. We\'ve got a lot to do, right?',
],
'credits' => [
'title' => 'Your payment was successful!',
'content' => "Thanks! I'm looking forward to working with you!",
],
],
];
Loading

0 comments on commit 3722826

Please sign in to comment.