Skip to content
29 changes: 23 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
version: 2

multi-ecosystem-groups:
dependencies:
schedule:
interval: "monthly"

updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
patterns:
- "*"
multi-ecosystem-group: "dependencies"
cooldown:
default-days: 7

- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
patterns:
- "*"
multi-ecosystem-group: "dependencies"
cooldown:
default-days: 7

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
patterns:
- "*"
multi-ecosystem-group: "dependencies"
cooldown:
default-days: 7
10 changes: 6 additions & 4 deletions .github/workflows/test-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ jobs:
temporaryPublicStorage: true # upload lighthouse report to the temporary storage

- name: Deploy to Firebase Hosting Preview Channel
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]'
if: |
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository &&
github.actor != 'dependabot[bot]'
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
Expand Down Expand Up @@ -98,10 +101,9 @@ jobs:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Enable auto-merge for Dependabot PRs
if: |
steps.metadata.outputs.update-type == 'version-update:semver-patch' ||
steps.metadata.outputs.update-type == 'version-update:semver-minor'
if: steps.metadata.outputs.update-type != 'version-update:semver-major'
run: gh pr merge --squash --auto "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

64 changes: 38 additions & 26 deletions src/js/components/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import { DataUtils } from "../techreport/utils/data";

class Filters {
constructor(filterData, filters) {
this.categories = filterData?.categories;
this.technologies = filterData?.technologies;
this.geos = filterData?.geos;
this.ranks = filterData?.ranks;
this.categories = Array.isArray(filterData?.categories) ? filterData.categories : [];
this.technologies = Array.isArray(filterData?.technologies) ? filterData.technologies : [];
this.geos = Array.isArray(filterData?.geos) && filterData.geos.length > 0
? filterData.geos
: [{ geo: 'ALL' }];
this.ranks = Array.isArray(filterData?.ranks) && filterData.ranks.length > 0
? filterData.ranks
: [{ rank: 'ALL' }];

this.filters = filters;

Expand Down Expand Up @@ -152,37 +156,45 @@ class Filters {
/* Update the list with geographies */
updateGeo() {
const select = document.querySelector('select#geo');
if (!select) return;
select.innerHTML = '';
const normalizedFilter = decodeURIComponent(this.filters.geo || '').trim();
this.geos.forEach((geo) => {
const optionTmpl = document.getElementById('filter-option').content.cloneNode(true);
const option = optionTmpl.querySelector('option');
const formattedTech = geo.geo;
option.textContent = geo.geo;
option.value = formattedTech;
if(formattedTech === this.filters.geo || formattedTech === normalizedFilter) {
option.selected = true;
}
select.append(optionTmpl);
});
if (Array.isArray(this.geos)) {
this.geos.forEach((geo) => {
const optionTmpl = document.getElementById('filter-option')?.content?.cloneNode(true);
if (!optionTmpl) return;
const option = optionTmpl.querySelector('option');
const formattedTech = geo.geo;
option.textContent = geo.geo;
option.value = formattedTech;
if(formattedTech === this.filters.geo || formattedTech === normalizedFilter) {
option.selected = true;
}
select.append(optionTmpl);
});
}
}

/* Update the list with ranks */
updateRank() {
const select = document.querySelector('select#rank');
if (!select) return;
select.innerHTML = '';
const normalizedFilter = decodeURIComponent(this.filters.rank || '').trim();
this.ranks.forEach((rank) => {
const optionTmpl = document.getElementById('filter-option').content.cloneNode(true);
const option = optionTmpl.querySelector('option');
const formattedTech = rank.rank;
option.textContent = rank.rank;
option.value = formattedTech;
if(formattedTech === this.filters.rank || formattedTech === normalizedFilter) {
option.selected = true;
}
select.append(optionTmpl);
});
if (Array.isArray(this.ranks)) {
this.ranks.forEach((rank) => {
const optionTmpl = document.getElementById('filter-option')?.content?.cloneNode(true);
if (!optionTmpl) return;
const option = optionTmpl.querySelector('option');
const formattedTech = rank.rank;
option.textContent = rank.rank;
option.value = formattedTech;
if(formattedTech === this.filters.rank || formattedTech === normalizedFilter) {
option.selected = true;
}
select.append(optionTmpl);
});
}
}

/* Update the list with categories */
Expand Down
17 changes: 14 additions & 3 deletions src/js/techreport/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,20 @@ class TechReport {
const url = `${Constants.apiBase}/${api.endpoint}`;

return fetch(url)
.then(result => result.json())
.then(result => filterData[api.name] = result)
.catch(error => console.log('Something went wrong', error));
.then(result => {
if (!result.ok) {
console.warn(`Failed to fetch ${api.name}: ${result.status}`);
return [];
}
return result.json();
})
.then(result => {
filterData[api.name] = Array.isArray(result) ? result : [];
})
.catch(error => {
console.warn('Something went wrong fetching filter data', error);
filterData[api.name] = [];
});
})).then(() => {
const FilterComponent = new Filters(filterData, this.filters);

Expand Down
Loading