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

[wip] Import display name from orderly custom metadata, store it in proxy DB, and display it #142

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

david-mears-2
Copy link
Contributor

@david-mears-2 david-mears-2 commented Nov 25, 2024

In this branch there's a new packet group in demos, since none of the existing ones were making use of the description.display_name orderly property.

That property is referenced during the scheduled job that imports packets into the proxy db, so that the column 'display_name' is being used for the first time. When there's no display name, it defaults to the name.

Then, the home page / packet group index page is now able to display the display name for a packit group, which is found by the API looking up the latest display name at the same time as it looks up the latest ID and latest time.

Future iterations:

  • Be able to filter packets/groups by their display_name, not just their name
  • Display the display name on the packet group summary page (PacketGroup.tsx)
  • Display the display name on the packet page and subpages (PacketHeader.tsx)

Copy link

codecov bot commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.25%. Comparing base (10e5546) to head (7838952).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #142   +/-   ##
=======================================
  Coverage   97.25%   97.25%           
=======================================
  Files         131      131           
  Lines        1238     1238           
  Branches      346      346           
=======================================
  Hits         1204     1204           
  Misses         33       33           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@david-mears-2 david-mears-2 changed the title [wip] Import display name from orderly custom data -> description property [wip] Import display name from orderly custom metadata, store it in proxy DB, and display it Nov 25, 2024
Comment on lines 48 to 54
private fun getDisplayNameForPacket(packet: OutpackMetadata): String {
val metadata = outpackServerClient.getMetadataById(packet.id)
val orderlyMetadata = metadata?.custom?.get("orderly") as? Map<*, *>
val description = orderlyMetadata?.get("description") as? Map<*, *>
return description?.get("display") as? String ?: packet.name
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm surprised you need to do this - is the custom metadata not already in the metadata being returned for all new packets in line 59? If it's not it should be. Maybe it is but those values ujust aren't being passed out by getMetadata? We shouldn't need to do a new call to the client per packet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does seem inefficient doesn't it. Line 59 corresponds to calling /packit/metadata on the outpack server, which returns only id, name, parameters, and time, contrary to the documentation of outpack server: mrc-ide/outpack_server#68

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So we'll change the outpack server

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed outpack server in mrc-ide/outpack_server#69

@@ -15,6 +15,7 @@ export const PacketTable = () => {
const { packetName } = useParams();
const [pageNumber, setPageNumber] = useState(0);

// Rename useGetPacketGroups to useGetPacketGroupPages, and packetGroups to packetGroupPages?
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When you iterate over those things, the elements aren't packet groups, they are pages of packet groups. So later in the file we have eg 'packetGroups.first' which looks like it means 'the first packet group' but actually means 'the first page of packet groups'.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I mistook this file for being PacketGroupSummaryList.tsx. In fact, each item returned by useGetPacketGroups (each so-called packetGroup) is a page of packets, not a packet group nor a page of packet groups. So these things should be renamed to useGetPacketPages and packetPages respectively.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

or more simply, useGetPackets and pages

@david-mears-2
Copy link
Contributor Author

I wonder if we have any CI checks designed to notice when test coverage is too low -- I know my last commit is changing a lot of things that demand new unit tests!

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

Successfully merging this pull request may close these issues.

2 participants