<commit_before>const path = require('path');
const fs = require('fs-extra');
const debug = require('debug')('server:getChartImage');
const differenceInWeeks = require('date-fns/difference_in_weeks');
const sanitizeFilename = require('filenamify');

const browserPagePool = require('./services/browserPagePool');
const getPackagesFromUrl = require('./getPackagesFromUrl');
const SCREENSHOT_DIR = require('configs/SCREENSHOT_DIR');

const sanitizeScreenshotFilename = url =>
  sanitizeFilename(getPackagesFromUrl(url).join(','));

const fileIsNotStale = filePath =>
  differenceInWeeks(new Date(), Date(fs.statSync(filePath).mtime)) < 3;

module.exports = async url => {
  try {
    debug('checking if screenshot exists');
    const screenshotPath = path.join(<commit_msg>decrease screencap cache length from 3 weeks to 1<commit_after>const path = require('path');
const fs = require('fs-extra');
const debug = require('debug')('server:getChartImage');
const differenceInWeeks = require('date-fns/difference_in_weeks');
const sanitizeFilename = require('filenamify');

const browserPagePool = require('./services/browserPagePool');
const getPackagesFromUrl = require('./getPackagesFromUrl');
const SCREENSHOT_DIR = require('configs/SCREENSHOT_DIR');

const sanitizeScreenshotFilename = url =>
  sanitizeFilename(getPackagesFromUrl(url).join(','));

const fileIsNotStale = filePath =>
  differenceInWeeks(new Date(), Date(fs.statSync(filePath).mtime)) < 1;

module.exports = async url => {
  try {
    debug('checking if screenshot exists');
    const screenshotPath = path.join(
{'fraction_non_alphanumeric': 0.1383248730964467, 'fraction_numerical': 0.0025380710659898475, 'mean_word_length': 6.924623115577889, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1761095', 'n_tokens_mistral': 484, 'n_tokens_neox': 467, 'n_words': 99}