suminagashi/figures

Statistics for your symfony app, simply.

Installs: 13

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Type:symfony-bundle

dev-master 2020-08-02 11:14 UTC

This package is auto-updated.

Last update: 2024-04-29 04:40:16 UTC


README

#Figures

Statistics for your symfony app, simply.

Install the bundle :

Flex recipe incoming...

Register the bundle :

// config/bundles.php

return [
    ...
    Suminagashi\FiguresBundle\FiguresBundle::class => ['all' => true],
];

Add the Figure entity to your database :

php bin/console doctrine:schema:update --force

Setup your entities :

First you need to import Suminagashi\FiguresBundle\Annotation\Watch annotation. Then you have to write add the key of your stat, the type (cumul or count) and the lifecycle (at which lifecycle you want the stat to register).

use Suminagashi\FiguresBundle\Annotation\Watch;

class Product
{
    //...

    /**
     *
     * @ORM\Column(type="integer")
     *
     * @Watch(key="product:price", type="cumul", lifecycle="update")
     * @Watch(key="product:sell", type="count", lifecycle="create")
     */
    private $price;

    //***

How does this works :

There is two mode of stats calculation :

  • count is for counting the number of sales (e.g).
  • cumul is for calculating the amount of sales (e.g).

How to get a specific stats :

First you need to import Suminagashi\FiguresBundle\Tools\Figures in your code. Then you can autowire the class and start using it. We provide few methods to help you :

$figures = new Figures();

$figures->all('key');
$figures->getToday('key');
$figures->getLastweek('key');
$figures->getLastmonth('key');
$figures->getLastyear('key');
$figures->get('key', 'start', 'end');

Coming :

  • Stat percentages calculations.
  • Statut type
  • Better exception handling
  • Handle delete (cascade)