function devel_generate_add_statistics

Same name in other branches
  1. 6.x-1.x devel_generate.inc \devel_generate_add_statistics()
  2. 7.x-1.x devel_generate/devel_generate.inc \devel_generate_add_statistics()
  3. 4.x devel_generate/devel_generate.module \devel_generate_add_statistics()

Generate statistics information for a node.

Parameters

\Drupal\node\NodeInterface $node: A node object.

1 call to devel_generate_add_statistics()
devel_generate_entity_insert in devel_generate/devel_generate.module
Implements hook_entity_insert().

File

devel_generate/devel_generate.module, line 137

Code

function devel_generate_add_statistics(NodeInterface $node) {
    $statistic = array(
        'nid' => $node->id(),
        'totalcount' => mt_rand(0, 500),
        'timestamp' => REQUEST_TIME - mt_rand(0, $node->getCreatedTime()),
    );
    $statistic['daycount'] = mt_rand(0, $statistic['totalcount']);
    db_insert('node_counter')->fields($statistic)
        ->execute();
}