#+TITLE: [30-11-2025] - Weekly Review
#+OPTIONS: num:nil
#+DATE: <2025-11-30 Sun 17:09>
#+filetags: :review:
#+WIP:
#+COMMENTS: t
#+SLUG: 30-11-25-week-review

* Previous Week List:

- Competencies to do:
  - +Aware of relational databases+
  - +Aware of TLS and SSL+
  - +Aware of good error handling and logging+
  - Understanding of TCP/IP
  - Understands Server Operating Systems (might be tough)
    
  Been extremely busy with this sprint, getting the work delivered in a timely manner; there wasn't as much time to focus on competencies.
    
* Weekly Review
- <2025-11-24 Mon>:
  - Got the news the company is reducing staff. See this [[https://www.thebusinessdesk.com/eastmidlands/news/2104597-microlise-issues-profit-warning-after-weaker-than-expected-trading][article]]
  - Got the DAG for PR's to work
- <2025-11-25 Tue>
  - Worked mainly on threads and commits DAGs
- <2025-11-26 Wed>
  - We had a meeting with Kevin on the scoring system for the redundancy thing
  - Finished creating and testing all the DAG's
- <2025-11-27 Thu>
  - Refinement meeting
  - Started creating base case tests for SQL
  - Made a script to automate the creation of testing files
- <2025-11-28 Fri>
  - Finished base case tests
  - Training with Lloyd on SRE and Techops
** Daily retrospectives:

[[../../../assets/images/reviews/30-11-25-daily-retros.jpg]]

** Weekly retrospectives

[[../../../assets/sketchnotes/30-11-2025-retrospectives.svg]]

* Other

** Powershell script:

Here is the powershell script that generates the files for testing:

#+BEGIN_SRC ps1

# Define the base folders
$securityFolder = "C:\Users\zqayyum\Source\Repos\DataMart.Academy.DoraMetrics\tsqlt\Security"
$scriptsFolder = "C:\Users\zqayyum\Source\Repos\DataMart.Academy.DoraMetrics\tsqlt"


# Create base folders if they don't exist
if (!(Test-Path $securityFolder)) { New-Item -ItemType Directory -Path $securityFolder }
if (!(Test-Path $scriptsFolder)) { New-Item -ItemType Directory -Path $scriptsFolder }

# Define main file names (schemas)
$fileNames = @(
 "testMergeStagingDataCommits.sql",
 "testMergeStagingDataEnvironments.sql",
 "testMergeStagingDataPullRequests.sql",
 "testMergeStagingDataReleases.sql",
 "testMergeStagingDataRepositories.sql",
 "testMergeStagingDataThreads.sql"
)

# Define stored procedure test files
$storedProcFiles = @(
 "Test changed rows are logged.sql",
 "Test changed rows are not logged as inserted.sql",
 "Test changed rows are updated.sql",
 "Test errors are logged.sql",
 "Test import date on changed rows is updated.sql",
 "Test new rows are inserted.sql",
 "Test new rows are not logged as updated.sql"
)

foreach ($name in $fileNames) {
 # Create .sql file under Security
 $filePath = Join-Path $securityFolder $name
 $schemaName = [System.IO.Path]::GetFileNameWithoutExtension($name)

 # Content for schema file
 $schemaContent = @"
CREATE SCHEMA [$schemaName]
 AUTHORIZATION [dbo];

GO
EXECUTE sp_addextendedproperty 
 @name = N'tSQLt.TestClass', 
 @value = 1, 
 @level0type = N'SCHEMA', 
 @level0name = N'$schemaName';
GO
"@

 Set-Content -Path $filePath -Value $schemaContent

 # Create schema folder under Scripts
 $schemaFolderPath = Join-Path $scriptsFolder $schemaName
 if (!(Test-Path $schemaFolderPath)) {
 New-Item -ItemType Directory -Path $schemaFolderPath | Out-Null
 }

 # Create Stored Procedures subfolder
 $storedProcFolderPath = Join-Path $schemaFolderPath "Stored Procedures"
 if (!(Test-Path $storedProcFolderPath)) {
 New-Item -ItemType Directory -Path $storedProcFolderPath | Out-Null
 }

 # Create stored procedure files with dynamic content
 foreach ($procFile in $storedProcFiles) {
 $procFilePath = Join-Path $storedProcFolderPath $procFile
 $procName = [System.IO.Path]::GetFileNameWithoutExtension($procFile)

 $procContent = @"
CREATE PROCEDURE $schemaName.[$procName]
AS
BEGIN
 SET NOCOUNT ON;

 -- Assemble
 DECLARE @RowsUpdated INT; 

 EXEC tsqlt.FakeTable @SchemaName = 'staging', @TableName = 'tbl_TemplateTable';
 EXEC tsqlt.FakeTable @SchemaName = 'data', @TableName = 'tbl_TemplateTable';
 EXEC tsqlt.FakeTable @SchemaName = 'logging', @TableName = 'tbl_ExecutionCounts';

 INSERT INTO data.tbl_TemplateTable(UnitDescription, TrunionDisplacementInMM)
 VALUES('UT7000', '9');

 INSERT INTO staging.tbl_TemplateTable(UnitDescription, TrunionDisplacementInMM)
 VALUES('UT7000', '6');

 -- Act
 EXEC staging.pr_MergeStagingData;

 -- Assert
 SELECT @RowsUpdated = RowsUpdated FROM logging.tbl_ExecutionCounts;
 
 EXEC tsqlt.AssertEquals 
 @Actual = @RowsUpdated,
 @Expected = 1; 
END
"@

 Set-Content -Path $procFilePath -Value $procContent
 }
}

Write-Host "All files and folders created successfully with dynamic procedure content"
  
#+END_SRC

** Finances
I decided to spin up a docker container to manage finances. For the moment there is no way to connect to a Bank without using an intermediary (privacy concerns).

[[../../../assets/images/reviews/30-11-2025-acutal.png]]

* Next Week

  -  Understands Server Operating Systems (might be tough)
  -  Understanding of TCP/IP
