{"size": 972, "ext": "js", "max_stars_repo_path": "common/digestEmailHtml.js", "max_stars_repo_name": "ScottLogic/search-data-exports-backend", "max_stars_repo_stars_event_min_datetime": "2020-08-27T14:38:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T15:40:24.000Z", "max_issues_repo_path": "common/digestEmailHtml.js", "max_issues_repo_name": "ScottLogic/search-data-exports-backend", "max_issues_repo_issues_event_min_datetime": "2021-03-10T00:59:03.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-10T20:33:50.000Z", "max_forks_repo_path": "common/digestEmailHtml.js", "max_forks_repo_name": "ScottLogic/search-data-exports-backend", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 6, "max_issues_count": 4, "max_forks_count": null, "avg_line_length": 23.1428571429, "max_line_length": 179, "alphanum_fraction": 0.566872428}
const createPostOutput = ({
  UserID, DateCreated, Content, Tags
}) => (
  `
  <div style="background-color: whitesmoke; border: 1px solid black;">
    <div>
      <div>${UserID}</div>
      <div>${DateCreated}</div>
    </div>
    <hr>
    <div>
      ${Content}
    </div>
    <div>
      ${Tags.join(' ')}
    </div>
  </div>
  `
);

const createDigestSection = result => (
  `
  <h3>New posts matching your digests for <i>${result.searchTerms.map(term => `<a href="http://${process.env.WEBSITE_LINK_URL}/?search=${term}">${term}</a>`).join(', ')}</i>:</h3>
  ${result.posts.map(post => createPostOutput(post))}
  `
);

export default results => (
  `
  <html>
    <head>
      <title>Your digest</title>
    </head>
    <body>
      ${results.map(result => createDigestSection(result)).join('')}
      <hr />
      <p>If you wish to unsubscribe please click <a href="http://${process.env.WEBSITE_LINK_URL}/?unsubscribe=true">here</a>.</p>
    </body>
  </html>
  `
);
