Skip to content

Commit

Permalink
Merge branch 'dependabot/npm_and_yarn/markdown-it-attrs-4.3.0' of git…
Browse files Browse the repository at this point in the history
…hub.com:GSA/datagov-11ty into dependabot/npm_and_yarn/markdown-it-attrs-4.3.0
  • Loading branch information
btylerburton committed Dec 11, 2024
2 parents f1ea44f + 94db32f commit 8374d15
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 25 deletions.
8 changes: 8 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ module.exports = function (config) {
pathPrefix = process.env.BASEURL;
}

// add a liquid filter to separate numbers with commas
config.addLiquidFilter('toLocaleString', (string) => {
if (!isNaN(string)) {
string = parseFloat(string);
}
return string.toLocaleString('en', { useGrouping: true });
});

// Set image shortcodes
config.addLiquidShortcode('download', downloadShortCode);
config.addLiquidShortcode('image', imageShortcode);
Expand Down
18 changes: 16 additions & 2 deletions _data/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ const REPORTS = {
url: "global__device_category__last30.[end_date].csv",
columnKeys: ["deviceCategory", "activeUsers", "percentage"]
},
MOST_DOWNLOADED_DATASETS: {
title: "Most Downloaded Dataset Files",
description: "Top 10 downloaded files",
url: "global__download_requests__last30.[end_date].csv",
columnKeys: ["linkUrl", "eventCount"]
},
MOST_CLICKED_OUTBOUND_LINKS: {
title: "Most Clicked Outbound Links",
description: "Top 10 external link clicks",
url: "global__link_requests__last30.[end_date].csv",
columnKeys: ["linkUrl", "eventCount"]
},
DATASETS_PER_ORG: {
title: "Number of Datasets per Organization",
description: "Count of datasets by organization",
Expand All @@ -36,6 +48,7 @@ const REPORTS = {
url: "global__harvest_sources.[end_date].csv",
columnKeys: ["organization", "count"]
}

},
// ORG is a meta constructor for orgs
ORG: {
Expand All @@ -49,13 +62,13 @@ const REPORTS = {
title: "Most Downloaded Dataset Files",
description: "Top 10 downloaded files from dataset pages",
url: "download_requests__last30.[end_date].csv",
columnKeys: ["linkUrl", "eventCount"]
columnKeys: ["linkUrl", "pageTitle", "eventCount"]
},
MOST_CLICKED_OUTBOUND_LINKS: {
title: "Most Clicked Outbound Links",
description: "Top 10 external link clicks from dataset pages",
url: "link_requests__last30.[end_date].csv",
columnKeys: ["linkUrl", "eventCount"]
columnKeys: ["linkUrl", "pageTitle", "eventCount"]
}
}
}
Expand All @@ -64,6 +77,7 @@ const ENUMS = {
"deviceCategory": "Device Category",
"activeUsers": "Users",
"searchTerm": "Search Term",
"pageTitle": "Title",
"eventCount": "Count",
"organization": "Organization",
"count": "Count",
Expand Down
17 changes: 8 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
"@11ty/eleventy-navigation": "^0.3.5",
"@11ty/eleventy-plugin-rss": "^2.0.2",
"@quasibit/eleventy-plugin-sitemap": "^2.2.0",
"@types/node": "^22.10.0",
"@types/node": "^22.10.1",
"autoprefixer": "^10.4.20",
"chokidar-cli": "^3.0.0",
"cypress": "^13.16.0",
"cypress": "^13.16.1",
"dotenv": "^16.4.5",
"eleventy-plugin-svg-sprite": "^2.4.2",
"esbuild": "^0.24.0",
Expand Down
24 changes: 13 additions & 11 deletions pages/metrics/metrics.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h6 class="usa-heading">Report Date: {{ metrics.end_date}} </h6>
<div class="grid-row grid-gap-lg {{cacheKey}}">
<div class="grid-col-12">
<h4>{{block.meta.title}}</h4>
<h3>{{ block.data[1] }}</h3>
<h3>{{ block.data[1] | toLocaleString }}</h3>
</div>
</div>
<div class="mt-3"></div>
Expand Down Expand Up @@ -84,17 +84,19 @@ <h4>{{block.meta.title}}</h4>
{% for row in block.data offset:1 %}
<tr>
{% for column in row %}
{%- if block.meta.columnKeys contains block.data[0][forloop.index0] -%}
{%- if forloop.first -%}
{%- if cacheKey == "DATASETS_PER_ORG" or cacheKey == "HARVEST_SOURCES_PER_ORG" -%}
<td><a href="{{helpers.baseUrl}}/metrics/organization/{{column}}/index.html">{{metrics.orgDict[column]}}</a></td>
{%- else -%}
<td>{{column}}</td>
{%- if block.meta.columnKeys contains block.data[0][forloop.index0] -%}
{%- if forloop.first -%}
{%- if cacheKey == "DATASETS_PER_ORG" or cacheKey == "HARVEST_SOURCES_PER_ORG" -%}
<td><a href="{{helpers.baseUrl}}/metrics/organization/{{column}}/index.html">{{metrics.orgDict[column]}}</a></td>
{%- elsif cacheKey == "MOST_DOWNLOADED_DATASETS" or cacheKey == "MOST_CLICKED_OUTBOUND_LINKS" -%}
<td><a href="{{column}}">{{column}}</a></td>
{%- else -%}
<td>{{column}}</td>
{%- endif -%}
{%- else -%}
<td align="right">{{column | toLocaleString}}</td>
{%- endif -%}
{%- endif -%}
{%- else -%}
<td>{{column}}</td>
{%- endif -%}
{%- endif -%}
{% endfor %}
</tr>
{% endfor %}
Expand Down
9 changes: 8 additions & 1 deletion pages/metrics/metrics_per-org.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ <h4>{{block.meta.title}}</h4>
{%- endif -%}

{%- else -%}
<td>{{column}}</td>
{%- assign pageURL = 5 -%}
{%- if block.data[0][forloop.index0] == "pageTitle" -%}
<td align="right">
<a href="{{row[pageURL]}}" target="_blank">{{column | toLocaleString | replace: " - Catalog", ""}}</a>
</td>
{%- else -%}
<td align="right">{{column | toLocaleString}}</td>
{%- endif -%}
{%- endif -%}
{%- endif -%}
{% endfor %}
Expand Down

0 comments on commit 8374d15

Please sign in to comment.