Skip to content

Commit

Permalink
Fix broken requests
Browse files Browse the repository at this point in the history
The requests for sorted constructed molecules and sorted building
blocks were broken, as they were not returning any molecules. This
was discovered simply by trying to view sorted constructed molecules
and sorted building blocks in stk-vis. The origin of the bug for
the sorted constructed molecules request was due to the fact that the
the query in `sorted-constructed-molecules/Request.js` was wrong. It
was filtering out constructed molecules, rather than keeping them.
Probably due to copying code from the other requests and forgetting to
edit it.

Fixing this revealed a second bug in the request. When the molecules
were getting sorted by "Num Atoms", the table had no "Num Bonds"
entries, and vice versa. This was also happening in the sorted
building blocks request. The reason for this is that I was returning
`sortedBaseMolecules`, which did not contain the results of the data
query, rather than `molecules`, which did.

To help future debugging I've also made all the building blocks
contain a value in the "Num Atoms" collection in the test database.
  • Loading branch information
lukasturcani committed Jun 6, 2021
1 parent 771d59d commit bf44af9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Requests/sorted-building-blocks/Request.purs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ request options = do

molecules = Utils.addValues sortedBaseMolecules collections

collection <- _collectionPromise sortedBaseMolecules
collection <- _collectionPromise molecules

pure
(Result
Expand Down
2 changes: 1 addition & 1 deletion src/Requests/sorted-constructed-molecules/Request.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ exports.query =
],
},
{
'$eq': [
'$gt': [
{'$size': '$constructedMolecule'},
0,
],
Expand Down
2 changes: 1 addition & 1 deletion src/Requests/sorted-constructed-molecules/Request.purs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ request options = do

molecules = Utils.addValues sortedBaseMolecules collections

collection <- _collectionPromise sortedBaseMolecules
collection <- _collectionPromise molecules

pure
(Result
Expand Down
6 changes: 6 additions & 0 deletions test/make_test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ def build_database_1():
num_atoms_db.put(molecule, molecule.get_num_atoms())
num_bonds_db.put(molecule, molecule.get_num_bonds())

for building_block in molecule.get_building_blocks():
num_atoms_db.put(
molecule=building_block,
value=building_block.get_num_atoms(),
)


def build_database_2():
"""
Expand Down

0 comments on commit bf44af9

Please sign in to comment.