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

Fixed Issue #44 #65

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fixed Issue #44 #65

wants to merge 1 commit into from

Conversation

adityawbwce
Copy link
Contributor

Fixed Issue #44

Copy link
Member

@scop scop left a comment

Choose a reason for hiding this comment

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

Added some comments from a read through, did not test yet.

Comment on lines -95 to +147
}
foreach (Capsule::table('tblproductconfigoptionssub')->where('configid', $optionId)->get() as $id) {
$parts = explode("|", $id->optionname);
$fprice = $parts[0] * "2";
$monthlys = $this->manager->CurrencyConvert('EUR', $currencyCode, $fprice);
Capsule::table('tblpricing')->updateOrInsert(['type' => 'configoptions', 'relid' => $id->id, 'monthly' => $monthlys['convertedAmount'] ],['currency' => $currencyId]);
$relId = Capsule::table('tblproductconfigoptionssub')->where('optionname', $mem.'|'.$mvals)->where('configid', $optionId)->first()->id;
$fprice = $mem * "2";
$monthlys = $this->manager->CurrencyConvert('EUR', $currencyCode, $fprice);
Capsule::table('tblpricing')->updateOrInsert(['type' => 'configoptions', 'relid' => $relId, 'monthly' => $monthlys['convertedAmount'] ],['currency' => $currencyId]);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I read this correctly, or how it is related to issue #44. Could we clarify the purpose of this change?

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 do not think that I made any changes createRAMFields function, please check again.

Comment on lines -115 to +165
}
foreach (Capsule::table('tblproductconfigoptionssub')->where('configid', $optionId)->get() as $id) {
$parts = explode("|", $id->optionname);
$fprice = $parts[0] * "6";
$monthlys = $this->manager->CurrencyConvert('EUR', $currencyCode, $fprice);
Capsule::table('tblpricing')->updateOrInsert(['type' => 'configoptions', 'relid' => $id->id, 'monthly' => $monthlys['convertedAmount'] ],['currency' => $currencyId]);
$relId = Capsule::table('tblproductconfigoptionssub')->where('optionname', $cpu.'|'.$cvals)->where('configid', $optionId)->first()->id;
$fprice = $cpu * "6";
$monthlys = $this->manager->CurrencyConvert('EUR', $currencyCode, $fprice);
Capsule::table('tblpricing')->updateOrInsert(['type' => 'configoptions', 'relid' => $relId, 'monthly' => $monthlys['convertedAmount'] ],['currency' => $currencyId]);
Copy link
Member

Choose a reason for hiding this comment

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

Same as above comment for memory, but for CPU here.

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 do not think that I made any changes createCPUFields function, please check again.

Comment on lines -135 to +183
}
foreach (Capsule::table('tblproductconfigoptionssub')->where('configid', $optionId)->get() as $id) {
$parts = explode("|", $id->optionname);
$fprice = $parts[0] * "0.10";
$monthlys = $this->manager->CurrencyConvert('EUR', $currencyCode, $fprice);
Capsule::table('tblpricing')->updateOrInsert(['type' => 'configoptions', 'relid' => $id->id, 'monthly' => $monthlys['convertedAmount'] ], ['currency' => $currencyId] );
$relId = Capsule::table('tblproductconfigoptionssub')->where('optionname', $storage.'|'.$vals)->where('configid', $optionId)->first()->id;
$fprice = $storage * "0.10";
$monthlys = $this->manager->CurrencyConvert('EUR', $currencyCode, $fprice);
Capsule::table('tblpricing')->updateOrInsert(['type' => 'configoptions', 'relid' => $relId, 'monthly' => $monthlys['convertedAmount'] ], ['currency' => $currencyId] );
Copy link
Member

Choose a reason for hiding this comment

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

Same as above comment for memory, but for storage here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as above for createStorageFields function

{
$groupId = Capsule::table('tblproductconfiggroups')->where('name', 'Configurable options for UpCloud Global')->first()->id;
$groupId = Capsule::table('tblproductconfiggroups')->where('name', 'Configurable options for UpCloud Cloud Linux')->first()->id;
Copy link
Member

Choose a reason for hiding this comment

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

Does "Cloud Linux" here and below mean that it is related to Linux instances set up from cloud-init templates? If I understand correctly, would be good to clarify the intents of these option sets in their names, for example

Configurable options for UpCloud - native Windows template VPS
Configurable options for UpCloud - native Linux template VPS
Configurable options for UpCloud - cloud-init Linux template VPS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The names it self says https://prnt.sc/p-h7WOcY5_MF where Cloud Linux meaning cloud-init images

Comment on lines -88 to +137
$mems["$i"] = "$i Gigabyte (GB)";
$mems["$i"] = "$i Gigabyte [GB]";
Copy link
Member

Choose a reason for hiding this comment

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

I wonder what is the rationale for this change, and its relation to #44?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was creating some conflicts so added [] brackets

Comment on lines +265 to +271
if ($vmtype == 'nativewindows' && preg_match('/Windows/', $template['title'])) {
$templateIds[$template['uuid']] = $template['title'];
} elseif ($vmtype == 'nativelinux' && !preg_match('/Windows/', $template['title'])) {
$templateIds[$template['uuid']] = $template['title'];
}
} elseif ($template['template_type'] == "cloud-init" && $vmtype == 'cloudinit') {
$templateIds[$template['uuid']] = $template['title'];
Copy link
Member

Choose a reason for hiding this comment

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

The bodies of all these conditions are the same,

$templateIds[$template['uuid']] = $template['title'];

Is this on purpose? If yes, I feel this would be clearer refactored into a single if statement with a series of || separated conditions, instead of a nested if-else chain. As currently written, it gives the feeling that there might be a bug in that all the condition bodies are the same (i.e. maybe they should be somehow different)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How they are same? Have you checked the conditions?

}
if (!$vmtype) {
foreach ($templates as $template) {
$templateIds[$template['uuid']] = $template['title'];
Copy link
Member

Choose a reason for hiding this comment

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

Here's yet another same condition body as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do verify the conditions for the function getTemplateIds and let me know your issues

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.

2 participants