Skip to content

bk: Подготовка к сбору статистики#49

Open
bkeenke wants to merge 1 commit intodanuk:statsfrom
bkeenke:stats
Open

bk: Подготовка к сбору статистики#49
bkeenke wants to merge 1 commit intodanuk:statsfrom
bkeenke:stats

Conversation

@bkeenke
Copy link
Collaborator

@bkeenke bkeenke commented Mar 5, 2026

No description provided.

title => 'логин',
user_for_stats => 1,
count_for_stats => 1,
},
Copy link
Owner

Choose a reason for hiding this comment

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

Причем тут user? Может use?
И не нужно двух переменных, сделай проще:

stats_mode => 'inc' # inc или diff

Copy link
Owner

Choose a reason for hiding this comment

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

inc - режим счетчика
diff - режим, когда вычисляем разницу между текущим значением и новым
asis - режим, когда используем новое значение (из args)

}

sub stats {
my ($self, $action, $args) = @_;
Copy link
Owner

@danuk danuk Mar 6, 2026

Choose a reason for hiding this comment

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

Для режима diff используй разницу значений:

my $method = "get_$field";
$value = $self->$method + 0 - $args->{$field}

my @fields;

for my $field (keys %$structure) {
push @fields, $field if $structure->{$field}->{user_for_stats};
Copy link
Owner

Choose a reason for hiding this comment

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

Проверяй наличие поля: stats_mode


next unless exists $args->{$field};

my $value = $self->structure->{$field}->{count_for_stats}
Copy link
Owner

Choose a reason for hiding this comment

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

Проверяем, что stats_mode eq 'inc'

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.

2 participants