Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 6, 2025

Addresses code duplication feedback on #484 where business logic for calculating days before/after payday was duplicated between PaymasterWorker and EmailTestServer.

Changes

  • Created lib/utils/payday.ts: Extracted daysBeforePayday and daysAfterPayday functions as reusable utilities
  • Updated workers/paymaster/src/index.ts: Removed duplicate methods, imports shared utilities
  • Updated workers/email/scripts/emailOverview.ts: Replaced 39 lines of duplicated calculation logic with utility function call

Before/After

Before:

// emailOverview.ts - duplicated logic
let expectedPayDay: Date | null = null;
if (workspace.paidUntil) {
  expectedPayDay = new Date(workspace.paidUntil);
} else if (workspace.lastChargeDate) {
  const lastCharge = new Date(workspace.lastChargeDate);
  expectedPayDay = new Date(lastCharge.getFullYear(), lastCharge.getMonth() + 1, lastCharge.getDate());
}
// ... more calculation logic

After:

// emailOverview.ts - using shared utility
import { daysAfterPayday } from '../../../lib/utils/payday';

const days = daysAfterPayday(workspace.lastChargeDate, workspace.paidUntil);

Payday calculation logic is now maintained in a single location, ensuring consistency across all workers.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: talyguryn <15259299+talyguryn@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 6, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fastdl.mongodb.org
    • Triggering command: /usr/local/bin/node node ./postinstall.js /home/REDACTED/.cache/node-gyp/20.19.6/deps/uv/include -I /home/REDACTED/.cache/node-gyp/20.19.6/deps/zlib -I /home/REDACTED/.cache/node-gyp/20.19.6/deps/v8/include -I ../../../../../nan --64 -o Release/obj.target/sshcrypto/src/binding.o runn�� e -c _modules/.bin/as (dns block)
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/hawk.workers/hawk.workers/node_modules/.bin/jest workers/paymaster l/openssl/includ-e conf�� rc/index.ts workers/email/scripts/emailOverview.ts --global s pull.rebase l/config (dns block)
  • node-binaries.s3.amazonaws.com
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/hawk.workers/hawk.workers/node_modules/gc-stats/node_modules/.bin/node-pre-gyp install --fallback-to-build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] WIP address feedback on reminder email feature Extract payday calculation logic to shared utility module Dec 6, 2025
Copilot AI requested a review from talyguryn December 6, 2025 15:18
@talyguryn talyguryn closed this Dec 6, 2025
@talyguryn talyguryn deleted the copilot/sub-pr-484 branch December 6, 2025 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants