-
Notifications
You must be signed in to change notification settings - Fork 0
Feature refactor #48
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
Open
StanBarrows
wants to merge
3
commits into
main
Choose a base branch
from
feature-refactor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature refactor #48
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| <?php | ||
|
|
||
| namespace App\Console\Commands; | ||
|
|
||
| use App\Enums\LocaleEnum; | ||
| use App\Models\GithubRepository; | ||
| use Illuminate\Console\Command; | ||
| use Illuminate\Support\Facades\Http; | ||
| use Illuminate\Support\Str; | ||
|
|
||
| class SyncRepositoriesCommand extends Command | ||
| { | ||
| protected $signature = 'sync:repositories'; | ||
|
|
||
| protected $description = 'Sync public GitHub repositories from the codebar-ag organization'; | ||
|
|
||
| private const ORG = 'codebar-ag'; | ||
|
|
||
| private const DEFAULT_IMAGE = 'https://res.cloudinary.com/codebar/image/upload/c_scale,dpr_2.0,f_auto,q_auto,w_1200/www-codebar-ch/seo/seo_codebar.webp'; | ||
|
|
||
| public function handle(): int | ||
| { | ||
| $this->info('Fetching public repositories from GitHub...'); | ||
|
|
||
| $repos = $this->fetchAllRepositories(); | ||
|
|
||
| if ($repos === null) { | ||
| $this->error('Failed to fetch repositories from GitHub.'); | ||
|
|
||
| return self::FAILURE; | ||
| } | ||
|
|
||
| $this->info(sprintf('Found %d public repositories.', count($repos))); | ||
|
|
||
| $synced = 0; | ||
|
|
||
| foreach ($repos as $repo) { | ||
| if ($repo['fork'] ?? false) { | ||
| continue; | ||
| } | ||
|
|
||
| $this->syncRepository($repo); | ||
| $synced++; | ||
| } | ||
|
|
||
| $this->info(sprintf('Synced %d repositories.', $synced)); | ||
|
|
||
| return self::SUCCESS; | ||
| } | ||
|
|
||
| private function fetchAllRepositories(): ?array | ||
| { | ||
| $repos = []; | ||
| $page = 1; | ||
|
|
||
| $headers = []; | ||
| $token = config('services.github.token'); | ||
| if ($token) { | ||
| $headers['Authorization'] = "Bearer {$token}"; | ||
| } | ||
|
|
||
| do { | ||
| $response = Http::withHeaders($headers) | ||
| ->accept('application/vnd.github+json') | ||
| ->get(sprintf('https://api.github.com/orgs/%s/repos', self::ORG), [ | ||
| 'type' => 'public', | ||
| 'per_page' => 100, | ||
| 'page' => $page, | ||
| ]); | ||
|
|
||
| if ($response->failed()) { | ||
| $this->error(sprintf('GitHub API error: %s', $response->body())); | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| $batch = $response->json(); | ||
|
|
||
| if (empty($batch)) { | ||
| break; | ||
| } | ||
|
|
||
| $repos = array_merge($repos, $batch); | ||
| $page++; | ||
| } while (count($batch) === 100); | ||
|
|
||
| return $repos; | ||
| } | ||
|
|
||
| private function syncRepository(array $repo): void | ||
| { | ||
| $slug = Str::slug($repo['name']); | ||
| $title = Str::of($repo['name'])->replace('-', ' ')->title()->toString(); | ||
| $teaser = $repo['description'] ?? ''; | ||
| $topics = $repo['topics'] ?? []; | ||
| $downloads = $this->fetchPackagistDownloads($repo['full_name']); | ||
|
|
||
| foreach (LocaleEnum::cases() as $locale) { | ||
| $entry = GithubRepository::updateOrCreate( | ||
| [ | ||
| 'locale' => $locale->value, | ||
| 'slug' => $slug, | ||
| ], | ||
| [ | ||
| 'published' => true, | ||
| 'title' => $title, | ||
| 'teaser' => $teaser, | ||
| 'image' => self::DEFAULT_IMAGE, | ||
| 'tags' => $topics, | ||
| 'link' => $repo['html_url'], | ||
| 'downloads' => $downloads, | ||
| 'stars' => $repo['stargazers_count'] ?? 0, | ||
| 'forks' => $repo['forks_count'] ?? 0, | ||
| 'primary_language' => $repo['language'], | ||
| 'github_name' => $repo['full_name'], | ||
| ] | ||
| ); | ||
|
|
||
| $this->line(sprintf(' %s [%s] %s downloads', $entry->title, $locale->value, number_format($downloads))); | ||
| } | ||
| } | ||
|
|
||
| private function fetchPackagistDownloads(string $fullName): int | ||
| { | ||
| $response = Http::accept('application/json') | ||
| ->get(sprintf('https://packagist.org/packages/%s.json', $fullName)); | ||
|
|
||
| if ($response->failed()) { | ||
| return 0; | ||
| } | ||
|
|
||
| return (int) data_get($response->json(), 'package.downloads.total', 0); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| <?php | ||
|
|
||
| namespace App\Data; | ||
|
|
||
| use Illuminate\Support\Collection; | ||
|
|
||
| class GkiServiceData | ||
| { | ||
| public static function all(): Collection | ||
| { | ||
| return collect([ | ||
| self::strategy(), | ||
| self::sprint(), | ||
| self::build(), | ||
| ]); | ||
| } | ||
|
|
||
| public static function findBySlug(string $slug): ?array | ||
| { | ||
| return self::all()->firstWhere('slug', $slug); | ||
| } | ||
|
|
||
| private static function strategy(): array | ||
| { | ||
| return [ | ||
| 'slug' => 'gki-strategy', | ||
| 'name' => 'GKI Strategy', | ||
| 'teaser' => 'Strategische Einordnung von KI im Unternehmen.', | ||
| 'features' => [ | ||
| 'KI-Readiness Assessment', | ||
| 'Identifikation priorisierter Use Cases', | ||
| 'Business Case & Wertschöpfungslogik', | ||
| 'Governance- und Compliance-Rahmen', | ||
| 'Roadmap (6–12 Monate)', | ||
| ], | ||
| 'closing' => null, | ||
| 'audience' => 'Ideal für Geschäftsleitungen, Innovationsverantwortliche und Hochschulen.', | ||
| ]; | ||
| } | ||
|
|
||
| private static function sprint(): array | ||
| { | ||
| return [ | ||
| 'slug' => 'gki-sprint', | ||
| 'name' => 'GKI Sprint', | ||
| 'teaser' => 'Vom Problem zum funktionierenden Prototyp in 2–5 Tagen.', | ||
| 'features' => [ | ||
| 'Use-Case-Schärfung', | ||
| 'Prompt-Architektur', | ||
| 'MVP-Entwicklung (z.B. interner Copilot, Wissensagent, Automationslösung)', | ||
| 'Nutzer-Test', | ||
| 'Skalierungsentscheidung', | ||
| ], | ||
| 'closing' => 'Kein PowerPoint. Nur funktionierende Systeme.', | ||
| 'audience' => null, | ||
| ]; | ||
| } | ||
|
|
||
| private static function build(): array | ||
| { | ||
| return [ | ||
| 'slug' => 'gki-build', | ||
| 'name' => 'GKI Build', | ||
| 'teaser' => 'Technische Integration in bestehende Systeme.', | ||
| 'features' => [ | ||
| 'API-Integration', | ||
| 'CRM- / ERP-Anbindung', | ||
| 'Interne Wissens-GPTs', | ||
| 'Automatisierungsstrecken', | ||
| 'Dokumentation & Betriebskonzept', | ||
| ], | ||
| 'closing' => 'Wir bauen Lösungen, die produktiv laufen – nicht Demo-Umgebungen.', | ||
| 'audience' => null, | ||
| ]; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,7 +4,11 @@ | |||||
|
|
||||||
| enum ContactSectionEnum: string | ||||||
| { | ||||||
| const string EMPLOYEES = 'employees'; | ||||||
| const string SOFTWARE_ENGINERING = 'software_engineering'; | ||||||
|
||||||
| const string SOFTWARE_ENGINERING = 'software_engineering'; | |
| const string SOFTWARE_ENGINEERING = 'software_engineering'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?php | ||
|
|
||
| namespace App\Http\Controllers\Ai; | ||
|
|
||
| use App\Actions\PageAction; | ||
| use App\Data\GkiServiceData; | ||
| use App\Http\Controllers\Controller; | ||
| use Illuminate\View\View; | ||
|
|
||
| class AiIndexController extends Controller | ||
| { | ||
| public function __invoke(): View | ||
| { | ||
| return view('app.ai.index')->with([ | ||
| 'page' => (new PageAction(locale: null, routeName: 'ai.index'))->default(), | ||
| 'services' => GkiServiceData::all(), | ||
| ]); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
|
|
||
| namespace App\Http\Controllers\Ai; | ||
|
|
||
| use App\Actions\PageAction; | ||
| use App\Data\GkiServiceData; | ||
| use App\Http\Controllers\Controller; | ||
| use Illuminate\View\View; | ||
|
|
||
| class AiShowController extends Controller | ||
| { | ||
| public function __invoke(string $slug): View | ||
| { | ||
| $service = GkiServiceData::findBySlug($slug); | ||
|
|
||
| abort_unless((bool) $service, 404); | ||
|
|
||
| return view('app.ai.show')->with([ | ||
| 'page' => (new PageAction(locale: null, routeName: 'ai.index'))->default(), | ||
| 'service' => $service, | ||
| ]); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The same typo "ENGINERING" appears here and should be "ENGINEERING" to match the corrected enum constant name.