Skip to content

0.8.0

Compare
Choose a tag to compare
@palkan palkan released this 01 Oct 20:50
· 202 commits to master since this release

Features

Added ability to specify the debounce time to avoid spamming logs creation.

See PR #87.

Usage:

# 5000ms
rails generate logidze:model story --debounce_time=5000

You see the following in generated migration

CREATE TRIGGER logidze_on_stories
      BEFORE UPDATE OR INSERT ON stories FOR EACH ROW
      WHEN (coalesce(#{current_setting('logidze.disabled')}, '') <> 'on')
      EXECUTE PROCEDURE logidze_logger(null, 'updated_at', null, 5000);

How to upgrade.

Please run rails generate logidze:install --update to regenerate stored functions.

This feature checks if several logs came in within a debounce time period then only keep the latest one
by merging the latest in previous others.

The concept is similar to https://underscorejs.org/#debounce

without debounce_time

{
    "h": [
        {
            "c": {
                "content": "Content 1"
            },
            "v": 1,
            "ts": 0
        },
        {
            "c": {
                "content": "content 2",
                "active": true
            },
            "v": 2,
            "ts": 100
        },
        {
            "c": {
                "content": "content 3",
            },
            "v": 3,
            "ts": 101
        }
    ],
    "v": 3
}

with debounce_time of 10ms

{
    "h": [
        {
            "c": {
                "content": "Content 1"
            },
            "v": 1,
            "ts": 0
        },
        {
            "c": {
                "content": "content 3",
                "active": true
            },
            "v": 2,
            "ts": 101
        }
    ],
    "v": 3
}