Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Due the reason that API is paid, would be nice to have info how many requests in this month was sent on the current installation.
Would be nice to count requests for each type of requests https://cloud.google.com/vision/docs/pricing
Also maybe would be nice to have lock to not exceed some limit
Comment | File | Size | Author |
---|---|---|---|
#11 | interdiff-9-11.txt | 3.49 KB | ajalan065 |
#11 | 2685399-11.patch | 36.07 KB | ajalan065 |
#9 | 2685399-9.patch | 37.14 KB | ajalan065 |
Comments
Comment #2
eugene.ilyin CreditAttribution: eugene.ilyin as a volunteer and at DrupalJedi commentedComment #3
eugene.ilyin CreditAttribution: eugene.ilyin as a volunteer and at DrupalJedi commentedComment #4
marcoscanoDo you know if there is a way of retrieving this information from the API?
I was willing to move this issue forward, but I have looked into the documentation and did not found a way to do so, and apparently some other people neither: http://stackoverflow.com/questions/36096176/how-can-i-get-usage-data-for...
Or is the idea just to store this information locally based on the calls done by the module? (assuming then that the application will be the only one being used for a given account/quota)
Comment #5
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedHi marcoscano,
Thank you for showing your interest in the issue.
Actually, there is no such way of retrieving the information directly from the API.
This is partially true, however with a subproblem.
Just storing the number of calls locally won't solve the issue. As because this information is directly attached to the google_vision module, hence if the user disables the module, this information would be lost, thus resetting the count to the initial value.
If this subproblem is tackled accordingly, we can build on this issue.
Please let me know if any further queries need to be answered.
Comment #6
eugene.ilyin CreditAttribution: eugene.ilyin as a volunteer and at DrupalJedi commentedYes, I know that data will be lost if module will be disabled. But it's better than nothing. Let's start from it.
Comment #7
eugene.ilyin CreditAttribution: eugene.ilyin as a volunteer and at DrupalJedi commentedComment #8
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedAssigning it to myself, as I am working on it.
Comment #9
ajalan065 CreditAttribution: ajalan065 as a volunteer commentedHere is the patch which counts the sent requests.
The mechanism on which the patch works:
1. The status report of the API calls requested is shown under the Reports section of the site.
2. The number of calls made is reset at the end of each month, or we can say, with the start of the next month.
3. Maximum limits for each feature can be set at the Google Vision settings page.
4. If the limits exceed, a drupal message will be shown each time the user tries to use the exhausted features.
5. The reports show the current(today's) date, and the due date(which is the first day of the successive month), in addition to, the number of calls requested and the maximum calls allowed.
6. The simple tests for the issue have also been developed, considering any one of the features as the test feature to demonstrate the functionality of the issue.
Assigning it to Eugene for the review.
Please review :)
Comment #10
eugene.ilyin CreditAttribution: eugene.ilyin as a volunteer and at DrupalJedi commentedI think you can make code shorter if you will use something like this:
$build_options = [
...
'landmark_detection' => 'Landmark Detection',
'logo_detection' => 'Logo Detection',
...
];
and iterate over the elements in the loop.
Comment #11
ajalan065 CreditAttribution: ajalan065 as a volunteer commentedHere is the new patch with suggestions implemented.
The similar loop cannot be applied to the next half of the controller, as the labels have different names, so it would be of no use to do so.
The optimized and minimized code is patched here.
Please review :)