From fa01056f51620d311e6145628d594ef113b80247 Mon Sep 17 00:00:00 2001 From: hanif salafi Date: Wed, 1 Oct 2025 21:59:51 +0700 Subject: [PATCH] feat: delete file trash --- add_clientid_extraction.ps1 | 66 --------------- add_clientid_to_remaining.ps1 | 59 -------------- debug_approval_flow.sql | 95 ---------------------- fix_all_article_approval_flows.ps1 | 59 -------------- fix_all_article_approval_flows_final.ps1 | 59 -------------- fix_all_article_approval_flows_final10.ps1 | 59 -------------- fix_all_article_approval_flows_final11.ps1 | 59 -------------- fix_all_article_approval_flows_final12.ps1 | 59 -------------- fix_all_article_approval_flows_final13.ps1 | 59 -------------- fix_all_article_approval_flows_final14.ps1 | 59 -------------- fix_all_article_approval_flows_final15.ps1 | 59 -------------- fix_all_article_approval_flows_final16.ps1 | 59 -------------- fix_all_article_approval_flows_final2.ps1 | 59 -------------- fix_all_article_approval_flows_final3.ps1 | 59 -------------- fix_all_article_approval_flows_final4.ps1 | 59 -------------- fix_all_article_approval_flows_final5.ps1 | 59 -------------- fix_all_article_approval_flows_final6.ps1 | 59 -------------- fix_all_article_approval_flows_final7.ps1 | 59 -------------- fix_all_article_approval_flows_final8.ps1 | 59 -------------- fix_all_article_approval_flows_final9.ps1 | 59 -------------- fix_all_clientid.ps1 | 59 -------------- fix_approval_flow.sql | 85 ------------------- fix_article_approval_flows_clientid.ps1 | 59 -------------- fix_remaining_article_approval_flows.ps1 | 59 -------------- fix_remaining_clientid.ps1 | 61 -------------- replace_clientid_calls.ps1 | 43 ---------- update_service_methods.ps1 | 44 ---------- update_service_methods.sh | 30 ------- 28 files changed, 1663 deletions(-) delete mode 100644 add_clientid_extraction.ps1 delete mode 100644 add_clientid_to_remaining.ps1 delete mode 100644 debug_approval_flow.sql delete mode 100644 fix_all_article_approval_flows.ps1 delete mode 100644 fix_all_article_approval_flows_final.ps1 delete mode 100644 fix_all_article_approval_flows_final10.ps1 delete mode 100644 fix_all_article_approval_flows_final11.ps1 delete mode 100644 fix_all_article_approval_flows_final12.ps1 delete mode 100644 fix_all_article_approval_flows_final13.ps1 delete mode 100644 fix_all_article_approval_flows_final14.ps1 delete mode 100644 fix_all_article_approval_flows_final15.ps1 delete mode 100644 fix_all_article_approval_flows_final16.ps1 delete mode 100644 fix_all_article_approval_flows_final2.ps1 delete mode 100644 fix_all_article_approval_flows_final3.ps1 delete mode 100644 fix_all_article_approval_flows_final4.ps1 delete mode 100644 fix_all_article_approval_flows_final5.ps1 delete mode 100644 fix_all_article_approval_flows_final6.ps1 delete mode 100644 fix_all_article_approval_flows_final7.ps1 delete mode 100644 fix_all_article_approval_flows_final8.ps1 delete mode 100644 fix_all_article_approval_flows_final9.ps1 delete mode 100644 fix_all_clientid.ps1 delete mode 100644 fix_approval_flow.sql delete mode 100644 fix_article_approval_flows_clientid.ps1 delete mode 100644 fix_remaining_article_approval_flows.ps1 delete mode 100644 fix_remaining_clientid.ps1 delete mode 100644 replace_clientid_calls.ps1 delete mode 100644 update_service_methods.ps1 delete mode 100644 update_service_methods.sh diff --git a/add_clientid_extraction.ps1 b/add_clientid_extraction.ps1 deleted file mode 100644 index 60bf285..0000000 --- a/add_clientid_extraction.ps1 +++ /dev/null @@ -1,66 +0,0 @@ -# PowerShell script to add clientId extraction logic to service methods -# Usage: .\add_clientid_extraction.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Adding clientId extraction logic to: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Pattern to find method definitions that need clientId extraction -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\)' - -# Find all method matches -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Processing method: $MethodName" - - # Skip methods that already have clientId extraction logic - if ($Content -match "func \(_i \*${ServiceName}Service\) ${MethodName}\(authToken string, ${Parameters}\) \{[^}]*Extract clientId from authToken") { - Write-Host " Skipping $MethodName - already has clientId extraction" - continue - } - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "ClientId extraction logic added to service methods." diff --git a/add_clientid_to_remaining.ps1 b/add_clientid_to_remaining.ps1 deleted file mode 100644 index 786a194..0000000 --- a/add_clientid_to_remaining.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to add clientId extraction to remaining methods -# Usage: .\add_clientid_to_remaining.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Adding clientId extraction to remaining methods in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Adding clientId extraction to method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "ClientId extraction added to remaining methods." diff --git a/debug_approval_flow.sql b/debug_approval_flow.sql deleted file mode 100644 index a8588fa..0000000 --- a/debug_approval_flow.sql +++ /dev/null @@ -1,95 +0,0 @@ --- Debug script untuk mengecek masalah approval flow - --- 1. Cek user level 5 -SELECT - id, - level_name, - level_number, - is_approval_active, - client_id -FROM user_levels -WHERE id = 5; - --- 2. Cek user dengan level 5 -SELECT - u.id, - u.name, - u.user_level_id, - ul.level_name, - ul.level_number, - ul.is_approval_active -FROM users u -JOIN user_levels ul ON u.user_level_id = ul.id -WHERE u.user_level_id = 5; - --- 3. Cek default workflow -SELECT - id, - name, - is_active, - is_default, - client_id -FROM approval_workflows -WHERE is_default = true -AND is_active = true; - --- 4. Cek workflow steps -SELECT - aws.id, - aws.workflow_id, - aws.step_order, - aws.step_name, - aws.required_user_level_id, - aws.condition_type, - aws.condition_value, - aws.branch_name, - aw.name as workflow_name -FROM approval_workflow_steps aws -JOIN approval_workflows aw ON aws.workflow_id = aw.id -WHERE aw.is_default = true -ORDER BY aws.step_order, aws.branch_order; - --- 5. Cek artikel yang baru dibuat -SELECT - id, - title, - created_by_id, - workflow_id, - current_approval_step, - status_id, - bypass_approval, - approval_exempt, - created_at -FROM articles -WHERE title = 'Test Tni Artikel 1' -ORDER BY created_at DESC; - --- 6. Cek approval flows -SELECT - aaf.id, - aaf.article_id, - aaf.workflow_id, - aaf.current_step, - aaf.current_branch, - aaf.status_id, - aaf.submitted_by_id, - aaf.submitted_at, - a.title as article_title -FROM article_approval_flows aaf -JOIN articles a ON aaf.article_id = a.id -WHERE a.title = 'Test Tni Artikel 1' -ORDER BY aaf.created_at DESC; - --- 7. Cek legacy approval records -SELECT - aa.id, - aa.article_id, - aa.approval_by, - aa.status_id, - aa.message, - aa.approval_at_level, - a.title as article_title -FROM article_approvals aa -JOIN articles a ON aa.article_id = a.id -WHERE a.title = 'Test Tni Artikel 1' -ORDER BY aa.created_at DESC; diff --git a/fix_all_article_approval_flows.ps1 b/fix_all_article_approval_flows.ps1 deleted file mode 100644 index 14a2592..0000000 --- a/fix_all_article_approval_flows.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues in article_approval_flows -# Usage: .\fix_all_article_approval_flows.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All remaining clientId issues fixed." diff --git a/fix_all_article_approval_flows_final.ps1 b/fix_all_article_approval_flows_final.ps1 deleted file mode 100644 index eecc094..0000000 --- a/fix_all_article_approval_flows_final.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues in article_approval_flows -# Usage: .\fix_all_article_approval_flows_final.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All remaining clientId issues fixed." diff --git a/fix_all_article_approval_flows_final10.ps1 b/fix_all_article_approval_flows_final10.ps1 deleted file mode 100644 index a2a8afb..0000000 --- a/fix_all_article_approval_flows_final10.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues in article_approval_flows -# Usage: .\fix_all_article_approval_flows_final10.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All remaining clientId issues fixed." diff --git a/fix_all_article_approval_flows_final11.ps1 b/fix_all_article_approval_flows_final11.ps1 deleted file mode 100644 index f23372c..0000000 --- a/fix_all_article_approval_flows_final11.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues in article_approval_flows -# Usage: .\fix_all_article_approval_flows_final11.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All remaining clientId issues fixed." diff --git a/fix_all_article_approval_flows_final12.ps1 b/fix_all_article_approval_flows_final12.ps1 deleted file mode 100644 index 63760fd..0000000 --- a/fix_all_article_approval_flows_final12.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues in article_approval_flows -# Usage: .\fix_all_article_approval_flows_final12.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All remaining clientId issues fixed." diff --git a/fix_all_article_approval_flows_final13.ps1 b/fix_all_article_approval_flows_final13.ps1 deleted file mode 100644 index 0538491..0000000 --- a/fix_all_article_approval_flows_final13.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues in article_approval_flows -# Usage: .\fix_all_article_approval_flows_final13.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All remaining clientId issues fixed." diff --git a/fix_all_article_approval_flows_final14.ps1 b/fix_all_article_approval_flows_final14.ps1 deleted file mode 100644 index 39e3bc6..0000000 --- a/fix_all_article_approval_flows_final14.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues in article_approval_flows -# Usage: .\fix_all_article_approval_flows_final14.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All remaining clientId issues fixed." diff --git a/fix_all_article_approval_flows_final15.ps1 b/fix_all_article_approval_flows_final15.ps1 deleted file mode 100644 index cfffe99..0000000 --- a/fix_all_article_approval_flows_final15.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues in article_approval_flows -# Usage: .\fix_all_article_approval_flows_final15.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All remaining clientId issues fixed." diff --git a/fix_all_article_approval_flows_final16.ps1 b/fix_all_article_approval_flows_final16.ps1 deleted file mode 100644 index f9426f8..0000000 --- a/fix_all_article_approval_flows_final16.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues in article_approval_flows -# Usage: .\fix_all_article_approval_flows_final16.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All remaining clientId issues fixed." diff --git a/fix_all_article_approval_flows_final2.ps1 b/fix_all_article_approval_flows_final2.ps1 deleted file mode 100644 index 0ad929d..0000000 --- a/fix_all_article_approval_flows_final2.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues in article_approval_flows -# Usage: .\fix_all_article_approval_flows_final2.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All remaining clientId issues fixed." diff --git a/fix_all_article_approval_flows_final3.ps1 b/fix_all_article_approval_flows_final3.ps1 deleted file mode 100644 index 7aa7658..0000000 --- a/fix_all_article_approval_flows_final3.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues in article_approval_flows -# Usage: .\fix_all_article_approval_flows_final3.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All remaining clientId issues fixed." diff --git a/fix_all_article_approval_flows_final4.ps1 b/fix_all_article_approval_flows_final4.ps1 deleted file mode 100644 index 6f5cba4..0000000 --- a/fix_all_article_approval_flows_final4.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues in article_approval_flows -# Usage: .\fix_all_article_approval_flows_final4.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All remaining clientId issues fixed." diff --git a/fix_all_article_approval_flows_final5.ps1 b/fix_all_article_approval_flows_final5.ps1 deleted file mode 100644 index 4ff6969..0000000 --- a/fix_all_article_approval_flows_final5.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues in article_approval_flows -# Usage: .\fix_all_article_approval_flows_final5.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All remaining clientId issues fixed." diff --git a/fix_all_article_approval_flows_final6.ps1 b/fix_all_article_approval_flows_final6.ps1 deleted file mode 100644 index f2d9526..0000000 --- a/fix_all_article_approval_flows_final6.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues in article_approval_flows -# Usage: .\fix_all_article_approval_flows_final6.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All remaining clientId issues fixed." diff --git a/fix_all_article_approval_flows_final7.ps1 b/fix_all_article_approval_flows_final7.ps1 deleted file mode 100644 index b0433a6..0000000 --- a/fix_all_article_approval_flows_final7.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues in article_approval_flows -# Usage: .\fix_all_article_approval_flows_final7.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All remaining clientId issues fixed." diff --git a/fix_all_article_approval_flows_final8.ps1 b/fix_all_article_approval_flows_final8.ps1 deleted file mode 100644 index e67a058..0000000 --- a/fix_all_article_approval_flows_final8.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues in article_approval_flows -# Usage: .\fix_all_article_approval_flows_final8.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All remaining clientId issues fixed." diff --git a/fix_all_article_approval_flows_final9.ps1 b/fix_all_article_approval_flows_final9.ps1 deleted file mode 100644 index bb0382e..0000000 --- a/fix_all_article_approval_flows_final9.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues in article_approval_flows -# Usage: .\fix_all_article_approval_flows_final9.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All remaining clientId issues fixed." diff --git a/fix_all_clientid.ps1 b/fix_all_clientid.ps1 deleted file mode 100644 index aca5640..0000000 --- a/fix_all_clientid.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues -# Usage: .\fix_all_clientid.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All clientId issues fixed." diff --git a/fix_approval_flow.sql b/fix_approval_flow.sql deleted file mode 100644 index 9f5c537..0000000 --- a/fix_approval_flow.sql +++ /dev/null @@ -1,85 +0,0 @@ --- Script untuk memperbaiki masalah approval flow - --- 1. Pastikan user level 5 memiliki is_approval_active = true -UPDATE user_levels -SET is_approval_active = true -WHERE id = 5; - --- 2. Pastikan workflow yang dibuat adalah default workflow -UPDATE approval_workflows -SET is_default = true, is_active = true -WHERE name = 'Multi-Branch Article Approval'; - --- 3. Cek apakah ada workflow default -SELECT - id, - name, - is_active, - is_default, - client_id -FROM approval_workflows -WHERE is_default = true -AND is_active = true; - --- 4. Jika tidak ada default workflow, buat satu --- (Gunakan ID workflow yang sudah dibuat) --- UPDATE approval_workflows --- SET is_default = true --- WHERE id = YOUR_WORKFLOW_ID; - --- 5. Cek user level 5 setelah update -SELECT - id, - level_name, - level_number, - is_approval_active, - client_id -FROM user_levels -WHERE id = 5; - --- 6. Cek user dengan level 5 -SELECT - u.id, - u.name, - u.user_level_id, - ul.level_name, - ul.level_number, - ul.is_approval_active -FROM users u -JOIN user_levels ul ON u.user_level_id = ul.id -WHERE u.user_level_id = 5; - --- 7. Test: Buat artikel baru untuk test --- Gunakan API atau aplikasi untuk membuat artikel baru --- dengan user level 5 - --- 8. Cek hasil setelah test -SELECT - id, - title, - created_by_id, - workflow_id, - current_approval_step, - status_id, - bypass_approval, - approval_exempt, - created_at -FROM articles -ORDER BY created_at DESC -LIMIT 5; - --- 9. Cek approval flows yang baru dibuat -SELECT - aaf.id, - aaf.article_id, - aaf.workflow_id, - aaf.current_step, - aaf.current_branch, - aaf.status_id, - aaf.submitted_by_id, - aaf.submitted_at, - a.title as article_title -FROM article_approval_flows aaf -JOIN articles a ON aaf.article_id = a.id -ORDER BY aaf.created_at DESC -LIMIT 5; diff --git a/fix_article_approval_flows_clientid.ps1 b/fix_article_approval_flows_clientid.ps1 deleted file mode 100644 index 2691a6e..0000000 --- a/fix_article_approval_flows_clientid.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all clientId issues in article_approval_flows -# Usage: .\fix_article_approval_flows_clientid.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing all clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "All clientId issues fixed." diff --git a/fix_remaining_article_approval_flows.ps1 b/fix_remaining_article_approval_flows.ps1 deleted file mode 100644 index 1c41537..0000000 --- a/fix_remaining_article_approval_flows.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# PowerShell script to fix all remaining clientId issues in article_approval_flows -# Usage: .\fix_remaining_article_approval_flows.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find all methods that use clientId but don't have extraction logic -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "Remaining clientId issues fixed." diff --git a/fix_remaining_clientid.ps1 b/fix_remaining_clientid.ps1 deleted file mode 100644 index e2099e7..0000000 --- a/fix_remaining_clientid.ps1 +++ /dev/null @@ -1,61 +0,0 @@ -# PowerShell script to fix remaining clientId issues -# Usage: .\fix_remaining_clientid.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Fixing remaining clientId issues in: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Find methods that don't have clientId extraction logic but use clientId -$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,' - -$Matches = [regex]::Matches($Content, $MethodPattern) - -foreach ($Match in $Matches) { - $ServiceName = $Match.Groups[1].Value - $MethodName = $Match.Groups[2].Value - $Parameters = $Match.Groups[3].Value - $RepositoryName = $Match.Groups[4].Value - $RepositoryMethod = $Match.Groups[5].Value - - Write-Host "Fixing method: $MethodName" - - # Create the clientId extraction logic - $ExtractionLogic = @" - // Extract clientId from authToken - var clientId *uuid.UUID - if authToken != "" { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken) - if user != nil && user.ClientId != nil { - clientId = user.ClientId - _i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token") - } - } - - if clientId == nil { - return nil, errors.New("clientId not found in auth token") - } - -"@ - - # Replace the method opening with extraction logic - $OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {" - $NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}" - - $Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "Remaining clientId issues fixed." diff --git a/replace_clientid_calls.ps1 b/replace_clientid_calls.ps1 deleted file mode 100644 index 9c2af70..0000000 --- a/replace_clientid_calls.ps1 +++ /dev/null @@ -1,43 +0,0 @@ -# PowerShell script to replace clientId with authToken in method calls -# Usage: .\replace_clientid_calls.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Replacing clientId with authToken in method calls: $FilePath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Replace patterns where clientId is used as parameter to other methods -$Replacements = @( - @{ - Pattern = '_i\.ValidateStepOrder\(clientId, ' - Replacement = '_i.ValidateStepOrder(authToken, ' - }, - @{ - Pattern = '_i\.ValidateStep\(clientId, ' - Replacement = '_i.ValidateStep(authToken, ' - }, - @{ - Pattern = '_i\.CanDeleteStep\(clientId, ' - Replacement = '_i.CanDeleteStep(authToken, ' - } -) - -foreach ($Replacement in $Replacements) { - $Content = $Content -replace $Replacement.Pattern, $Replacement.Replacement - Write-Host "Replaced: $($Replacement.Pattern)" -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "ClientId method calls replaced with authToken." diff --git a/update_service_methods.ps1 b/update_service_methods.ps1 deleted file mode 100644 index b04b116..0000000 --- a/update_service_methods.ps1 +++ /dev/null @@ -1,44 +0,0 @@ -# PowerShell script to update service method signatures -# Usage: .\update_service_methods.ps1 - -param( - [Parameter(Mandatory=$true)] - [string]$FilePath -) - -if (-not (Test-Path $FilePath)) { - Write-Error "File not found: $FilePath" - exit 1 -} - -Write-Host "Updating service methods in: $FilePath" - -# Create backup -$BackupPath = "$FilePath.backup" -Copy-Item $FilePath $BackupPath -Write-Host "Backup created at: $BackupPath" - -# Read file content -$Content = Get-Content $FilePath -Raw - -# Update method signatures - replace clientId *uuid.UUID with authToken string -$Patterns = @( - @{ - Pattern = 'func \(_i \*(\w+)Service\) (\w+)\(clientId \*uuid\.UUID, ' - Replacement = 'func (_i *$1Service) $2(authToken string, ' - }, - @{ - Pattern = 'func \(_i \*(\w+)Service\) (\w+)\(clientId \*uuid\.UUID\) ' - Replacement = 'func (_i *$1Service) $2(authToken string) ' - } -) - -foreach ($Pattern in $Patterns) { - $Content = $Content -replace $Pattern.Pattern, $Pattern.Replacement -} - -# Write updated content -Set-Content $FilePath $Content -NoNewline - -Write-Host "Service method signatures updated." -Write-Host "Please review the changes and add clientId extraction logic manually." diff --git a/update_service_methods.sh b/update_service_methods.sh deleted file mode 100644 index 200bb1a..0000000 --- a/update_service_methods.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -# Script to update all service methods from clientId *uuid.UUID to authToken string -# Usage: ./update_service_methods.sh - -if [ $# -eq 0 ]; then - echo "Usage: ./update_service_methods.sh " - exit 1 -fi - -FILE_PATH=$1 - -if [ ! -f "$FILE_PATH" ]; then - echo "File not found: $FILE_PATH" - exit 1 -fi - -echo "Updating service methods in: $FILE_PATH" - -# Create backup -cp "$FILE_PATH" "${FILE_PATH}.backup" - -# Update method signatures -sed -i 's/func (_i \*[a-zA-Z]*Service) \([A-Za-z]*\)(clientId \*uuid\.UUID, /func (_i *\1Service) \2(authToken string, /g' "$FILE_PATH" - -# Add clientId extraction logic to each method -# This is a simplified approach - in practice, you'd need more sophisticated sed patterns - -echo "Service methods updated. Please review the changes and add clientId extraction logic manually." -echo "Backup created at: ${FILE_PATH}.backup"