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: adding organisations thumbnails to records #511

Merged
merged 4 commits into from
Jul 17, 2023
Merged

Conversation

f-necas
Copy link
Collaborator

@f-necas f-necas commented Jun 22, 2023

Organisations thumbnails are now visible in feed and datasets tabs.

If the organization strategy is set to metadata (default behaviour), matching is done on the organization name set in the contact property of the record.

Maybe the IMAGE_URL constant could be common in organisations-from-groups.service.ts and organisations-from-metadata.service.ts.

@fgravin @jahow @tkohr Tell me if this solution would be suitable.
Thanks :)

@f-necas f-necas requested review from fgravin, tkohr and jahow June 22, 2023 14:50
@github-actions
Copy link
Contributor

github-actions bot commented Jun 22, 2023

Affected libs: feature-catalog, feature-record, feature-router, feature-search, feature-map, feature-dataviz, ui-search, util-shared, feature-auth, ui-elements, ui-catalog, ui-widgets, feature-editor, ui-inputs, ui-map,
Affected apps: datahub, demo, webcomponents, metadata-editor, search, map-viewer, metadata-converter, datafeeder,

  • 🚀 Build and deploy storybook and demo on GitHub Pages
  • 📦 Build and push affected docker images

Copy link
Member

@fgravin fgravin left a comment

Choose a reason for hiding this comment

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

Looks good to me except the mandatory changes mentioned in the comments.

Overall, I would have some comments about the implementation from @jahow

  1. It's disturbing that we add duplicated contacts within the contacts & resourcesContact properties of the MetadataRecord objects. I wonder if we shouldn't clearly separate this concern with an organization property in the record.
  2. mapContact() could take an optional 3rd argument as the organization, for the group strategy, the group is mapped to the organisation first.
  3. The records should not have the catalog logo by default
  4. I think we should try to maintain a cache because the mapping between contacts & organisation + the hydration would be repeated a lot for nothing. Not in this PR though.

Overall the organisation domain object should raise above contacts/groups, we should just treat with organisations; contacts (for metadata) or groups (for group) should be mapped to an organisation and be forgotten.

): MetadataContact {
const logoUrl = getAsUrl(`${organisation.logoUrl}`)
return {
name: organisation.name[lang3],
Copy link
Member

Choose a reason for hiding this comment

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

contacts or not multilingual yet
multilingual index fields ends with Object eg organizationObject

]).pipe(
map(([record, organisations]) => {
const org = organisations.filter(
(o) => o.name === record.contact.organisation
Copy link
Member

Choose a reason for hiding this comment

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

resourceContact[0]

)[0]
if (org) {
const lang3 = LANG_2_TO_3_MAPPER[this.translateService.currentLang]
record.contact = this.mapContactFromOrganisation(org, lang3)
Copy link
Member

Choose a reason for hiding this comment

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

avoid object mutation

Copy link
Collaborator

@jahow jahow left a comment

Choose a reason for hiding this comment

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

Just looked through quickly but I think the approach is good since it's only touching the orgs-from-metadata implementation 🙂

@jahow
Copy link
Collaborator

jahow commented Jun 22, 2023

  1. It's disturbing that we add duplicated contacts within the contacts & resourcesContact properties of the MetadataRecord objects. I wonder if we shouldn't clearly separate this concern with an organization property in the record.

Yes clearly the record format is awkward on that part. I think we should address that in the pivot format and not overthink it with the current MetadataRecord format though.

  1. mapContact() could take an optional 3rd argument as the organization, for the group strategy, the group is mapped to the organisation first.

I feel like simply adding a 3rd optional argument would be a work around for something missing elsewhere, but not really sure about this.

  1. The records should not have the catalog logo by default

I think that's the point of this PR, display the thumbnail if any and display the contact logo otherwise. Or am I missing something? Maybe we shouldn't overwrite any existing logo on the record?

  1. I think we should try to maintain a cache because the mapping between contacts & organisation + the hydration would be repeated a lot for nothing. Not in this PR though.

Why not but in my understanding the contacts in the raw metadata can have many different forms and the method used to match with the groups use several fields. We can't just maintain a map between an org email and a group for example; the mapping could use a combination of the org fields (name, email...). But I also think that this concern would be "premature optimization": the hydration happens maybe at most twenty times in a row when showing the records list, and I don't think this is going to be noticeable in any way.

@fgravin
Copy link
Member

fgravin commented Jun 22, 2023

I think that's the point of this PR, display the thumbnail if any and display the contact logo otherwise. Or am I missing something? Maybe we shouldn't overwrite any existing logo on the record?

ATM it uses the metadata.logo which is the catalog logo, and not the organization logo, so yes it could make sense as the third choice for the thumbnail.
Actually i haven't checked where the metadata logo comes from, probably from the source, which means that geo2france should have logos instead of blank images (because they use harvester sources) ... anyway

@fgravin
Copy link
Member

fgravin commented Jun 23, 2023

I feel like simply adding a 3rd optional argument would be a work around for something missing elsewhere, but not really sure about this.

Thinking about this and the issue is more about the confusion between contact & orgs.
The mapper and atomic-operations are just responsible for mapping the index to our model, at least it should be. Once we are hydrating this model from other sources (other than the index, eg. groups/orgs), then we overextend the responsibility of the mapper IMO.
And the question raised again: should we extend metadata informations from other sources (eg contacts from orgs/groups), or shall we add new properties in the record (eg organisations).

@f-necas
Copy link
Collaborator Author

f-necas commented Jun 23, 2023

And the question raised again: should we extend metadata informations from other sources (eg contacts from orgs/groups), or shall we add new properties in the record (eg organisations).

For me, I think it would be clearer if we edit the MetadataRecord interface with something like :

export interface MetadataRecord {
  id: string
  ...
  contact?: MetadataContact
  resourceContacts?: MetadataContact[]
  organisation?: Organisation
  ...
}

but this doesn't match XML format ...

What if we create an ExtendedMetadateRecord interface ?

export interface ExtendedMetadataRecord {
  record: MetadataRecord
  organisation?: Organisation
}

remove untranslated organisation name fields, improving addOrganisationToRecordFromSource without forkJoin, alter mapLogo to not use the record logo for a contact
@f-necas f-necas marked this pull request as ready for review July 6, 2023 09:32
@fgravin
Copy link
Member

fgravin commented Jul 11, 2023

It's not clear in the US, but to me the rules are

  1. use record thumbnail if present
  2. if not, use organization logo if present
  3. if not, use placeholder

@f-necas
Copy link
Collaborator Author

f-necas commented Jul 11, 2023

It's not clear in the US, but to me the rules are

  1. use record thumbnail if present
  2. if not, use organization logo if present
  3. if not, use placeholder

It's conflicting what @jahow told me : Keeping catalog logo if org logo is not present for the feed.
For the feed, organisation logo is set with org.logo or record.logo (which is catalog logo in the index).
For the search, we take record thumbnail or organisation logo ( so it takes catalog logo if none present ).

@fgravin Can you confirm that we won't use record logo (catalog's logo) for organisation logo ? It will change actual display of logos in the feed preview

@fgravin
Copy link
Member

fgravin commented Jul 11, 2023

@fgravin Can you confirm that we won't use record logo (catalog's logo) for organisation logo ? It will change actual display of logos in the feed preview

Ok, to me this is the kind of things to be discussed with Geo2France/MEL, but you can go as @jahow told you for now.
Keep using catalog logo as a fallback.
Thanks

@fgravin fgravin self-assigned this Jul 13, 2023
Copy link
Member

@fgravin fgravin left a comment

Choose a reason for hiding this comment

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

Thanks for adding the missing behavior of hydrating the records with the organisation details.
Works well, but it lacks of tests. You should test the hydration.

I still have a weird behavior (which is expected), i have an org with a logo in the organization tab, when i click on it, the metadata in the result list has the catalog logo instead of the org one (because the organisation is the second resourceContact). Actually, having several resourceContact breaks a bit the approch we have, because the record does not have only one organisation, anyway.

Feel free to merge after adding a test.
Thanks, great work

check if record collect the right logo/thumbnail
@f-necas f-necas merged commit 0c09970 into main Jul 17, 2023
8 checks passed
@f-necas f-necas deleted the org-thumbnail branch July 17, 2023 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Proposal for a new feature minor feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants