Skip to content

[RFC] API endpoint for combined Joomla & PHP version #37#40

Closed
alikon wants to merge 6 commits intojoomla:masterfrom
alikon:patch-2
Closed

[RFC] API endpoint for combined Joomla & PHP version #37#40
alikon wants to merge 6 commits intojoomla:masterfrom
alikon:patch-2

Conversation

@alikon
Copy link
Copy Markdown

@alikon alikon commented Sep 5, 2018

Pull Request for Issue #37 .

Summary of Changes

  • create a new table
  • populate the new table with current data
  • implement the insert trigger
  • implement the update trigger
  • expose the new api endpoint

to do

  • mod_joomladata ??

Testing Instructions

apply this patch
from the mysql console
drop the current insert trigger
drop the current update trigger
create the new insert trigger
create the new update trigger
call the new api endopoint http://localhost/jstats/www/?source=cms_php

this is how the new API endpoint response look like

screenshot from 2018-09-05 20-09-38

Additional comments

if this will be accepted documentation https://developer.joomla.org/about/stats/api.html should be updated
i was not able to run the bin/stats install for the trigger sections 👶
i've switched to the mysql console where it works successfully

@mbabker
Copy link
Copy Markdown

mbabker commented Sep 5, 2018

All this trigger stuff is over my head but it seems we're missing the update trigger to decrement things. Beyond that though seems good to me.

I'd probably do the API response as a nested array though instead of how you've got it.

{
    "3.8.12": {
        "7.1.21": 1
    },
    "3.8.11": {
        "7.0.31": 1,
        "5.3.10": 1
    }
}

@alikon
Copy link
Copy Markdown
Author

alikon commented Sep 5, 2018

yes, sure the update trigger is currently missing.... i'm on this sorry i'm quite lazy 😄
but it is on my to do list with high priority ... coming soon...

@alikon
Copy link
Copy Markdown
Author

alikon commented Sep 5, 2018

I'd probably do the API response as a nested array though instead of how you've got it.

again yes, there are a lot of things that can be done in a better way.... and this is surely one of these...

@alikon
Copy link
Copy Markdown
Author

alikon commented Sep 5, 2018

what about the bin/stats install for the trigger sections issue
did you experienced it already ?

@mbabker
Copy link
Copy Markdown

mbabker commented Sep 5, 2018

I haven't run the install command from a long time. I just do a DB backup if I need a current snapshot. So, no guarantees on the state of that command (or what issues it may or may not have with interacting in the database API).

@alikon
Copy link
Copy Markdown
Author

alikon commented Sep 6, 2018

added the update trigger

@alikon
Copy link
Copy Markdown
Author

alikon commented Sep 7, 2018

with the nested array now the response should be like this
screenshot from 2018-09-07 18-34-08

@mbabker
Copy link
Copy Markdown

mbabker commented Sep 7, 2018

This needs to go through buildResponseData or something similar to ensure the grouping/sanitization step takes place as required (remember the API does not allow access to get the full versions of everything without special permission, result sets are grouped generally on minor versions or the first word of the O/S name for those).

@alikon
Copy link
Copy Markdown
Author

alikon commented Sep 8, 2018

not sure to understand, 🤕 may i ask "someone else" to cover this side ?

@wilsonge
Copy link
Copy Markdown

wilsonge commented Sep 8, 2018

He means using this function https://github.com/joomla/statistics-server/blob/master/src/Views/Stats/StatsJsonView.php#L179-L205 which if you notice calls a data sanitisation method.

@alikon
Copy link
Copy Markdown
Author

alikon commented Sep 9, 2018

yeah, but I still don't fully understand why, ect.. i know it's me 🤕

API does not allow access to get the full versions of everything without special permission

what special permission ?
i'm able to get the full info from API without any special permission
screenshot from 2018-09-09 11-32-28

did you mean to expose the percentage instead of the total number of each items?
did you mean some kind of sort should be made on result before to expose them?

@mbabker
Copy link
Copy Markdown

mbabker commented Sep 9, 2018

So, there's a check in the controller to determine if the requestor is authorized to get the full raw data from the database. By default, that isn't the case (actually right now the only way to get raw data is to go through the database, the config value for what that header allows to see raw data isn't even set).

In the view, after building the initial response structure (which is geared toward allowing the raw data), there is a check if the view is giving the raw data response. If not, the view pushes the data through the sanitizeData method which groups data on a key (so for things with versions those are grouped on <major>.<minor>, operating systems grouped on the first word) then gives a percentage instead of the raw total.

When authorized raw data, you get this response:

{
    "data": {
        "php_version": {
            "7.1.20": 5,
            "7.0.31": 5,
            "5.6.1": 3,
            "5.6.20": 5
        }
    },
    "total": 18
}

When not authorized raw data, you get this response:

{
    "data": {
        "php_version": {
            "7.1": 27.78,
            "7.0": 27.78,
            "5.6": 44.44
        }
    },
    "total": 18
}

@alikon
Copy link
Copy Markdown
Author

alikon commented Apr 8, 2019

reworked on #43

@alikon alikon closed this Apr 8, 2019
@alikon alikon deleted the patch-2 branch April 8, 2019 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants