Skip to content

Comments

Able to select samples and sort them before generating genlabIDs.#163

Closed
aastabk wants to merge 7 commits intosummer25from
103-clean-1
Closed

Able to select samples and sort them before generating genlabIDs.#163
aastabk wants to merge 7 commits intosummer25from
103-clean-1

Conversation

@aastabk
Copy link
Contributor

@aastabk aastabk commented Jul 1, 2025

When looking at incoming samples, staff is now able to sort the columns and then generate a genlabID in their desired order. They are also able to only generate a genlabID for a selected few.

  • Changes are made to html files to send the post request within the same form.
  • Generate now accepts more fields
  • Still support for the other buttons that generate genlabIDs
  • Javascript is added to make checkboxes dynamic

Has not been tested for genlabID generation, as I am not able to do so locally.

Screenshot 2025-07-01 at 09 10 57

Has not been tested for genlabID generation.
@aastabk aastabk requested review from mortenlyn and omfj July 1, 2025 06:30
@aastabk aastabk self-assigned this Jul 1, 2025
Comment on lines 113 to 117
order_by_columns = (
[column(col, table=samples_table) for col in sorting_order]
if sorting_order
else [column("name", table=samples_table)]
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Legge til kommentarer på hva som skjer her?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hvorfor sorterer man i en update action?

Comment on lines 95 to 99
def update_genlab_id_query(
order_id: int | str,
sorting_order: list[str] | None = None,
selected_samples: list[Any] | None = None,
) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

Dette bør vi nok finne en måte å teste på før vi merger

@aastabk
Copy link
Contributor Author

aastabk commented Jul 2, 2025

Generation genlab IDs have now been tested, and the code is changed as a result. In the image below, 7 samples have a generated genlabID based on their name (they are naturally sorted on species as the ID is dependent on the specie code).

Screenshot 2025-07-02 at 12 52 47

Copy link
Contributor

@emilte emilte Jul 2, 2025

Choose a reason for hiding this comment

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

Det er en drastisk endring på så viktig funksjonalitet. Hvis denne branchen ikke er avhengig av refaktoreringen hadde det kanskje vært lurt å gjøre denne endringen i en egen dedikert branch slik at det er lettere å reversere i tilfelle noe problem skulle oppstå?

Copy link
Contributor

Choose a reason for hiding this comment

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

Er det skrevet tester rundt denne funksjonaliteten? Er vi sikre på at det fortsatt fungerer som forventet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Enig - da flytter jeg endringene i genlabid.py til en ny branch og tilpasser heller implementeringen som allerede er der.

Jeg ser ingen tester skrev rundt generering av genlabid.

Copy link
Contributor

@emilte emilte Jul 3, 2025

Choose a reason for hiding this comment

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

Jeg foreslår at dere kanskje setter dere sammen og prøver å skrive pytester på den funksjonen, i egen branch

Comment on lines +69 to +71
cursor.execute(
update_genlab_id_query(order_id, sorting_order, selected_samples)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Litt usikker på om dette skal funke. cursor.execute kjører den sql-queryen den får, mens update_genlab_id_query kjører en sql query + returnerer None.

Suggested change
cursor.execute(
update_genlab_id_query(order_id, sorting_order, selected_samples)
)
update_genlab_id_query(order_id, sorting_order, selected_samples)

@@ -73,7 +66,9 @@ def generate(order_id: int | str) -> None:
with connection.cursor() as cursor:
try:
with transaction.atomic():
Copy link
Contributor

Choose a reason for hiding this comment

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

Tror ikke at with transaction.atomic() er nødvendig siden du dekorerer funksjonen din også med det.

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.

4 participants