Skip to content

Commit

Permalink
add scrape from beginning of month
Browse files Browse the repository at this point in the history
  • Loading branch information
shayki5 committed Oct 3, 2023
1 parent 70b803e commit 1173c00
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import "dotenv/config";
import { subDays, format } from "date-fns";
import { subDays, format, startOfMonth } from "date-fns";
import { AccountConfig } from "./types";
import { logToPublicLog } from "./utils/logger.js";


logToPublicLog("Parsing config");
const {
DAYS_BACK,
Expand All @@ -13,6 +14,7 @@ const {
WORKSHEET_NAME,
ACCOUNTS_TO_SCRAPE = "",
FUTURE_MONTHS = "",
SCRAPE_FROM_BEGINNING_OF_MONTH = ""
} = process.env;

/**
Expand All @@ -29,7 +31,9 @@ const accountsToScrape = ACCOUNTS_TO_SCRAPE.split(",")
export { TELEGRAM_API_KEY, TELEGRAM_CHAT_ID, GOOGLE_SHEET_ID };
export const systemName = "moneyman";
export const currentDate = format(Date.now(), "yyyy-MM-dd");
export const scrapeStartDate = subDays(Date.now(), Number(daysBackToScrape));
export const scrapeStartDate = SCRAPE_FROM_BEGINNING_OF_MONTH === "true"
? subDays(startOfMonth(Date.now()), Number(daysBackToScrape))
: subDays(Date.now(), Number(daysBackToScrape));

export const accounts = parseAccounts(ACCOUNTS_JSON).filter(
(account) =>
Expand Down

0 comments on commit 1173c00

Please sign in to comment.