fossasia / open-event-organizer-android

Open Event Mobile App for Organizers and Entry Managers https://play.google.com/store/apps/details?id=com.eventyay.organizer
Apache License 2.0
1.79k stars 490 forks source link

Reimplement event sales stats #2020

Closed iamareebjamal closed 1 year ago

iamareebjamal commented 4 years ago

Since revenue, tickets sold, tickets available have been removed from the API, app sales info is broken and needs to be reimplemented

https://github.com/fossasia/open-event-organizer-android/pull/1315

iamareebjamal commented 4 years ago

@codedsun Can you take this up please

codedsun commented 4 years ago

Yes, taking this up

codedsun commented 4 years ago

@iamareebjamal - For the revenue I can get in https://open-event-api-dev.herokuapp.com/v1/events/9/order-statistics

Response: {"data": {"type": "order-statistics-event", "attributes": {"sales": {"total": 200.0,

But for tickets- i had to get the tickets via /v1/events/9/tickets

and suppose if the event has multiple ticket - then fetch these ticket details in a loop with ticket-id

like /v1/tickets/27/order-statistics

correct?

But why dont we have made them available in event statistics?

iamareebjamal commented 4 years ago

They should be available there

codedsun commented 4 years ago

@iamareebjamal

The event statics shows this as response. We dont have total quantity of tickets.

{
    "data": {
        "type": "order-statistics-event",
        "id": "38",
        "attributes": {
            "orders": {
                "total": 25,
                "draft": 0,
                "cancelled": 0,
                "pending": 0,
                "expired": 20,
                "placed": 2,
                "completed": 0
            },
            "sales": {
                "total": 250.0,
                "draft": 0,
                "cancelled": 0,
                "pending": 0,
                "expired": 200.0,
                "placed": 20.0,
                "completed": 0
            },
            "tickets": {
                "total": 31,
                "draft": 0,
                "cancelled": 0,
                "pending": 0,
                "expired": 26,
                "placed": 2,
                "completed": 0
            },
            "identifier": "95a16dad"
        },
        "links": {
            "self": "/v1/events/38/order-statistics"
        }
    },
    "links": {
        "self": "/v1/events/38/order-statistics"
    },
    "jsonapi": {
        "version": "1.0"
    }
}

Shall i go with the approach stated here https://github.com/fossasia/open-event-organizer-android/issues/2020#issuecomment-570251415 ?

iamareebjamal commented 4 years ago

Then what is this?

"tickets": {
                "total": 31,
codedsun commented 4 years ago

@iamareebjamal - it's not the total quantity of tickets which can be ordered.

From the codebase it says total = db.session.query(func.sum(OrderTicket.quantity.label('sum'))).join(Order.order_tickets).filter( OrderTicket.ticket_id == obj_id).scalar()

https://github.com/fossasia/open-event-server/blob/3260e981d4b3eb309487f70319e6a1aaacccb47f/app/api/order_statistics/events.py#L35-L60

Actual ticket capacity is different

image

iamareebjamal commented 4 years ago

Yeah, then add them in event statistics

codedsun commented 4 years ago

Okay, then will raise the issue on server side. Thanks

On Fri, Jan 3, 2020, 8:34 PM Areeb Jamal notifications@github.com wrote:

Yeah, then add them in event statistics

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fossasia/open-event-organizer-android/issues/2020?email_source=notifications&email_token=AEYZISD5HYPKQ7XTYVE3MSTQ35HXPA5CNFSM4KCAD4B2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIBJ7QI#issuecomment-570597313, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYZISBIBT6ZQGAESBUL2DTQ35HXPANCNFSM4KCAD4BQ .

iamareebjamal commented 4 years ago

Same issue, no need of creating new one

codedsun commented 4 years ago

@iamareebjamal - What should be the structure like when there are multiple tickets? Then we can't add them under http://127.0.0.1:5000/v1/events/38/order-statistics

I should add them under http://127.0.0.1:5000/v1/tickets/30/order-statistics but then again the client has to call this API for all the unique ticket available .?

Am I Corrrect?

iamareebjamal commented 4 years ago

?

codedsun commented 4 years ago

@iamareebjamal - The ticket quantity is not present under http://127.0.0.1:5000/v1/tickets/30/order-statistics as discuessed here. (https://github.com/fossasia/open-event-organizer-android/issues/2020#issuecomment-570595585)

You asked me to add under this, but how do I do this when there are multiple tickets like (Paid, Free etc) shall I return just the sum of them in this api?

Example for the same in the screenshot here (https://github.com/fossasia/open-event-organizer-android/issues/2020#issuecomment-570595585) - I should return the sum (100+1) - for total and free ticket?

or shall I add this under http://127.0.0.1:5000/v1/tickets/30/order-statistics with respect specific ticket id?

iamareebjamal commented 4 years ago

I asked to add under general-statistics.

but how do I do this when there are multiple tickets like (Paid, Free etc)

See what's required in app. You're looking at screenshot of frontend and that too of order sales, not ticket count, about which the discussion was going on

codedsun commented 4 years ago

@iamareebjamal - I mean that revenue, tickets sold, tickets available this is required in the app as they are removed from the api. https://open-event-api-dev.herokuapp.com/v1/users/31/events?page[size]=0

SS for the app:

Now as I want these - I will have to hit

  1. For all the events of user - https://open-event-api-dev.herokuapp.com/v1/users/31/events?page[size]=0

  2. For revenue of each event - https://open-event-api-dev.herokuapp.com/v1/events/9/order-statistics example: "sales": {"total": 200.0,

  3. For ticket-count of each event - https://open-event-api-dev.herokuapp.com/v1/events/9?include=tickets

    I am hitting extra 2 calls to get the revenue and ticket-counts.

Which mean If a user has 10 events - then 21(20 +1 ) calls just for this screen.

iamareebjamal commented 4 years ago

First you were talking about multiple tickets types and free and paid tickets and whatnot and now you're talking about multiple API calls. Can you please stick to 1 thing in a discussion?

You don't need ?include=tickets for ticket count. Add that info in order statistics and include order-statistics with events

https://open-event-api-dev.herokuapp.com/v1/users/31/events?page[size]=0&include=order-statistics

1 call for just this screen

codedsun commented 4 years ago

@iamareebjamal - I am sorry.

Add that info in order statistics and include order-statistics with events

I will add the info (ticket_quantity) under order-statistics.

I got this.

Now,

my first ques(https://github.com/fossasia/open-event-organizer-android/issues/2020#issuecomment-570773207) -

but how do I do this when there are multiple tickets like (Paid, Free etc) shall I return just the sum of them in this api?

Explaination -

If i had multiple tickets Paid - Ticket quantity =100 Free - Ticket quantity = 200

Then I shall return ticket_quanity as 300 = sum of (paid+free)

Am I clear this tym?

iamareebjamal commented 4 years ago

Why do you need to separate free and paid tickets? Is there a UI in the app where it is needed?

codedsun commented 4 years ago

I don't need to seperate, I am asking about the case here - When there are multiple tickets in an event then I have to take their quantity count also.

codedsun commented 4 years ago

I have not mentioned anywhere of seperating- For an event - the ticket quantity count should be equal to sum of all the possible tickets ticket quanity (be it paid, dontation, free)

More specific - this is what I am talking about

400 here in the pic = sum of ticket_quantity of all the possible tickets(Paid, free,..etc)

image

Correct? @iamareebjamal

iamareebjamal commented 4 years ago

Yes