Skip to content
This repository was archived by the owner on Oct 29, 2020. It is now read-only.

Commit 7351a77

Browse files
committed
Merge pull request #4628 from angaither/progress-log
Progress log table
2 parents a1ed011 + 93b27e1 commit 7351a77

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

lib/modules/dosomething/dosomething_reportback/dosomething_reportback.cron.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ function dosomething_reportback_cron() {
2222
// Updated reportback counts accordingly.
2323
foreach ($results as $result) {
2424
dosomething_helpers_set_variable('node', $result->nid, 'sum_rb_quanity', (int) $result->total);
25+
26+
// Add a row to the reportback progress log table.
27+
db_insert('dosomething_reportback_progress_log')
28+
->fields(array(
29+
'nid' => $result->nid,
30+
'quantity' => $result->total,
31+
'timestamp' => REQUEST_TIME,
32+
))
33+
->execute();
2534
}
2635

2736
}

lib/modules/dosomething/dosomething_reportback/dosomething_reportback.install

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,38 @@ function dosomething_reportback_schema() {
228228
),
229229
'primary key' => array('rbid', 'fid'),
230230
);
231+
$schema['dosomething_reportback_progress_log'] = array(
232+
'description' => 'Log table of the total quantity of campaign nodes over time.',
233+
'fields' => array(
234+
'id' => array(
235+
'description' => 'Primary key of log table.',
236+
'type' => 'serial',
237+
'unsigned' => TRUE,
238+
'not null' => TRUE,
239+
),
240+
'nid' => array(
241+
'description' => 'The {node}.nid of the campaign.',
242+
'type' => 'int',
243+
'not null' => TRUE,
244+
'default' => 0,
245+
),
246+
'quantity' => array(
247+
'type' => 'int',
248+
'description' => 'The total quantity of approved reportbacks at this time.',
249+
'not null' => TRUE,
250+
),
251+
'timestamp' => array(
252+
'description' => 'The Unix timestamp of the time this quantity was stored.',
253+
'type' => 'int',
254+
'not null' => TRUE,
255+
'default' => 0,
256+
),
257+
),
258+
'primary key' => array('id'),
259+
'indexes' => array(
260+
'nid' => array('nid'),
261+
),
262+
);
231263
// Add a custom cache table.
232264
$schema['cache_dosomething_reportback'] = drupal_get_schema_unprocessed('system', 'cache');
233265
return $schema;
@@ -731,3 +763,12 @@ function dosomething_reportback_update_7026(&$sandbox) {
731763
}
732764
}
733765
}
766+
767+
/**
768+
* Create a reportback progress log table.
769+
*/
770+
function dosomething_reportback_update_7027(&$sandbox) {
771+
$table_name = 'dosomething_reportback_progress_log';
772+
$schema = dosomething_reportback_schema();
773+
db_create_table($table_name, $schema[$table_name]);
774+
}

0 commit comments

Comments
 (0)