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

Low search accuracy for people #5722

Open
pacyL2K19 opened this issue Jun 4, 2024 · 2 comments · May be fixed by #5786
Open

Low search accuracy for people #5722

pacyL2K19 opened this issue Jun 4, 2024 · 2 comments · May be fixed by #5786
Labels
type: bug Something isn't working

Comments

@pacyL2K19
Copy link
Contributor

Bug Description

Currently, when searching for people in any filter (ex: search for POC in the opportunity page), the search accuracy seems low in some scenarios

Example:

In the screenshots below, I am searching for Anthony May how exists in the people list, and the same company as this opportunity, but he doesn't appear on top of the list while being the perfect match to my query(screenshot 1). But if I scroll way down below, I can see the person (screenshot 2)

Screenshot 2024-06-04 at 10 17 19
Screenshot 2024-06-04 at 10 17 50

Expected behavior

The search should be accurate and display the best match on top

Example:

In the example above, Anthony May should appear on top of the list, followed by the rest with less accuracy

Technical inputs

N/A

@pacyL2K19 pacyL2K19 added the type: bug Something isn't working label Jun 4, 2024
Copy link

greptile-apps bot commented Jun 4, 2024

Disclaimer: This comment was automatically generated with AI. It can give some useful hints as to where to look for, but sometimes it can also give very inaccurate answers so takes this with a pinch of salt :).

To improve search accuracy for people, follow these steps:

  1. Update Search Query: Modify the FIND_PERSON query in /packages/twenty-chrome-extension/src/graphql/person/queries.ts to include sorting logic.
export const FIND_PERSON = gql`
  query FindPerson($filter: PersonFilterInput) {
    people(filter: $filter, sort: { field: "name", order: ASC }) {
      edges {
        node {
          firstName
          lastName
          linkedinUrl
          label
        }
      }
    }
  }
`;
  1. Enhance Search Function: Update the fetchPerson function in /packages/twenty-chrome-extension/src/db/person.db.ts to handle the new sorting logic.
export async function fetchPerson(personFilterData: PersonFilterInput): Promise<Person | null> {
  const { data } = await callQuery(FIND_PERSON, { filter: personFilterData });
  if (data.people.edges.length > 0) {
    return data.people.edges[0].node;
  }
  return null;
}
  1. Adjust Mock Data: Ensure the mock data in /packages/twenty-front/src/testing/graphqlMocks.ts reflects the new sorting logic for accurate testing.
export const mockedPeopleData = [
  {
    firstName: 'Anthony',
    lastName: 'May',
    linkedinUrl: 'https://linkedin.com/in/anthonymay',
    label: 'POC',
  },
  // other mock data
];
  1. Update Storybook: Modify the story in /packages/twenty-front/src/pages/object-record/__stories__/RecordShowPage.stories.tsx to test the new search functionality.
export const Default = Template.bind({});
Default.play = async ({ canvasElement }) => {
  const canvas = within(canvasElement);
  const searchInput = await canvas.getByPlaceholderText('Search...');
  await userEvent.type(searchInput, 'Anthony May');
  const result = await canvas.findByText('Anthony May');
  expect(result).toBeInTheDocument();
};

References

/packages/twenty-front/src/testing/graphqlMocks.ts
/packages/twenty-chrome-extension/src/graphql/person/queries.ts
/packages/twenty-front/src/pages/object-record/stories/RecordShowPage.stories.tsx
/packages/twenty-chrome-extension/src/db/person.db.ts
/packages/twenty-chrome-extension/src/contentScript/extractPersonProfile.ts
/packages/twenty-front/src/modules/object-record/relation-picker/components/stories/SingleEntitySelect.stories.tsx
/packages/twenty-chrome-extension/src/graphql/person
/packages/twenty-server/src/core/api-rest/api-rest.controller.utils.spec.ts
/packages/twenty-server/src/workspace/workspace-manager/demo-objects-prefill-data/person.ts
/packages/twenty-front/src/pages/opportunities/stories/Opportunities.stories.tsx

Ask Greptile

@FelixMalfait
Copy link
Member

Yes this is a tricky one, not an easy fix

See a related comment #3708 (comment)

@shashankvish0010 shashankvish0010 linked a pull request Jun 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
Status: 🆕 New
Development

Successfully merging a pull request may close this issue.

2 participants