Skip to content

Conversation

@servoz
Copy link
Contributor

@servoz servoz commented Dec 6, 2024

I'm doing this little PR because I'm not sure!

I'm still not very comfortable with the new populse_db API and I'm wondering if there might be another, more elegant way of doing things here?

We have the config object by doing:
for config in session.configs(module, env) :

I haven't found a way to use this object to retrieve the configuration items, so I'm using the enumerate() function ...
Isn't there a better method?
Isn't regression possible?

Copy link
Collaborator

@sapetnioc sapetnioc left a comment

Choose a reason for hiding this comment

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

There is a wrong usage of the Storage API here. I believe this code is not working.

for config in session.configs(module, env):
id = "%s-%s" % (config._id, env)
doc = data[session.collection_name(module)][id]
items = dict(doc._items())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Once get() is called, the value of the document is returned (very likely as a dict in this case). There is no _items() method in Storage API.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe the test if "config_id" in doc: could be appropriate here ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

dict() is useless here.
Personally, I would have directly set doc = data[session.collection_name(module)][id].get() and replace items by doc. But this is no important.

@servoz servoz requested a review from sapetnioc December 9, 2024 12:27
Copy link
Collaborator

@sapetnioc sapetnioc left a comment

Choose a reason for hiding this comment

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

You can merge this PR once you decided what to do (or not to do) with my comments.

for config in session.configs(module, env):
id = "%s-%s" % (config._id, env)
doc = data[session.collection_name(module)][id]
items = dict(doc._items())
Copy link
Collaborator

Choose a reason for hiding this comment

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

dict() is useless here.
Personally, I would have directly set doc = data[session.collection_name(module)][id].get() and replace items by doc. But this is no important.

@servoz servoz merged commit 25ebf07 into populsedb3 Dec 9, 2024
1 check passed
@servoz servoz deleted the populsedb3_pr branch December 9, 2024 13:11
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