CCP-NC / ccpnc-database

4 stars 3 forks source link

Feature/boolean search #35

Closed Sathya-S3 closed 3 months ago

Sathya-S3 commented 3 months ago

HTML changes: file: index.html

  1. Added toggle switch to facilitate AND and NOT Boolean filtering in search.
  2. Changed External database reference name choice to a dropdown menu rather than free text, to make user experience better. User is shown an additional textbox to enter custom database name if the chosen database name from dropdown is 'Other'.
  3. Present two drop-down menus for search depending on AND or NOT option chosen with toggle switch.

file: version_table.html Minor change - corrected code indentation.

Custom stylesheet changes: file: stylesheet.css Styles added for custom toggle switch appearance and its states.

JavaScript changes: file: search.js Added 'boolean' variable to 'args' under the search_specs scope variable to track the state of the toggle switch.

Backend python changes: file: search.py

  1. Changes to NMR data (magnetic shielding and electric field gradient) query building to accommodate external query negation.
  2. Major changes to external database reference query building function - receive separate user arguments for database name (preset values CSD, ICSD or COD or custom values when reftype is Other), wildcard search for refcode improved.
  3. Added code to extract 'boolean' scope variable directly from query and modify query according for AND or NOT search cases.

file: server.py Added 'boolean' variable to avoid errors when getting records.

Test files change for CI: tests/py/mdb_test.py

  1. Added 'boolean' variable to build_query arguments under testSearch module.
  2. Added 'other_reftype' datatype to the arguments for external database test search queries.
jkshenton commented 3 months ago

Thanks Sathya - that looks like it nicely captures the requirements that the users wanted!

The only major thing I would add would be tests of the new functionality, specifically the boolean NOT queries both by themselves and in conjunction with other queries.

Sathya-S3 commented 3 months ago

@jkshenton The last commit a920dea includes the necessary CI tests added to showcase the NOT Boolean searches. The NOT queries are simply triggered by setting 'boolean' argument to True when calling the search_record() function.

NOT cases have been included for doi, External database reference, and license search parameters.

NOT case has not been written for the magnetic shielding and electric field gradient cases. The unittest() is set to skip the nmr parameter tests because mongomock at the moment does not support MongoDB query functions such as '$anyElementTrue' and '$map' which are used by these functions. Therefore, the test will exit with a custom warning message 'MongoDB mock does not support this search, skipping test case'. This is a limitation of mongomock only, not that of pymongo or MongoDB.

jkshenton commented 3 months ago

Great, thanks Sathya. I've now merged