Closed (fixed)
Project:
Monitoring
Version:
8.x-1.x-dev
Component:
Sensors
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
27 Nov 2014 at 11:17 UTC
Updated:
18 Dec 2014 at 22:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Anushka-mp commentedHere are the two sensors to monitor payments (payments count and turnover for last 24 hours)
Awaiting feedback. needs to provide test coverage.
Comment #2
Anushka-mp commentedrunSensor overriden for the payment count sensor. as discussed with Berdir.
Comment #3
berdirNo need to specify the entity_type, as that is not used.
We can't just hardcode CHF here :)
Have a look at the existing commerce sensor. What we did there is expose a sensor for each enabled currency, but this works all a bit different in 8.x now.
Check which currency is enabled by default in payment and use that for now. We will also need a setting to limit the sensor to payments of a specific currency.
The description here is copied from the other one and not correct. the two should also have a different label. label here is the same as for the sensors.
You already have the count, there is no need to load them, count($ids) is enough, you can actually do a COUNT() expression here... Almost.
The problem is that payment_status contains multiple rows per payment, so this will return too much.
Which mean we need to do a count(DISTINCT payment_id).
And we need to add an option to filter on a specific payment status. We only want to count completed payments her, so we need to filter by "completed" or what it is called. This is a sensor setting.
Comment #4
Anushka-mp commentedAs discussed I've created the configs in tests and test the functionality of the sensors here, they're not default sensors anymore.
the filter by successful transactions needs to be implemented in both sensors. awaiting feedback.
These tests are dependent on the payment module.
Comment #5
miro_dietikerHmm.. Testbot currently postponed checking due to a fail in HEAD. That's a strange thing.
I have pushed the debug statement from the issue referred...
#2382539: Rename SensorInfo to SensorConfig
Hopefully we will be able to see the bug origin when it fails again.
Comment #6
miro_dietikerYeah and now it passes again... grrr :-!
Comment #8
miro_dietikerAh yeah and testbot doesn't work with payment currently...
Comment does not match.
Please add a comment about what the query does.
Filtering by proper currency here seems to me pretty late. We are loading payments and cycling through them although they are unrelated to the current sensor.
If earlier filter through db_select is not possible, explain in comment.
The sensor should alter the value_label of SensorForm to a select and offer the currencies only for selection. Alternatively, it should validate the input.
Ah and don't forget, i'm about to rename Sensor classes... so you should follow the new pattern SensorPaymentTurnover => PaymentTurnoverSensor... See
#2383993: Rename Sensor* to *Sensor, Sensor/Sensors/* to Sensor/*, Sensor to SensorBase
Comment #9
berdirThere is no way to do this other than a form_alter (which would be pointless as it's the same module. The interaction beween value type and the plugin settings forms is *very* problematic (cross-dependency on config forms for example), let's not go into this here.
Comment #10
berdirAnd in this case, as written in #2368593: Currency value support, currency should be a value type, which would then completely replace a manual value label configuration. (Yet more complexity: hide the value_label form element if you select a value type that has a formatter callback).
Comment #11
Anushka-mp commentedThe query modified as suggested by Miro, now this fetches only the required from the database, currency checks are done at data tier not in the application layer.
Comments added to explain the query.
Sensors renamed according to #2383993: Rename Sensor* to *Sensor, Sensor/Sensors/* to Sensor/*, Sensor to SensorBase.
Still need to check for the completed transactions. awaiting feedback.
Comment #12
Anushka-mp commentedComment #13
miro_dietikerNo "the following"...
not past 24h. It's the configured interval.
My intention was more a summary documentation statement instead of interpreting line by line...
I can read the code and see payment_status and payment_line_item already. But even though you documented it, it is not quickly clear to the reader why these two tables are needed.
Example:
Query payments from payment_status, filter for the currency.
The payment amounts reside on payment_line_item.
Add a comment here that we are using a custom "illegal" query to the database instead of using the EntityManager...
Comment #14
Anushka-mp commentedcomments chopped modified and looks better now :D
Comment #16
miro_dietikerYeah, now looks good. Possibly ready to merge in. Not tested though.
Comment #17
berdirWhy are you not using a COUNT(*)?
Also, can't we extend from database aggregator by now?
Same here, this should be possible as a SUM() query, if we query it directly anyway..
The class is named Monitoring*Core*Test, Payment is not core. So we need a separate integration test for this.
And we need a test_dependencies[] in the info file.
Also, commiting this is tricky, it will only work if testbot can get the proper dependency and it will be broken until we do. We can try as payment is on d.o, but I'm not sure if it will work.
Comment #19
Anushka-mp commentedSUM() and COUNT(*) expressions added, separate integration tests created and test dependancies added.
Comment #21
berdirSo we have to commit this and then wait until the dependencies are rebuilt, then we should get payment and the test should work. Alternatively, we can commit without the test and do that as a follow-up.
search_api is now there, so we can add the test for that back.
Comment #22
berdirOk, I just committed the payment test dependency separately. Let's wait day, then re-roll this and then it should work.
Comment #23
miro_dietikerProviding updated patch without test dependency.
Comment #28
miro_dietikerYay! Now it passes.
Committed and pushed.