Skip to content

Commit 757523a

Browse files
committed
Merge branch 'cleanup/code-comments-v3' into 'main'
chore: trim trailing whitespace inside code comments Closes #193 See merge request postgres-ai/postgresai!265
2 parents e0be2e8 + cfff872 commit 757523a

4 files changed

Lines changed: 22 additions & 22 deletions

File tree

cli/lib/checkup.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,41 @@
22
* Express Checkup Module
33
* ======================
44
* Generates JSON health check reports directly from PostgreSQL without Prometheus.
5-
*
5+
*
66
* ARCHITECTURAL DECISIONS
77
* -----------------------
8-
*
8+
*
99
* 1. SINGLE SOURCE OF TRUTH FOR SQL QUERIES
10-
* Complex metrics (index health, settings, db_stats) are loaded from
10+
* Complex metrics (index health, settings, db_stats) are loaded from
1111
* config/pgwatch-prometheus/metrics.yml via getMetricSql() from metrics-loader.ts.
12-
*
12+
*
1313
* Simple queries (version, database list, connection states, uptime) use
1414
* inline SQL as they're trivial and CLI-specific.
15-
*
15+
*
1616
* 2. JSON SCHEMA COMPLIANCE
1717
* All generated reports MUST comply with JSON schemas in reporter/schemas/.
1818
* These schemas define the expected format for both:
1919
* - Full-fledged monitoring reporter output
2020
* - Express checkup output
21-
*
21+
*
2222
* Before adding or modifying a report, verify the corresponding schema exists
2323
* and ensure the output matches. Run schema validation tests to confirm.
24-
*
24+
*
2525
* 3. ERROR HANDLING STRATEGY
2626
* Functions follow two patterns based on criticality:
27-
*
27+
*
2828
* PROPAGATING (throws on error):
2929
* - Core data functions: getPostgresVersion, getSettings, getAlteredSettings,
3030
* getDatabaseSizes, getInvalidIndexes, getUnusedIndexes, getRedundantIndexes
3131
* - If these fail, the entire report should fail (data is required)
3232
* - Callers should handle errors at the report generation level
33-
*
33+
*
3434
* GRACEFUL DEGRADATION (catches errors, includes error in output):
3535
* - Optional/supplementary queries: pg_stat_statements, pg_stat_kcache checks,
3636
* memory calculations, postmaster startup time
3737
* - These are nice-to-have; missing data shouldn't fail the whole report
3838
* - Errors are logged and included in report output for visibility
39-
*
39+
*
4040
* ADDING NEW REPORTS
4141
* ------------------
4242
* 1. Add/verify the metric exists in config/pgwatch-prometheus/metrics.yml
@@ -336,7 +336,7 @@ export function parseVersionNum(versionNum: string): { major: string; minor: str
336336
/**
337337
* Format bytes to human readable string using binary units (1024-based).
338338
* Uses IEC standard: KiB, MiB, GiB, etc.
339-
*
339+
*
340340
* Note: PostgreSQL's pg_size_pretty() uses kB/MB/GB with 1024 base (technically
341341
* incorrect SI usage), but we follow IEC binary units per project style guide.
342342
*/
@@ -387,7 +387,7 @@ function formatSettingPrettyValue(
387387
/**
388388
* Get PostgreSQL version information.
389389
* Uses simple inline SQL (trivial query, CLI-specific).
390-
*
390+
*
391391
* @throws {Error} If database query fails (propagating - critical data)
392392
*/
393393
export async function getPostgresVersion(client: Client): Promise<PostgresVersion> {
@@ -1084,7 +1084,7 @@ export const generateH004 = (client: Client, nodeName = "node-01") =>
10841084

10851085
/**
10861086
* Generate D004 report - pg_stat_statements and pg_stat_kcache settings.
1087-
*
1087+
*
10881088
* Uses graceful degradation: extension queries are wrapped in try-catch
10891089
* because extensions may not be installed. Errors are included in the
10901090
* report output rather than failing the entire report.

cli/lib/init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export type AdminConnection = {
8787
/**
8888
* Check if an error indicates SSL negotiation failed and fallback to non-SSL should be attempted.
8989
* This mimics libpq's sslmode=prefer behavior.
90-
*
90+
*
9191
* IMPORTANT: This should NOT match certificate errors (expired, invalid, self-signed)
9292
* as those are real errors the user needs to fix, not negotiation failures.
9393
*/

cli/lib/metrics-loader.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Metrics loader for express checkup reports
3-
*
3+
*
44
* Loads SQL queries from embedded metrics data (generated from metrics.yml at build time).
55
* Provides version-aware query selection and row transformation utilities.
66
*/
@@ -9,7 +9,7 @@ import { METRICS, MetricDefinition } from "./metrics-embedded";
99

1010
/**
1111
* Get SQL query for a specific metric, selecting the appropriate version.
12-
*
12+
*
1313
* @param metricName - Name of the metric (e.g., "settings", "db_stats")
1414
* @param pgMajorVersion - PostgreSQL major version (default: 16)
1515
* @returns SQL query string
@@ -41,7 +41,7 @@ export function getMetricSql(metricName: string, pgMajorVersion: number = 16): s
4141

4242
/**
4343
* Get metric definition including all metadata.
44-
*
44+
*
4545
* @param metricName - Name of the metric
4646
* @returns MetricDefinition or undefined if not found
4747
*/

reporter/postgres_reports.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def get_index_definitions_from_sink(self, db_name: str = None) -> Dict[str, str]
259259
# 1. This method is called VERY rarely (only during report generation)
260260
# 2. The table size is expected to remain small (< 10000 rows per database)
261261
# 3. Current latency is well under 1 second for typical workloads
262-
#
262+
#
263263
# If the table grows significantly larger (>> 10000 rows) or latency exceeds 1s,
264264
# consider adding a GIN index on the data JSONB column or materialized view.
265265
if db_name:
@@ -1107,7 +1107,7 @@ def generate_d004_pgstat_settings_report(self, cluster: str = "local", node_name
11071107
# Check if pg_stat_kcache extension is available and working by querying its metrics
11081108
kcache_status = self._check_pg_stat_kcache_status(cluster, node_name)
11091109

1110-
# Check if pg_stat_statements is available and working by querying its metrics
1110+
# Check if pg_stat_statements is available and working by querying its metrics
11111111
pgss_status = self._check_pg_stat_statements_status(cluster, node_name)
11121112

11131113
return self.format_report_data(
@@ -1635,7 +1635,7 @@ def _analyze_memory_settings(self, memory_data: Dict[str, Any]) -> Dict[str, Any
16351635
"effective_cache_size_pretty": self.format_bytes(effective_cache_size)
16361636
}
16371637

1638-
# Generate recommendations
1638+
# Generate recommendations
16391639
except (ValueError, TypeError):
16401640
# If parsing fails, return empty analysis
16411641
analysis["estimated_total_memory_usage"] = {}
@@ -3285,7 +3285,7 @@ def _get_pgss_metrics_data(self, cluster: str, node_name: str, start_time: datet
32853285
if start_result:
32863286
start_data.extend(start_result)
32873287

3288-
# Query metrics around end time
3288+
# Query metrics around end time
32893289
end_result = self.query_range(metric_with_filters, end_time - timedelta(minutes=1),
32903290
end_time + timedelta(minutes=1))
32913291
if end_result:
@@ -4976,7 +4976,7 @@ def _get_pgss_metrics_data_by_db(self, cluster: str, node_name: str, db_name: st
49764976
start_data.extend(start_result)
49774977
metrics_found += 1
49784978

4979-
# Query metrics around end time
4979+
# Query metrics around end time
49804980
end_result = self.query_range(metric_with_filters, end_time - timedelta(minutes=1),
49814981
end_time + timedelta(minutes=1))
49824982
if end_result:

0 commit comments

Comments
 (0)