topcoder-platform / tc-billing-account-service

TC Billing Account Services
0 stars 6 forks source link

Issue in calling ChallengeFee API #34

Closed sumittopcoder closed 6 years ago

sumittopcoder commented 6 years ago

For one of the example where we dont give Challenge fee data, it is giving error- { "param": { "challengeFeeFixed":"false","challengeFeePercentage":"0.85", "challengeFees" :[] }, "method":"POST"

}

{ "id": "-66fc7c6f:15f4a37cd8a:-7c75", "result": { "success": true, "status": 400, "metadata": null, "content": "The challenge fee data should be provided" }, "version": "v3" }


If we give challenge fee then this is another error-

{ "param": { "challengeFeeFixed":true, "challengeFeePercentage": 1.1, "challengeFees": [ { "challengeFee": 500, "challengeTypeId": 39, "name": "Code xxx" } ] }, "method": "POST" }

{ "id": "-66fc7c6f:15f4a37cd8a:-7c78", "result": { "success": true, "status": 400, "metadata": null, "content": "org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException: java.sql.SQLException: Invalid sequence name [statement:\" EXECUTE PROCEDURE common_oltp\:get_sequence_ids(:seqName) \", located:\" EXECUTE PROCEDURE common_oltp\:get_sequence_ids(:seqName) \", rewritten:\" EXECUTE PROCEDURE common_oltp:get_sequence_ids(?) \", arguments:{ positional:{}, named:{seqName:'project_contest_fee_seq'}, finder:[]}]" }, "version": "v3" }

I m assuming first case should run

skyhit commented 6 years ago

@sumittopcoder can you be more specific about the api to reproduce the issue? are you testing in production or dev?

sumittopcoder commented 6 years ago

Here is the API URL - http://api.topcoder-dev.com/v3/billing-accounts/80000015/fees its in dev.

Testing with Body - { "param": { "challengeFeeFixed":true, "challengeFeePercentage": 1.1, "challengeFees": [] }, "method": "POST" }

AND

{ "param": { "challengeFeeFixed":true, "challengeFeePercentage": 1.1, "challengeFees": [ { "challengeFee": 500, "challengeTypeId": 39, "name": "Code xxx" } }, "method": "POST" }

On Fri, Mar 2, 2018 at 12:02 PM, skyhit notifications@github.com wrote:

@sumittopcoder https://github.com/sumittopcoder can you be more specific about the api to reproduce the issue? are you testing in production or dev?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/topcoder-platform/tc-billing-account-service/issues/34#issuecomment-369834601, or mute the thread https://github.com/notifications/unsubscribe-auth/AjO_AyY6QLIMjJeOfYgdOrcqA86fkheaks5taOdugaJpZM4SXxfh .

-- Thanks & Regards Sumit Mishra

Sr. Director Community

sumit@topcoder.com / +91-98291-13328 http://www.topcoder.com www.topcoder.com http://topcoder.com/ / Topcoder Blog: topcoder.com/blog / twitter: @Topcoder https://twitter.com/topcoder

4th Floor - B1 tower, Mahindra World City, Jaipur, India

skyhit commented 6 years ago

@sumittopcoder @ajefts here are my understanding, if the challengeFeeFixed is true, you don't need to set challengeFees array, it will use the challengeFeePercentage value to calculate the fee,

if challengeFeeFixed is false, you should provide the fixed fee for different challenge types in challengeFees

am I right?

sumittopcoder commented 6 years ago

I m sending this request. Still getting same error-

{ "param": { "challengeFeeFixed":"true","challengeFeePercentage":"0.85", "challengeFees" :[] }, "method":"POST" }

Result---

{ "id": "-66fc7c6f:15f4a37cd8a:-7c73", "result": { "success": true, "status": 400, "metadata": null, "content": "The challenge fee data should be provided" }, "version": "v3" }

On Mon, Mar 5, 2018 at 7:45 AM, skyhit notifications@github.com wrote:

@sumittopcoder https://github.com/sumittopcoder @ajefts https://github.com/ajefts here are my understanding, if the challengeFeeFixed is true, you don't need to set challengeFees array, it will use the challengeFeePercentage value to calculate the fee,

if challengeFeeFixed is false, you should provide the fixed fee for different challenge types in challengeFees

am I right?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/topcoder-platform/tc-billing-account-service/issues/34#issuecomment-370290935, or mute the thread https://github.com/notifications/unsubscribe-auth/AjO_A2TSVl-XypBt61FALTor0J7uTUHnks5tbJ_QgaJpZM4SXxfh .

-- Thanks & Regards Sumit Mishra

Sr. Director Community

sumit@topcoder.com / +91-98291-13328 http://www.topcoder.com www.topcoder.com http://topcoder.com/ / Topcoder Blog: topcoder.com/blog / twitter: @Topcoder https://twitter.com/topcoder

4th Floor - B1 tower, Mahindra World City, Jaipur, India

skyhit commented 6 years ago

@sumittopcoder ok, I see, I will work on the fixes.

ajefts commented 6 years ago

if the challengeFeeFixed is true, you don't need to set challengeFees array, it will use the challengeFeePercentage value to calculate the fee,

if challengeFeeFixed is false, you should provide the fixed fee for different challenge types in challengeFees

@skyhit That's correct logic.

sumittopcoder commented 6 years ago

Any updates??

skyhit commented 6 years ago

@sumittopcoder I suggested a quick challenge to resolve this, but no confirmation to launch https://www.topcoder.com/direct/contest/detail?projectId=30063343

how should I do?

sumittopcoder commented 6 years ago

@ajefts , @skyhit - Any updates on this?

skyhit commented 6 years ago

@sumittopcoder @ajefts changes are in PR (https://github.com/topcoder-platform/tc-billing-account-service/pull/35), I am asking approval to merge and deploy in dev for testing

skyhit commented 6 years ago

@sumittopcoder changes are available in dev env, can you test?

sumittopcoder commented 6 years ago

It is not working for me...

URL :http://api.topcoder-dev.com/v3/billing-accounts/80000015/fees Body : { "param": { "challengeFeeFixed":"true","challengeFeePercentage":"0.85", "challengeFees" :[] }, "method":"POST"

}

response: { "id": "215ab27b:1623ca3ad2c:-7ff6", "result": { "success": true, "status": 400, "metadata": null, "content": "The challenge fee data should be provided" }, "version": "v3" }

skyhit commented 6 years ago

it should `{ "param": { "challengeFeeFixed":false,"challengeFeePercentage":"0.85", "challengeFees" :[] }, "method":"POST"

}`

sumittopcoder commented 6 years ago

It says -

"content": "The challenge fee data should not be provided"

Still no luck.

On Mon, Mar 19, 2018 at 3:07 PM, skyhit notifications@github.com wrote:

it should `{ "param": { "challengeFeeFixed":false,"challengeFeePercentage":"0.85", "challengeFees" :[] }, "method":"POST"

}`

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/topcoder-platform/tc-billing-account-service/issues/34#issuecomment-374152393, or mute the thread https://github.com/notifications/unsubscribe-auth/AjO_A8ytxLaZgxoToCQm0jaxL74VuHG6ks5tf3xmgaJpZM4SXxfh .

-- Thanks & Regards Sumit Mishra

Sr. Director Community

sumit@topcoder.com / +91-98291-13328 http://www.topcoder.com www.topcoder.com http://topcoder.com/ / Topcoder Blog: topcoder.com/blog / twitter: @Topcoder https://twitter.com/topcoder

4th Floor - B1 tower, Mahindra World City, Jaipur, India

skyhit commented 6 years ago

how about without challengeFees field?

sumittopcoder commented 6 years ago

"content": "org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException: java.sql.SQLException: Invalid sequence name [statement:\" EXECUTE PROCEDURE common_oltp\:get_sequence_ids(:seqName) \", located:\" EXECUTE PROCEDURE common_oltp\:get_sequence_ids(:seqName) \", rewritten:\" EXECUTE PROCEDURE common_oltp:get_sequence_ids(?) \", arguments:{ positional:{}, named:{seqName:'project_contest_fee_percentage_seq'}, finder:[]}]"

skyhit commented 6 years ago

@sumittopcoder https://circleci.com/gh/topcoder-platform/tc-billing-account-service/40, this fix is not deployed.

mcards13 commented 6 years ago

@ajefts @cwdcwd can you get the above deployed?

skyhit commented 6 years ago

@mcards13 @ajefts @cwdcwd who should we ask for helping this deploy failure - https://circleci.com/gh/topcoder-platform/tc-billing-account-service/40

cwdcwd commented 6 years ago

@skyhit I reran the build and it seems to have succeed this time: https://circleci.com/gh/topcoder-platform/tc-billing-account-service/41

cwdcwd commented 6 years ago

testing http://api.topcoder-dev.com/v3/billing-accounts/80000120/fees on teh dev env gives me:

{
    "id": "-5f20f48e:1624e230f27:-7fd0",
    "result": {
        "success": true,
        "status": 404,
        "metadata": null,
        "content": "The challenge fee was not created for the billing account"
    },
    "version": "v3"
}
skyhit commented 6 years ago

@cwdcwd why I reran failed:(

skyhit commented 6 years ago

@cwdcwd for 80000120, I checked database, there is nothing related, so 404 status should be fine, right?

sumittopcoder commented 6 years ago

Any updates on this? I can still not set Fee on this

CC: @mcards13

skyhit commented 6 years ago

@sumittopcoder still can not, the sql problem, should be fixed.

cwdcwd commented 6 years ago

Can you elaborate on that @skyhit ? what is the core issue here that needs to be resolved ?

skyhit commented 6 years ago

@cwdcwd previously, the deployment failed (fixed by you rebuild it). before the deployment success, @sumittopcoder got error like

"content": "org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException: java.sql.SQLException: Invalid sequence name [statement:" EXECUTE PROCEDURE common_oltp\:get_sequence_ids(:seqName) ", located:" EXECUTE PROCEDURE common_oltp\:get_sequence_ids(:seqName) ", rewritten:" EXECUTE PROCEDURE common_oltp:get_sequence_ids(?) ", arguments:{ positional:{}, named:{seqName:'project_contest_fee_percentage_seq'}, finder:[]}]"

right?

sumittopcoder commented 6 years ago

At least One of these 4 should work-

{ "param": { "challengeFeeFixed":"true","challengeFeePercentage":"0.85", "challengeFees" :[] }, "method":"POST" }

Output- "content": "The challenge fee data should be provided"

{ "param": { "challengeFeeFixed":"false","challengeFeePercentage":"0.85", "challengeFees" :[] }, "method":"POST" } Output - "content": "The challenge fee data should not be provided"

{ "param": { "challengeFeeFixed":"false","challengeFeePercentage":"0.85" }, "method":"POST" } Output - "content": "org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException: java.sql.SQLException: Invalid sequence name [statement:\" EXECUTE PROCEDURE common_oltp\:get_sequence_ids(:seqName) \", located:\" EXECUTE PROCEDURE common_oltp\:get_sequence_ids(:seqName) \", rewritten:\" EXECUTE PROCEDURE common_oltp:get_sequence_ids(?) \", arguments:{ positional:{}, named:{seqName:'project_contest_fee_percentage_seq'}, finder:[]}]"

{ "param": { "challengeFeeFixed":"true","challengeFeePercentage":"0.85" }, "method":"POST" } Output - "content": "The challenge fee data should be provided"

On Tue, Mar 27, 2018 at 7:33 PM, skyhit notifications@github.com wrote:

@cwdcwd https://github.com/cwdcwd previously, the deployment failed (fixed by you rebuild it). before the deployment success, @sumittopcoder https://github.com/sumittopcoder got error like

"content": "org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException: java.sql.SQLException: Invalid sequence name [statement:" EXECUTE PROCEDURE common_oltp:get_sequence_ids(:seqName) ", located:" EXECUTE PROCEDURE common_oltp:get_sequence_ids(:seqName) ", rewritten:" EXECUTE PROCEDURE common_oltp:get_sequence_ids(?) ", arguments:{ positional:{}, named:{seqName:'project_contest_fee_percentage_seq'}, finder:[]}]"

right?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/topcoder-platform/tc-billing-account-service/issues/34#issuecomment-376536810, or mute the thread https://github.com/notifications/unsubscribe-auth/AjO_A2TuBqRd1nZYQwsWyXHfu3laVujxks5tikakgaJpZM4SXxfh .

-- Thanks & Regards Sumit Mishra

Sr. Director Community

sumit@topcoder.com / +91-98291-13328 http://www.topcoder.com www.topcoder.com http://topcoder.com/ / Topcoder Blog: topcoder.com/blog / twitter: @Topcoder https://twitter.com/topcoder

4th Floor - B1 tower, Mahindra World City, Jaipur, India

skyhit commented 6 years ago

@sumittopcoder

general clarification, for request, it should be

if challengeFeeFixed is true, you should set challengeFees array for each challenge type, which means the challenge fee will not be changed according to the prize of the challenge (nochallengeFeePercentage); if challengeFeeFixed is false, you should set challengeFeePercentage instead (no challengeFees)

skyhit commented 6 years ago

for the sql problem, I will look into that, and get that fixed.

tuxing1986 commented 6 years ago

Nothing to fix, you just need to insert the seq names into the table: delete from tcs_catalog:id_sequences where name in ('project_contest_fee_seq', 'project_contest_fee_percentage_seq'); insert into tcs_catalog:id_sequences values('project_contest_fee_seq', 5000, 1, 0); insert into tcs_catalog:id_sequences values('project_contest_fee_percentage_seq', 5000, 1, 0);

The above sqls are mentioned in the deployment guide. Please be noted that the bold 5000 is the start of the seq.

skyhit commented 6 years ago

@tuxing1986 see https://github.com/topcoder-platform/tc-database-scripts/blob/3ce29dd4c7879873b2aedaa0313650a397d067f2/time_oltp/01_time_oltp_main_schema.sql#L2803-L2810

there are sequences, we should reuse that, and we have similar logic in challenge service about how to do that, like following

package com.appirio.service.challenge.api;

import lombok.Getter;
import lombok.Setter;

public class IdSequence {
    @Getter
    @Setter
    private Long nextId;
}
package com.appirio.service.challenge.dao;

import com.appirio.service.challenge.api.IdSequence;
import com.appirio.supply.dataaccess.DatasourceName;

import org.skife.jdbi.v2.sqlobject.SqlQuery;
import org.skife.jdbi.v2.sqlobject.customizers.Define;

@DatasourceName("common")
public interface SequenceDAO {
    @SqlQuery("SELECT SEQUENCE_<sequenceName>.nextval AS nextId FROM systables WHERE tabid = 1")
    public IdSequence getIdSequence(@Define("sequenceName") String sequenceName);
}
tuxing1986 commented 6 years ago

Please check src\main\java\com\appirio\service\billingaccount\BillingAccountServiceApplication.java at the line 88: BillingAccountManager billingAccountManager = new BillingAccountManager(DAOFactory.getInstance().createDAO(BillingAccountDAO.class), IdGenerator.getInstance("com.topcoder.timetracker.ProjectManager"), IdGenerator.getInstance("com.topcoder.timetracker.user.User"), IdGenerator.getInstance("project_contest_fee_seq"), IdGenerator.getInstance("project_contest_fee_percentage_seq"));

Those sequences are reused.

If the database is not update and has no such sequences, you can run the sql in my deployment guide to insert them.

skyhit commented 6 years ago

@tuxing1986 actually, this is missing or wrong implementation from the previous submission, it is not your resposiblity to make the fix, I will take it

skyhit commented 6 years ago

@sumittopcoder the problem is fixed, please double check

sumittopcoder commented 6 years ago

First time this works. "param": { "challengeFeeFixed":"false","challengeFeePercentage":"0.85" }, It is setting 0.85 in challengeFeePercentage.

Now When I run same API with value "0.70". It is not changing the value "0.85".

I m assuming It should. Can you please check?

Sumit

On Wed, Mar 28, 2018 at 10:30 AM, skyhit notifications@github.com wrote:

@sumittopcoder https://github.com/sumittopcoder the problem is fixed, please double check

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/topcoder-platform/tc-billing-account-service/issues/34#issuecomment-376761958, or mute the thread https://github.com/notifications/unsubscribe-auth/AjO_AyDFhAKukG4ALFXR41yhADWp58d7ks5tixjsgaJpZM4SXxfh .

-- Thanks & Regards Sumit Mishra

Sr. Director Community

sumit@topcoder.com / +91-98291-13328 http://www.topcoder.com www.topcoder.com http://topcoder.com/ / Topcoder Blog: topcoder.com/blog / twitter: @Topcoder https://twitter.com/topcoder

4th Floor - B1 tower, Mahindra World City, Jaipur, India

skyhit commented 6 years ago

@sumittopcoder

POST for creation, PUT for updating, DELETE for removing, this is the standard for RESTful APIs.

sumittopcoder commented 6 years ago

Works well, Thanks,

On Wed, Mar 28, 2018 at 8:32 PM, skyhit notifications@github.com wrote:

@sumittopcoder https://github.com/sumittopcoder

POST for creation, PUT for updating, DELETE for removing, this is the standard for RESTful APIs.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/topcoder-platform/tc-billing-account-service/issues/34#issuecomment-376919272, or mute the thread https://github.com/notifications/unsubscribe-auth/AjO_A2Y-VcE7EsYW0-69-5eTHkjP7D5eks5ti6YRgaJpZM4SXxfh .

-- Thanks & Regards Sumit Mishra

Sr. Director Community

sumit@topcoder.com / +91-98291-13328 http://www.topcoder.com www.topcoder.com http://topcoder.com/ / Topcoder Blog: topcoder.com/blog / twitter: @Topcoder https://twitter.com/topcoder

4th Floor - B1 tower, Mahindra World City, Jaipur, India

skyhit commented 6 years ago

@sumittopcoder cool

cwdcwd commented 6 years ago

Billing account fee issue