Skip to content

Instantly share code, notes, and snippets.

// Jira Worklogs + Summary with Original Estimate
//
/*
Jira Worklogs + Estimates Sync
Purpose:
- Sync Jira worklogs into Postgres and build a per issue time summary with Original Estimate.
Selection:
- Processes only completed issues
- Applies a grace window (COMPLETED_GRACE_DAYS)
- Skips issues already snapshotted unless OVERWRITE_SUMMARY=true
/**
* deployment_backfill_run.js
*
* Reads deployments from a CSV file and posts them to the DX Deployments API.
* Supports --dry-run to preview the first 10 records only (no API calls).
*/
const fs = require('fs');
const path = require('path');
const csv = require('csv-parser');
/**
* fetch_work_item_parents.js
*
* Backfill: WorkItemLinks WIQL, partitioned by Source.ChangedDate windows using DATE precision (YYYY-MM-DD)
* Incremental: WorkItems WIQL by ChangedDate with DATE precision filter (YYYY-MM-DD)
* Writes: batched multi row upserts into custom.ado_work_item_links
* Schema columns used: child_work_item_source_id, parent_work_item_source_id, relation_url
* MIN_ID applied to both parent and child
* Direct ADO HTTPS without DX proxy
* Dry run writes a SQL file
// enrich_duo_csv.js
// CommonJS version. Only env var required: DATABASE_URL
const fs = require("fs");
const { parse } = require("csv-parse");
const { stringify } = require("csv-stringify");
const { Pool } = require("pg");
const DATABASE_URL = process.env.DATABASE_URL;
if (!DATABASE_URL) {
/**
* Fetch ADO custom field "Classification" for Work Items and upsert into DX.
* Usage: node fetch_classification.js
*/
const fs = require('fs');
const path = require('path');
const { Client } = require('pg');
const axios = require('axios');
'use strict';
/**
* export_dx_users.js
*
* Streams a DX Postgres query to a CSV file.
* - Uses DATABASE_URL from environment (preferred)
* - Falls back to HARDCODED_DB_URL if set
* - Normalizes postgres:// → postgresql://
* - Streams results to avoid memory issues
// Jira Worklogs + Summary with Original Estimate
//
/*
Jira Worklogs + Estimates Sync
Purpose:
- Sync Jira worklogs into Postgres and build a per issue time summary with Original Estimate.
Selection:
- Processes only completed issues
/**
* fetch_work_item_parents.incremental.js
*
* Purpose: Incremental-only importer of ADO parent-child links into DX.
* Uses a per-project watermark based on ADO System.ChangedDate to avoid gaps and duplicates.
*
* Writes: batched multi-row upserts into custom.ado_work_item_links
* Watermarks: custom.ado_wi_links_watermarks (organization_name, project_name, last_changed_at)
*
* Schema columns used in links table:
/**
* fetch_work_item_parents.js
*
* Backfill: WorkItemLinks WIQL, partitioned by Source.ChangedDate windows using DATE precision (YYYY-MM-DD)
* Incremental: WorkItems WIQL by ChangedDate, then workitemsbatch expand=Relations
* Writes: batched multi row upserts into custom.ado_work_item_links
* Schema columns used: child_work_item_source_id, parent_work_item_source_id, relation_url
* MIN_ID applied to both parent and child
* ADO HTTPS via http://DX_PROXY_USER:[email protected]:80
* Dry run writes a SQL file
# frozen_string_literal: true
module CustomerScripts
class accountIncidentImport
extend Callable
def call
results = unprocessed_issues
if results.empty?