Skip to content

Conversation

nitrosx
Copy link
Member

@nitrosx nitrosx commented Aug 20, 2025

Description

This PR removes the custom function to extract the run number from the scientific metadata with hard coded key name. It instead uses the dedicated high level field run_number recently added in the dataset schema.

SciCat_dataset_run_number_fix_1 SciCat_dataset_run_number_fix_2

Motivation

We need to show run number high level field by default. A soon to be created PR, will allow to include scientific metadata in the datasets list, so a different run number from scientific metadata will be addressed by the new PR.

Changes:

Please provide a list of the changes implemented by this PR

  • datasets table

Tests included

  • Included for each change/fix?
  • Passing? (Merge will not be approved unless this is checked)

Documentation

  • swagger documentation updated [required]
  • official documentation updated [nice-to-have]

official documentation info

If you have updated the official documentation, please provide PR # and URL of the pages where the updates are included

Backend version

  • Does it require a specific version of the backend
  • which version of the backend is required:

Summary by Sourcery

Fix run number display in the dataset list by removing the custom scientific metadata fallback and using the high-level runNumber field, add localization of table headers, and standardize translation namespaces across dataset components.

Bug Fixes:

  • Use the high-level runNumber field for the dataset list instead of the scientificMetadata fallback

Enhancements:

  • Inject TranslateService to translate dataset table column headers using the "dataset" namespace
  • Unify translation context to "dataset" in both dataset-detail components

Chores:

  • Add console.log statements in DynamicMatTableComponent for debugging

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • There are leftover console.log debug statements in DynamicMatTableComponent—please remove them before merging.
  • The old runNumber customRender block is just commented out; consider deleting it or refactoring it into a clear fallback path to keep the codebase clean.
  • Subscribing directly to forkJoin for header translations without teardown can lead to memory leaks—consider using the async pipe or unsubscribing in ngOnDestroy.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- There are leftover console.log debug statements in DynamicMatTableComponent—please remove them before merging.
- The old runNumber customRender block is just commented out; consider deleting it or refactoring it into a clear fallback path to keep the codebase clean.
- Subscribing directly to forkJoin for header translations without teardown can lead to memory leaks—consider using the async pipe or unsubscribing in ngOnDestroy.

## Individual Comments

### Comment 1
<location> `src/app/datasets/dataset-table/dataset-table.component.ts:407` </location>
<code_context>
-          convertedColumn.toExport = (row) =>
-            lodashGet(row, "scientificMetadata.runNumber.value");
-        }
+        // if (column.name === "runNumber" && column.type !== "custom") {
+        //   // NOTE: This is for the saved columns in the database or the old config.
+        //   convertedColumn.customRender = (c, row) =>
+        //     lodashGet(row, "scientificMetadata.runNumber.value");
+        //   convertedColumn.toExport = (row) =>
+        //     lodashGet(row, "scientificMetadata.runNumber.value");
+        // }
</code_context>

<issue_to_address>
Commented-out code for runNumber handling may cause confusion.

Remove deprecated code if no longer needed, or add a comment specifying when and why it should be re-enabled if it's only temporarily disabled.
</issue_to_address>

### Comment 2
<location> `src/app/shared/modules/dynamic-material-table/table/dynamic-mat-table.component.ts:515` </location>
<code_context>
   }

   columnName(row: any, column: TableField<any>) {
+    console.log("------");
+    console.log(row);
+    console.log(column);
     if (column.customRender) {
+      console.log("Custom");
+      console.log(column.customRender(column, row));
       return column.customRender(column, row);
     }
-
+    console.log("standard");
+    console.log(row[column.name]);
     return row[column.name];
   }
</code_context>

<issue_to_address>
Debugging console.log statements should be removed before merging.

Please remove these console.log statements or use a proper logging mechanism if necessary.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@nitrosx nitrosx changed the title Fixing run number in dataset list fix: fixing run number in dataset list Aug 20, 2025
Junjiequan
Junjiequan previously approved these changes Sep 10, 2025
@Junjiequan Junjiequan dismissed their stale review September 10, 2025 07:05

wrong pr approval

@nitrosx nitrosx requested review from Junjiequan and removed request for martin-trajanovski and abdimo101 September 30, 2025 06:59
@nitrosx nitrosx requested a review from Junjiequan September 30, 2025 07:13
@nitrosx nitrosx merged commit d39f4a2 into master Sep 30, 2025
7 checks passed
@nitrosx nitrosx deleted the fixing_run_number_in_dataset_list branch September 30, 2025 08:26
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.

3 participants