Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LITE-27896 Add PPR endpoints #51

Merged
merged 1 commit into from
Jul 26, 2023
Merged

LITE-27896 Add PPR endpoints #51

merged 1 commit into from
Jul 26, 2023

Conversation

Hairash
Copy link
Contributor

@Hairash Hairash commented Jul 26, 2023

No description provided.

@Hairash Hairash requested review from jonatrios, akodelia and d3rky July 26, 2023 06:42
summary=summary,
status=status,
created_by=context.user_id,
**config_kwargs,
)
db.set_verbose(new_ppr)
db.commit()
return new_ppr
return new_ppr, file_instance, active_configuration
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know that it looks bad to return 3 values in a function.
But we are going to refactor this function anyway, so let's refactor this place with a function.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that this could be solved by adding relationship on PPRVersion to Configurations and Files, like:

configuration = relationship('Configuration', foreign_keys="Configuration.id")
file = relationship('File', foreign_keys="File.id")

So then you can access new properties like: new_ppr.configuration or new_ppr.file

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about the file relation here... We already have a file link here, but I think that we should store a reference to the configuration that was used to generate the PPR. I'm ok to merge this now, but @Hairash submit a separate issue and patch to add the reference to the latest configuration in case of:

  1. File is generated on the new product version appears
  2. File is generated when user click on the regenerate button

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok agree with that!

description_items.append(ppr.description)
if ppr.summary:
description_items.append(str(ppr.summary))
description = '\n'.join(description_items)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Better to decide, how to output description and summary. Now I merge them because there are case when two of them are present and make sense. Like upload file with a description, but facing the validation errors.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have new task to implement this, but for now is good to have at least this approach

@@ -298,4 +306,6 @@ def test_create_ppr_db_error(
ppr_data, common_context, deployment,
dbsession, connect_client, logger,
)
assert ex.value.message == "Database error occurred."
assert ex.value.message == (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think better to come up with another test for DB error, because now it is duplicated with another one that file already exists.

@@ -117,6 +118,8 @@ def create_ppr(ppr, context, deployment, db, client, logger):
new_version = get_ppr_new_version(db, deployment)
config_kwargs = {}
status = PPRVersion.STATUS.ready
active_configuration = None
product_version = None
Copy link
Contributor

Choose a reason for hiding this comment

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

[COD-B] Why we have the product_version as None when user upload a file?, I think the new ppr has to correspond to the product version available at that moment on time no matter where the new file been generated from.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I understand, no.
@d3rky tell us.

Copy link
Contributor

Choose a reason for hiding this comment

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

We cannot guarantee with what version of the product and configuration this PPR was created. That's why it is null. We can assume, that probably it is the latest versions... But who knows? Maybe the version was not released at that moment

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry was my misunderstanding, then lets proceed!

description_items.append(ppr.description)
if ppr.summary:
description_items.append(str(ppr.summary))
description = '\n'.join(description_items)
Copy link
Contributor

Choose a reason for hiding this comment

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

I have new task to implement this, but for now is good to have at least this approach

summary=summary,
status=status,
created_by=context.user_id,
**config_kwargs,
)
db.set_verbose(new_ppr)
db.commit()
return new_ppr
return new_ppr, file_instance, active_configuration
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that this could be solved by adding relationship on PPRVersion to Configurations and Files, like:

configuration = relationship('Configuration', foreign_keys="Configuration.id")
file = relationship('File', foreign_keys="File.id")

So then you can access new properties like: new_ppr.configuration or new_ppr.file

@@ -316,6 +317,53 @@ def get_configuration_schema(configuration, file):
)


def get_ppr_version_schema(ppr, file, conf):
Copy link
Contributor

Choose a reason for hiding this comment

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

Same in here, if you relay on relationships, it only gonna take ppr arg

@@ -117,6 +118,8 @@ def create_ppr(ppr, context, deployment, db, client, logger):
new_version = get_ppr_new_version(db, deployment)
config_kwargs = {}
status = PPRVersion.STATUS.ready
active_configuration = None
product_version = None
Copy link
Contributor

Choose a reason for hiding this comment

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

We cannot guarantee with what version of the product and configuration this PPR was created. That's why it is null. We can assume, that probably it is the latest versions... But who knows? Maybe the version was not released at that moment

summary=summary,
status=status,
created_by=context.user_id,
**config_kwargs,
)
db.set_verbose(new_ppr)
db.commit()
return new_ppr
return new_ppr, file_instance, active_configuration
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about the file relation here... We already have a file link here, but I think that we should store a reference to the configuration that was used to generate the PPR. I'm ok to merge this now, but @Hairash submit a separate issue and patch to add the reference to the latest configuration in case of:

  1. File is generated on the new product version appears
  2. File is generated when user click on the regenerate button

@Hairash Hairash force-pushed the LITE-27896-ppr-endpoints branch from b7b3ff1 to c509f6e Compare July 26, 2023 11:51
@Hairash Hairash merged commit b70e555 into master Jul 26, 2023
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