Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add uk stores #455

Merged
merged 15 commits into from Oct 6, 2020
Merged

feat: add uk stores #455

merged 15 commits into from Oct 6, 2020

Conversation

andrewmackrodt
Copy link
Contributor

@andrewmackrodt andrewmackrodt commented Oct 5, 2020

Relates to #461 - merge second

This adds 10 UK stores, I've not added maxPrice yet but plan to do so in a future PR. andrewmackrodt/nvidia-snatcher@pr-framework-updates...pr-uk-stores

Copy link
Owner

@jef jef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wowa wowa. It looks great. Thanks for putting in this work. You're on the hunt for that card 😎

name = name.replace(/\bgraphics card\b/gi, '').trim();
name = name.replace(/\b\w+ fan\b/gi, '').trim();
name = name.replace(/\s{2,}/g, ' ');
name = name.replace(/\w+-\w+-[^ ]+/g, '');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow 😮 Nice work!

url: 'https://www.amazon.co.uk/dp/B081265T5Z/'
}
],
linksBuilder: {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine we could use this for the other Amazon stores, but could be very wrong there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine the builder function would work between stores, but determining the urls[].url[] would require a manual map per region. At a minimum, the following may work (not tested it compiles let alone works):

function getAmazonQueryString(search: string, categoryId: number, includeOutOfStockId: number) {
    return [
        `k=${encodeURIComponent(search)}`,
        'rh=' + encodeURIComponent([
            `n:${categoryId}`,
            `p_n_availability:${includeOutOfStockId}`
        ].join(','))
    ].join('&');
}

// Note: hardcoded amazon.co.uk details
const queryString = getAmazonQueryString('+"RTX 3080" -2080 -GTX', 430500031, 419162031);
const domain = 'www.amazon.co.uk';
const url = `https://${domain}/s?${queryString}`;

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense to me. Maybe we can bring this in at a later point. Thanks for checking this out.

@jef
Copy link
Owner

jef commented Oct 5, 2020

We can break this into 2 different PRs or commits squashed into the 2 units once approved.

No problem. I don't mind it in both.

@andrewmackrodt
Copy link
Contributor Author

andrewmackrodt commented Oct 5, 2020

You're on the hunt for that card

I actually snagged a 3080 the same night/morning nvidia made the API changes but trying to do what little I can to help others get their cards :)

@jef
Copy link
Owner

jef commented Oct 5, 2020

We all appreciate your contribution ❤️

@andrewmackrodt
Copy link
Contributor Author

@jef I've split the first changset into #461 and will rebase this PR on top of main once that one's merged.

Copy link
Owner

@jef jef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for all this hard work!

url: 'https://www.amazon.co.uk/dp/B081265T5Z/'
}
],
linksBuilder: {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense to me. Maybe we can bring this in at a later point. Thanks for checking this out.

@jef jef merged commit b9b6b55 into jef:main Oct 6, 2020
@andrewmackrodt andrewmackrodt deleted the pr-uk-stores branch October 6, 2020 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants