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

Create API for map pins search #3955

Merged
merged 10 commits into from
Oct 30, 2024

Conversation

goratt12
Copy link
Collaborator

PR Checklist

PR Type

What kind of change does this PR introduce?

  • Bugfix (fixes an issue)
  • Feature (adds functionality)
  • Code style update
  • Refactoring (no functional changes)
  • Build related changes
  • CI related changes
  • Documentation changes
  • Other... Please describe:

What is the current behavior?

map pins fetched from the old API (platfrom-api)

What is the new behavior?

map pins is fetching using Remix backend API

Does this PR introduce a breaking change?

  • Yes
  • No

Git Issues

Closes #3916

What happens next?

Thanks for the contribution! We try to make sure all PRs are reviewed ahead of our monthly maintainers call (first Monday of the month)

If the PR is working as intended it'll be merged and included in the next platform release, if not changes will be requested and re-reviewed once updated.

If you need more immediate feedback you can try reaching out on Discord in the Community Platform development channel.

Copy link

cypress bot commented Oct 25, 2024

onearmy-community-platform    Run #6479

Run Properties:  status check passed Passed #6479  •  git commit a6768f09e1: fix: fixed lint issues
Project onearmy-community-platform
Branch Review pull/3955
Run status status check passed Passed #6479
Run duration 05m 24s
Commit git commit a6768f09e1: fix: fixed lint issues
Committer unknown
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 1
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 75
View all changes introduced in this branch ↗︎

@goratt12 goratt12 marked this pull request as ready for review October 30, 2024 13:44
@goratt12 goratt12 requested a review from a team as a code owner October 30, 2024 13:44
// taken from platform-api
async function getUserProfile(userId) {
const collectionRef1 = collection(firestore, DB_ENDPOINTS.users)
const usersQuery1 = query(collectionRef1, where('_authId', '==', userId))
Copy link
Contributor

Choose a reason for hiding this comment

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

@benfurber do you know why we need to query for _authId?

Copy link
Member

Choose a reason for hiding this comment

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

I believe _authId relates to the auth stuff which is linked to a user recond on sign-up. Not sure why it's needed here...

// check if cached map pins are availbe, if not - load from db and cache them
if (cachedMappins) {
return json({ mapPins: cachedMappins })
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

no need the else since the if returns

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed :)

return queryResults1.docs[0].data()
}

const collectionRef2 = collection(firestore, DB_ENDPOINTS.users)
Copy link
Contributor

Choose a reason for hiding this comment

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

if querying for _authId is really needed, the collection is the same, so we don't need a "collectionRef2"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed :)

Comment on lines 81 to 82
const usersQuery2 = query(collectionRef2, where('_id', '==', userId))
const queryResults2 = await getDocs(usersQuery2)
Copy link
Contributor

@mariojsnunes mariojsnunes Oct 30, 2024

Choose a reason for hiding this comment

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

if querying for _authId is really needed, can still make the code more readable:

const usersCollection = collection(firestore, DB_ENDPOINTS.users);
const usersByAuthId = await getDocs(query(usersCollection, where('_authId', '==', userId)));
const usersById = await getDocs(query(usersCollection, where('_id', '==', userId)));

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed :)

@mariojsnunes mariojsnunes merged commit 32eb2ad into ONEARMY:master Oct 30, 2024
18 of 19 checks passed
@onearmy-bot
Copy link
Collaborator

🎉 This PR is included in version 2.10.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[feature request] Create API for map pins search
4 participants