HASH 0217690a1a41
DATE 2025-07-21
SUBJECT nix: add changelog system to simulation script, bump to latest
FILES 2 CHANGED
HASH 0217690a1a41
DATE 2025-07-21
SUBJECT nix: add changelog system to
simulation script, bump to latest
FILES 2 CHANGED
┌─ flake.lock ───────────────────────────────────────────────────────────────┐
│ diff --git a/flake.lock b/flake.lock │
│ index 8fc9ba3..b630eb5 100644 │
│ --- a/flake.lock │
│ +++ b/flake.lock │
│ @@ -85,11 +85,11 @@ │
│ ] │
│ }, │
│ "locked": { │
│ - "lastModified": 1752915035, │
│ - "narHash": "sha256-cTvsqC4HlSgaZoXJ9AfXbdhGE1SOuh+DQAZ8Lr9QPps=", │
│ + "lastModified": 1753058224, │
│ + "narHash": "sha256-D5oZmCNY0Sl6bF1obyS6j2uM21xBdnSuQ+i4a7eIR5E=", │
│ "owner": "ooks-io", │
│ "repo": "mop", │
│ - "rev": "822d1522a1ecdd80a60bab5662f9c95306a9cd8a", │
│ + "rev": "4f777d495f0f362cdadd478cb26f05bad66be8bd", │
│ "type": "github" │
│ }, │
│ "original": { │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ flake.lock ─────────────────────────┐
│ diff --git a/flake.lock b/flake.lock │
│ index 8fc9ba3..b630eb5 100644 │
│ --- a/flake.lock │
│ +++ b/flake.lock │
│ @@ -85,11 +85,11 @@ │
│ ] │
│ }, │
│ "locked": { │
│ - "lastModified": 1752915035, │
│ - "narHash": "sha256-cTvsqC4HlSgaZoXJ │
│ 9AfXbdhGE1SOuh+DQAZ8Lr9QPps=", │
│ + "lastModified": 1753058224, │
│ + "narHash": "sha256-D5oZmCNY0Sl6bF1o │
│ byS6j2uM21xBdnSuQ+i4a7eIR5E=", │
│ "owner": "ooks-io", │
│ "repo": "mop", │
│ - "rev": "822d1522a1ecdd80a60bab5662f │
│ 9c95306a9cd8a", │
│ + "rev": "4f777d495f0f362cdadd478cb26 │
│ f05bad66be8bd", │
│ "type": "github" │
│ }, │
│ "original": { │
└──────────────────────────────────────────────┘
┌─ nix/apps/simulation/mkMassSim.nix ────────────────────────────────────────┐
│ diff --git a/nix/apps/simulation/mkMassSim.nix b/nix/apps/simulation/mkMassSim.nix │
│ index 7c10ab5..69ac672 100644 │
│ --- a/nix/apps/simulation/mkMassSim.nix │
│ +++ b/nix/apps/simulation/mkMassSim.nix │
│ @@ -205,14 +205,81 @@ │
│ fi │
│ current_dir="$(dirname "$current_dir")" │
│ done │
│ - │
│ + │
│ if [[ -z "$repo_root" ]]; then │
│ echo "Warning: Could not find repo root (flake.nix), using current dire │
│ ctory" │
│ repo_root="$PWD" │
│ fi │
│ - │
│ + │
│ web_data_dir="$repo_root/web/public/data" │
│ + archive_dir="$web_data_dir/archive" │
│ + existing_file="$web_data_dir/${structuredOutput}.json" │
│ + │
│ mkdir -p "$web_data_dir" │
│ + mkdir -p "$archive_dir" │
│ + │
│ + # Archive existing file if it exists │
│ + if [[ -f "$existing_file" ]]; then │
│ + timestamp=$(date +"%Y%m%d_%H%M%S") │
│ + archived_name="${structuredOutput}_$timestamp.json" │
│ + cp "$existing_file" "$archive_dir/$archived_name" │
│ + echo "Archived existing file: $archived_name" │
│ + │
│ + # Generate changelog by comparing with archived version │
│ + echo "Generating changelog..." │
│ + changes=$(echo "$finalResult" | jq --slurpfile archived "$existing_file │
│ " ' │
│ + .results as $current | │
│ + $archived[0].results as $previous | │
│ + [ │
│ + $current | to_entries[] | . as $class_entry | │
│ + $class_entry.value | to_entries[] | . as $spec_entry | │
│ + { │
│ + class: $class_entry.key, │
│ + spec: $spec_entry.key, │
│ + current_dps: $spec_entry.value.dps, │
│ + previous_dps: ($previous[$class_entry.key][$spec_entry.key].dps / │
│ / null) │
│ + } | │
│ + select(.previous_dps != null and .current_dps != .previous_dps) | │
│ + { │
│ + class: .class, │
│ + spec: .spec, │
│ + current_dps: (.current_dps | round), │
│ + previous_dps: (.previous_dps | round), │
│ + absolute_change: ((.current_dps - .previous_dps) | round), │
│ + percent_change: (((.current_dps - .previous_dps) / .previous_dps │
│ * 100) | (. * 100 | round) / 100) │
│ + } │
│ + ] │
│ + ') │
│ + │
│ + change_count=$(echo "$changes" | jq length) │
│ + if [[ "$change_count" -gt 0 ]]; then │
│ + echo "Found $change_count DPS changes:" │
│ + echo "$changes" | jq -r '.[] | " \(.class)/\(.spec): \(if .absolute_ │
│ change > 0 then "+" else "" end)\(.absolute_change) DPS (\(if .percent_change > 0 │
│ then "+" else "" end)\(.percent_change)%)"' │
│ + │
│ + # Update or create changelog │
│ + changelog_file="$web_data_dir/changelog.json" │
│ + if [[ -f "$changelog_file" ]]; then │
│ + current_changelog=$(cat "$changelog_file") │
│ + else │
│ + current_changelog='{}' │
│ + fi │
│ + │
│ + updated_changelog=$(echo "$current_changelog" | jq \ │
│ + --arg sim "${structuredOutput}" \ │
│ + --arg timestamp "$(date -Iseconds)" \ │
│ + --argjson changes "$changes" ' │
│ + .[$sim] = (.[$sim] // []) + [{ │
│ + timestamp: $timestamp, │
│ + changes: $changes │
│ + }]') │
│ + │
│ + echo "$updated_changelog" > "$changelog_file" │
│ + echo "Updated changelog: $changelog_file" │
│ + else │
│ + echo "No DPS changes detected." │
│ + fi │
│ + fi │
│ + │
│ cp "${structuredOutput}.json" "$web_data_dir/" │
│ echo "Copied to: $web_data_dir/${structuredOutput}.json" │
│ │
│ @@ -248,4 +315,3 @@ │
│ in { │
│ inherit mkMassSim getAllDPSSpecs; │
│ } │
│ - │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ ...apps/simulation/mkMassSim.nix ───┐
│ diff --git a/nix/apps/simulation/mkMassSim.n │
│ ix b/nix/apps/simulation/mkMassSim.nix │
│ index 7c10ab5..69ac672 100644 │
│ --- a/nix/apps/simulation/mkMassSim.nix │
│ +++ b/nix/apps/simulation/mkMassSim.nix │
│ @@ -205,14 +205,81 @@ │
│ fi │
│ current_dir="$(dirname "$current_ │
│ dir")" │
│ done │
│ - │
│ + │
│ if [[ -z "$repo_root" ]]; then │
│ echo "Warning: Could not find rep │
│ o root (flake.nix), using current directory" │
│ repo_root="$PWD" │
│ fi │
│ - │
│ + │
│ web_data_dir="$repo_root/web/public │
│ /data" │
│ + archive_dir="$web_data_dir/archive" │
│ + existing_file="$web_data_dir/${stru │
│ cturedOutput}.json" │
│ + │
│ mkdir -p "$web_data_dir" │
│ + mkdir -p "$archive_dir" │
│ + │
│ + # Archive existing file if it exist │
│ s │
│ + if [[ -f "$existing_file" ]]; then │
│ + timestamp=$(date +"%Y%m%d_%H%M%S" │
│ ) │
│ + archived_name="${structuredOutput │
│ }_$timestamp.json" │
│ + cp "$existing_file" "$archive_dir │
│ /$archived_name" │
│ + echo "Archived existing file: $ar │
│ chived_name" │
│ + │
│ + # Generate changelog by comparing │
│ with archived version │
│ + echo "Generating changelog..." │
│ + changes=$(echo "$finalResult" | j │
│ q --slurpfile archived "$existing_file" ' │
│ + .results as $current | │
│ + $archived[0].results as $previo │
│ us | │
│ + [ │
│ + $current | to_entries[] | . a │
│ s $class_entry | │
│ + $class_entry.value | to_entri │
│ es[] | . as $spec_entry | │
│ + { │
│ + class: $class_entry.key, │
│ + spec: $spec_entry.key, │
│ + current_dps: $spec_entry.va │
│ lue.dps, │
│ + previous_dps: ($previous[$c │
│ lass_entry.key][$spec_entry.key].dps // null │
│ ) │
│ + } | │
│ + select(.previous_dps != null │
│ and .current_dps != .previous_dps) | │
│ + { │
│ + class: .class, │
│ + spec: .spec, │
│ + current_dps: (.current_dps │
│ | round), │
│ + previous_dps: (.previous_dp │
│ s | round), │
│ + absolute_change: ((.current │
│ _dps - .previous_dps) | round), │
│ + percent_change: (((.current │
│ _dps - .previous_dps) / .previous_dps * 100) │
│ | (. * 100 | round) / 100) │
│ + } │
│ + ] │
│ + ') │
│ + │
│ + change_count=$(echo "$changes" | │
│ jq length) │
│ + if [[ "$change_count" -gt 0 ]]; t │
│ hen │
│ + echo "Found $change_count DPS c │
│ hanges:" │
│ + echo "$changes" | jq -r '.[] | │
│ " \(.class)/\(.spec): \(if .absolute_change │
│ > 0 then "+" else "" end)\(.absolute_change │
│ ) DPS (\(if .percent_change > 0 then "+" els │
│ e "" end)\(.percent_change)%)"' │
│ + │
│ + # Update or create changelog │
│ + changelog_file="$web_data_dir/c │
│ hangelog.json" │
│ + if [[ -f "$changelog_file" ]]; │
│ then │
│ + current_changelog=$(cat "$cha │
│ ngelog_file") │
│ + else │
│ + current_changelog='{}' │
│ + fi │
│ + │
│ + updated_changelog=$(echo "$curr │
│ ent_changelog" | jq \ │
│ + --arg sim "${structuredOutput │
│ }" \ │
│ + --arg timestamp "$(date -Isec │
│ onds)" \ │
│ + --argjson changes "$changes" │
│ ' │
│ + .[$sim] = (.[$sim] // []) + [ │
│ { │
│ + timestamp: $timestamp, │
│ + changes: $changes │
│ + }]') │
│ + │
│ + echo "$updated_changelog" > "$c │
│ hangelog_file" │
│ + echo "Updated changelog: $chang │
│ elog_file" │
│ + else │
│ + echo "No DPS changes detected." │
│ + fi │
│ + fi │
│ + │
│ cp "${structuredOutput}.json" "$web │
│ _data_dir/" │
│ echo "Copied to: $web_data_dir/${st │
│ ructuredOutput}.json" │
│ │
│ @@ -248,4 +315,3 @@ │
│ in { │
│ inherit mkMassSim getAllDPSSpecs; │
│ } │
│ - │
└──────────────────────────────────────────────┘
[ BACK TO LOG ]
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET