Skip to content

Commit 214a301

Browse files
Update data sources for projects until 2024-04-24 and correct mapping of projects by name from HubSpot (#58)
1 parent 7db7055 commit 214a301

File tree

6 files changed

+447
-56
lines changed

6 files changed

+447
-56
lines changed

src/lib/config/data/donate.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ projects:
33
slug: spyder
44
image: /assets/media/spyder_splash_bg.webp
55
donationLinkID: Pjm6SyqYNb
6-
pastDonations: 19144
6+
pastDonations: 15744
77
- id: 1
88
slug: code-completions
99
image: /assets/media/donations-code_completions.webp

src/lib/i18n/en-US/donate.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ page:
1313
projects:
1414
- id: 0
1515
title: Support Spyder
16-
collected: Raised so far
16+
collected: Current balance
1717
separator: of
1818
intro: >-
1919
Do you want to support the Spyder project as a whole, with the money used where it is needed most? Donate here!

src/routes/donate/+page.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,27 @@ export async function load({ fetch }) {
2323
};
2424
});
2525

26+
// Create a mapping of common terms in deal names to project slugs
27+
const dealNameToSlugMap = {
28+
"spyder": ["spyder"],
29+
"code-completions": ["code completion", "smarter code"],
30+
"new-viewer-pane": ["viewer pane", "new viewer"],
31+
"syntax-highlighting": ["syntax highlight", "syntax-highlight"],
32+
"variable-explorer-improvements": ["variable explorer", "level-up the variable"]
33+
};
34+
2635
// Sort deals into their respective projects
2736
hubspotData.pipelineDeals.forEach((deal) => {
37+
const dealNameLower = deal.properties.dealname.toLowerCase();
38+
39+
// Check each project for potential matches
2840
content.props.projects.forEach((project) => {
29-
// Replace hyphens with spaces for comparison
30-
const projectNameForComparison = project.slug.toLowerCase().replace(/-/g, ' ');
31-
if (deal.properties.dealname.toLowerCase().includes(projectNameForComparison)) {
41+
const possibleMatches = dealNameToSlugMap[project.slug] || [project.slug.replace(/-/g, ' ')];
42+
43+
// Check if any of the possible matches are in the deal name
44+
const isMatch = possibleMatches.some(match => dealNameLower.includes(match.toLowerCase()));
45+
46+
if (isMatch) {
3247
projectDonations[project.slug].deals.push(deal);
3348
projectDonations[project.slug].total +=
3449
parseFloat(deal.properties.amount) || 0;

src/routes/donate/[slug]/+page.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,32 @@ export async function load({ params, fetch }) {
3636
oneTime: 0,
3737
};
3838

39+
// Create a mapping of common terms in deal names to project slugs
40+
const dealNameToSlugMap = {
41+
"spyder": ["spyder"],
42+
"code-completions": ["code completion", "smarter code"],
43+
"new-viewer-pane": ["viewer pane", "new viewer"],
44+
"syntax-highlighting": ["syntax highlight", "syntax-highlight"],
45+
"variable-explorer-improvements": ["variable explorer", "level-up the variable"]
46+
};
47+
48+
// Get the possible matches for this project's slug
49+
const possibleMatches = dealNameToSlugMap[project.slug] || [project.slug.replace(/-/g, ' ')];
50+
3951
// Get deals for this project
4052
hubspotData.pipelineDeals.forEach((deal) => {
41-
// Replace hyphens with spaces for comparison
42-
const projectNameForComparison = project.slug.toLowerCase().replace(/-/g, ' ');
43-
if (
44-
deal.properties.dealname.toLowerCase().includes(
45-
projectNameForComparison
46-
)
47-
) {
53+
const dealNameLower = deal.properties.dealname.toLowerCase();
54+
55+
// Check if any of the possible matches are in the deal name
56+
const isMatch = possibleMatches.some(match => dealNameLower.includes(match.toLowerCase()));
57+
58+
if (isMatch) {
4859
projectDonations.deals.push(deal);
4960
const amount = parseFloat(deal.properties.amount) || 0;
5061
projectDonations.total += amount;
5162

5263
// Separate monthly and one-time donations
53-
if (deal.properties.dealname.toLowerCase().includes("monthly")) {
64+
if (dealNameLower.includes("monthly")) {
5465
projectDonations.monthly += amount;
5566
} else {
5667
projectDonations.oneTime += amount;

static/data/github-contributors.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"type": "User",
2020
"user_view_type": "public",
2121
"site_admin": false,
22-
"contributions": 14409
22+
"contributions": 14428
2323
},
2424
{
2525
"login": "dalthviz",
@@ -41,7 +41,7 @@
4141
"type": "User",
4242
"user_view_type": "public",
4343
"site_admin": false,
44-
"contributions": 2465
44+
"contributions": 2471
4545
},
4646
{
4747
"login": "PierreRaybaut",
@@ -129,7 +129,7 @@
129129
"type": "User",
130130
"user_view_type": "public",
131131
"site_admin": false,
132-
"contributions": 943
132+
"contributions": 985
133133
},
134134
{
135135
"login": "jnsebgosselin",
@@ -305,7 +305,7 @@
305305
"type": "User",
306306
"user_view_type": "public",
307307
"site_admin": false,
308-
"contributions": 292
308+
"contributions": 297
309309
},
310310
{
311311
"login": "hlouzada",
@@ -371,7 +371,7 @@
371371
"type": "User",
372372
"user_view_type": "public",
373373
"site_admin": false,
374-
"contributions": 168
374+
"contributions": 176
375375
},
376376
{
377377
"login": "bcolsen",
@@ -503,7 +503,7 @@
503503
"type": "User",
504504
"user_view_type": "public",
505505
"site_admin": false,
506-
"contributions": 94
506+
"contributions": 95
507507
},
508508
{
509509
"login": "dhoegh",

0 commit comments

Comments
 (0)