Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHRAS-4085_data-volumes-api #4529

Merged
merged 12 commits into from
Jul 17, 2024
Merged

PHRAS-4085_data-volumes-api #4529

merged 12 commits into from
Jul 17, 2024

Conversation

jygaulier
Copy link
Member

@jygaulier jygaulier commented Jun 26, 2024

Changelog

Adds

  • PHRAS-4085: new route /api/v3/monitor/data/?oauth_token=xxx&blocksize=16ko&unit=mo&details=1
    blocksize is a number with possible units : '', 'o', 'octet', 'octets', 'Ko', 'Mo', 'Go' ; default: "" (same as 1 o) ==> disksize=size;
    unit sets the unit of size results
    details=1 to also get subdefs by collection/name
    e.g.:
{
    "meta": {
        "api_version": "3.0.0",
        "request": "GET /api/v3/monitor/data/",
        "response_time": "2024-06-27T12:29:25+00:00",
        "http_code": 200,
        "error_type": null,
        "error_message": null,
        "error_details": null,
        "charset": "UTF-8"
    },
    "response": {
        "unit": "Mo",
        "databoxes": {
            "1": {
                "sbas_id": 1,
                "viewname": "new_databox_name",
                "collections": {
                    "1": {
                        "coll_id": "1",
                        "name": "test",
                        "subdefs": {
                            "document": {
                                "count": 27,
                                "size": 54.17,
                                "disksize": 54.39
                            },
                            "preview": {
                                "count": 29,
                                "size": 4.61,
                                "disksize": 4.8
                            },
                            "preview_mobile": {
                                "count": 26,
                                "size": 1.32,
                                "disksize": 1.5
                            },
                            "thumbnail": {
                                "count": 29,
                                "size": 5.28,
                                "disksize": 5.53
                            },
                            "thumbnail_mobile": {
                                "count": 24,
                                "size": 0.12,
                                "disksize": 0.38
                            }
                        }
                    },
                    "26": {
                        "coll_id": "26",
                        "name": "ww",
                        "subdefs": {
                            "document": {
                                "count": 4,
                                "size": 5.65,
                                "disksize": 5.69
                            },
                            "preview": {
                                "count": 4,
                                "size": 0.52,
                                "disksize": 0.56
                            },
                            "preview_mobile": {
                                "count": 4,
                                "size": 0.17,
                                "disksize": 0.19
                            },
                            "thumbnail": {
                                "count": 4,
                                "size": 0.7,
                                "disksize": 0.72
                            },
                            "thumbnail_mobile": {
                                "count": 4,
                                "size": 0.02,
                                "disksize": 0.06
                            }
                        }
                    }
                },
                "subdefs": {
                    "document": {
                        "count": 31,
                        "size": 59.81,
                        "disksize": 60.08
                    },
                    "preview": {
                        "count": 33,
                        "size": 5.14,
                        "disksize": 5.36
                    },
                    "preview_mobile": {
                        "count": 30,
                        "size": 1.49,
                        "disksize": 1.69
                    },
                    "thumbnail": {
                        "count": 33,
                        "size": 5.98,
                        "disksize": 6.25
                    },
                    "thumbnail_mobile": {
                        "count": 28,
                        "size": 0.13,
                        "disksize": 0.44
                    }
                },
                "count": 155,
                "size": 72.55,
                "disksize": 73.81
            }
        },
        "downloads": {
            "count": 33,
            "days_oldest": 21,
            "expired": 32,
            "size": 4.36,
            "disksize": 4.73
        }
    }
}
  • new route /api/v3/databoxes/68/monitor/data/?oauth_token=xxx&blocksize=16ko&unit=mo&details=1
  • add column size in LazaretFiles table
  • add command bin/maintenance lazaret:set_sizes to fill the null size column of the LazaretFiles

@jygaulier jygaulier changed the title PHRAS-4085_data-volumes-api PHRAS-4085_data-volumes-api WIP OK TO TEST Jun 27, 2024
@jygaulier jygaulier added the WIP label Jun 27, 2024
@jygaulier jygaulier force-pushed the PHRAS-4085_data-volumes-api branch from 6d3d657 to db021b6 Compare June 27, 2024 13:12
@nmaillat nmaillat added the version-bump-back bump of Phraseanet version label Jun 27, 2024
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();

$disksize = ceil($row['size'] / $blocksize) * $blocksize;;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO...
disksize is per file, eg. if blocksize=16ko, the disksize of every file is a multiple of 16ko :

  • 10 small files (1 ko) = 10 * 16 ko ==> 160 ko (good)

here we get 10 * 1 ko = 10 ko ==> 16 ko (wrong)

Do blocksize, divider etc in sql, like in other requests.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


$this
->setDescription('Set the null size in the LazaretFiles table')
->addOption('dry-run', null, InputOption::VALUE_NONE, 'dry run, count')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better use --dry like in recent commands

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

/** @var LazaretFile $lazaretNullSize */
foreach ($lazaretNullSizes as $lazaretNullSize) {
$lazaretFileName = $path .'/'.$lazaretNullSize->getFilename();
$media = $this->container->getMediaFromUri($lazaretFileName);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrap in a try/catch just in case of missing file, and set size to 0 in case of error.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@nmaillat nmaillat changed the title PHRAS-4085_data-volumes-api WIP OK TO TEST PHRAS-4085_data-volumes-api Jul 17, 2024
@nmaillat nmaillat removed the WIP label Jul 17, 2024
@nmaillat nmaillat merged commit 5556462 into master Jul 17, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.1 Enhancement version-bump-back bump of Phraseanet version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants