alphagov/paas-billing

ServiceName and ServiceGUID missing from GET /billable_events

Closed this issue · 2 comments

What's wrong

The struct for BillableEvent has fields for ServiceGUID and ServiceName, and we have all the data in the database to populate them but these are not currently returned in requests for GET /billable_events.

Steps to reproduce

Run this:

curl -H "Authorization: $(cf oauth-token)" "https://billing.cloud.service.gov.uk/billable_events?range_start=2018-01-01&range_stop=2018-02-01" | jq .

Observe the lack of service_name and service_guid fields.

Some direction

The query in getBillableEventRows could be extended to join the service data something like:

select resource_name,resource_type,coalesce(services.label,resource_type) as service ,coalesce(service_plans.name,plan_name) as plan from billable_event_components bev left join service_plans on service_plans.guid = bev.plan_guid left join services on services.guid = service_plans.service_guid;
46bit commented

As I understand it, we already have this data in the resource_guid and resource_name fields.

46bit commented

From looking at a pricing statement, this data is definitely getting there. Closing–I'm going to remove those fields from BillingEvent.