Skip to content

698 - Audio not showing to Editors#747

Open
nole2701 wants to merge 2 commits into
mainfrom
698-editors-no-audio
Open

698 - Audio not showing to Editors#747
nole2701 wants to merge 2 commits into
mainfrom
698-editors-no-audio

Conversation

@nole2701
Copy link
Copy Markdown
Collaborator

Merged "Document Audio" and "User-contributed audio" into one list.

Editors can see:

  • All audio
  • All publish checkboxes
  • Audio recorder component

Contributors can see:

  • All published audio
  • Audio they contributed (no publish checkbox)
  • Audio recorder component

Readers can see:

  • All published audio

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 25, 2026

Deploy Preview for dailp ready!

Name Link
🔨 Latest commit 507a76e
🔍 Latest deploy log https://app.netlify.com/projects/dailp/deploys/69ecd23e815ae80008a94b26
😎 Deploy Preview https://deploy-preview-747--dailp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@sarahkelley42
Copy link
Copy Markdown
Collaborator

Hello! Quick intro, I'm Sarah, and I'm getting acquainted with the DAILP codebase and onboarding via code reviews. Wanted to give you a heads up that I'll be taking a look at this one; I'll mostly be focused on asking questions and learning for now.

Copy link
Copy Markdown
Collaborator

@sarahkelley42 sarahkelley42 left a comment

Choose a reason for hiding this comment

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

Mostly asking questions at this moment as I'm growing my understanding of the codebase.

contributor={
audio.recordedBy?.id === userId
? "you"
: audio.recordedBy?.displayName
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If this evaluates to undefined or null, does AudioPlayer render correctly?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Right now if undefined is passed into AudioPlayer for contributor, the audio player still renders but it does not say who recorded the audio.

(audio, index) =>
audio.recordedBy?.id === userId && (
{role === UserRole.Contributor &&
(() => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Making sure I understand the structure correctly. Before, this would render:

  1. To non-Editors (presumably, Readers and Contributors): All edited audio (from p.doc.editedAudio) as <AudioPlayer>s
  2. To Contributors: All contributed audio (from p.doc.userContributedAudio, filtered by user ID) as <AudioPlayer>s in a subsequent section
  3. To Editors: All audio (from p.doc.userContributedAudio, unfiltered) as <DocumentAudioWithCurate>.

After, this will render:

  1. To Contributors: all contributed audio (from p.doc.userContributedAudio, filtered by userId), plus all edited audio (from p.doc.editedAudio), deduped by sliceId, as an <AudioPlayer>
  2. To Readers: all p.doc.editedAudio as <AudioPlayer>s
  3. To Editors: All p.doc.userContributedAudio plus p.doc.editedAudio, deduped by sliceId, rendered as <DocumentAudioWithCurate>

So the main behavioral difference here is that Editors now see editedAudio in addition to userContributedAudio. Readers' view is unchanged, and Contributors might see a different arrangement but will see the same set of audio as they saw before.

Is that understanding correct, and does it match the intent?

Copy link
Copy Markdown
Collaborator Author

@nole2701 nole2701 May 20, 2026

Choose a reason for hiding this comment

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

Before

  • Readers -> One section "Document Audio", rendering p.doc.editedAudio with the official audio + any approved audios. Just the AudioPlayer + download button, no curate checkboxes.
  • Contributors -> The same "Document Audio" section as readers, as well as a second section "User-contributed Audio" which shows only their own uploads, with no curate checkbox. Also the "Record Audio" panel
  • Editors -> Only the "User-contributed Audio" section, showing all user contributed audio with curate checkboxes for all of them. Also the "Record Audio" panel. No "Document Audio" section, so editors could not see the official audio

After

"User-contributed Audio" as a section was removed. Every audio now lives in "Document Audio"

  • Readers -> All published audio with no checkboxes and no recording section.
  • Contributors -> Same as Reader, but also your own uploads and the recording section.
  • Editors -> Shows all audio with curate checkboxes for all of them, and the recording section.

I worked with Cara to finalise what exactly we want it to look like and it seems like this is the intended result.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Cool cool. I think there may be opportunity to express these intents by extracting out a couple functions for the filters, and maybe have something mapping role -> filter, but I'm not totally sure what that would look like at this point. Seems like this does the intended thing.

Comment thread types/src/database_sql.rs
index: 0,
// TODO: is this a bad default?
include_in_edited_collection: true,
include_in_edited_collection: item.include_audio_in_edited_collection,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm assuming this is only impacting reads. Is the value for include_audio_in_edited_collection already set for everything in the database, or does this require migration/data entry?

Copy link
Copy Markdown
Collaborator Author

@nole2701 nole2701 May 20, 2026

Choose a reason for hiding this comment

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

It defaults to true.

image

{
"db_name": "PostgreSQL",
"query": "select\n d.id,\n d.short_name,\n d.title,\n d.is_reference,\n d.written_at,\n d.audio_slice_id,\n media_resource.url as \"audio_url?\",\n media_resource.recorded_at as \"recorded_at?\",\n dailp_user.id as \"recorded_by?\",\n dailp_user.display_name as \"recorded_by_name?\",\n media_slice.time_range as \"audio_slice?\",\n ubd.bookmarked_on as \"bookmarked_on?\",\n coalesce(\n jsonb_agg(\n jsonb_build_object(\n 'name', contributor.full_name, 'role', attr.contribution_role\n )\n ) filter (where contributor is not null),\n '[]'\n )\n as contributors\nfrom document as d\n left join contributor_attribution as attr on attr.document_id = d.id\n left join contributor on contributor.id = attr.contributor_id\n left join media_slice on media_slice.id = d.audio_slice_id\n left join media_resource on media_resource.id = media_slice.resource_id\n left join dailp_user on dailp_user.id = media_resource.recorded_by\n left join user_bookmarked_document as ubd on ubd.document_id = d.id\nwhere d.short_name = any($1)\ngroup by d.id,\n media_slice.id,\n media_resource.id,\n dailp_user.id,\n ubd.bookmarked_on\n",
"query": "select\n d.id,\n d.short_name,\n d.title,\n d.is_reference,\n d.written_at,\n d.audio_slice_id,\n d.include_audio_in_edited_collection,\n media_resource.url as \"audio_url?\",\n media_resource.recorded_at as \"recorded_at?\",\n dailp_user.id as \"recorded_by?\",\n dailp_user.display_name as \"recorded_by_name?\",\n media_slice.time_range as \"audio_slice?\",\n ubd.bookmarked_on as \"bookmarked_on?\",\n coalesce(\n jsonb_agg(\n jsonb_build_object(\n 'name', contributor.full_name, 'role', attr.contribution_role\n )\n ) filter (where contributor is not null),\n '[]'\n )\n as contributors\nfrom document as d\n left join contributor_attribution as attr on attr.document_id = d.id\n left join contributor on contributor.id = attr.contributor_id\n left join media_slice on media_slice.id = d.audio_slice_id\n left join media_resource on media_resource.id = media_slice.resource_id\n left join dailp_user on dailp_user.id = media_resource.recorded_by\n left join user_bookmarked_document as ubd on ubd.document_id = d.id\nwhere d.short_name = any($1)\ngroup by d.id,\n media_slice.id,\n media_resource.id,\n dailp_user.id,\n ubd.bookmarked_on\n",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Confirming my understanding: this JSON (query+the columns description below) looks like it's generated from the .sql files under types/queries. Is that correct?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

They're generated from the SQL queries that are embedded in the rust code. In that file you'll see multiple usages of query!, query_as!, query_file! etc that point to files in the types/queries directory. From my understanding, these files are a cache used for compile-time checking when the database is offline and unreachable.

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