Skip to content

Commit e9a97e1

Browse files
committed
Updated the way we get info about and clear the queue
1 parent 96a4426 commit e9a97e1

File tree

1 file changed

+34
-26
lines changed

1 file changed

+34
-26
lines changed

os2web_esdh_provider.admin.inc

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function _os2web_esdh_provider_status() {
6666
$watchdog_table = theme('table', array('header' => $watchdog_head, 'rows' => $watchdog_rows));
6767
}
6868

69-
$queue_status = '';
69+
$queue_markup = '';
7070

7171
if (variable_get('os2web_esdh_provider_queue_enabled', FALSE)) {
7272
// Status for external meeting importer.
@@ -75,34 +75,43 @@ function _os2web_esdh_provider_status() {
7575
if (!lock_acquire('os2web_esdh_provider_queue')) {
7676
$queue_markup = '<h2>Meeting import: running!</h2>';
7777
}
78+
}
7879

79-
$queue_markup .= drupal_render(drupal_get_form('os2web_esdh_provider_queue_form'));
80-
$queue_markup .= '<h3>In queue</h3>';
80+
$queue_markup .= drupal_render(drupal_get_form('os2web_esdh_provider_queue_form'));
81+
$queue_markup .= '<h3>In queue</h3>';
8182

82-
$queue_header = array(t('Publication id:'), t('uri'), t('Force'));
83-
$queue_rows = array();
83+
$queue_header = array(t('Publication id:'), t('uri'), t('Force'));
84+
$queue_rows = array();
8485

85-
$queue = DrupalQueue::get('acadre_mm_import');
86-
while ($item = $queue->claimItem()) {
87-
if (isset($item->data['meeting'])) {
88-
$queue_rows[] = array(
89-
$item->data['meeting']['id'],
90-
$item->data['meeting']['uri'],
91-
$item->data['force'],
92-
);
93-
}
86+
$queue_name = 'acadre_mm_import';
87+
$query = db_select('queue', 'q')
88+
->fields('q', array('item_id', 'data', 'created'))
89+
->condition('q.name', $queue_name)
90+
->extend('PagerDefault')
91+
->limit(25)
92+
->execute();
93+
94+
foreach ($query as $record) {
95+
$data = unserialize($record->data);
96+
if (isset($data['meeting'])) {
97+
$queue_rows[] = array(
98+
$data['meeting']['id'],
99+
$data['meeting']['uri'],
100+
$data['force'],
101+
);
94102
}
103+
}
95104

96-
$queue_status .= '<br /><hr /><br />' . $queue_markup . theme('table', array(
97-
'header' => $queue_header,
98-
'rows' => $queue_rows,
99-
'empty' => t('Queue is empty'),
100-
));
105+
$queue_status = '<br /><hr /><br />' . $queue_markup . theme('table', array(
106+
'header' => $queue_header,
107+
'rows' => $queue_rows,
108+
'empty' => t('Queue is empty'),
109+
));
101110

102-
$queue_status .= '<br /><hr /><br />';
103-
}
111+
$queue_status .= '<br /><hr /><br />';
104112

105113
$import_form = drupal_get_form('os2web_esdh_provider_import_form');
114+
106115
return '<h2>' . t('ESDH Provider API plugin status') . '</h2>' .
107116
theme('table', array('header' => $head, 'rows' => $rows)) .
108117
'<h3>' . t('Last agenda import was successfully run at %time', array('%time' => format_date(variable_get('os2web_esdh_provider_last_import', 0)))) . '</h3>' .
@@ -128,10 +137,9 @@ function os2web_esdh_provider_queue_form($form_state) {
128137
*/
129138
function os2web_esdh_provider_queue_form_submit(&$form, &$form_state) {
130139
// Empty queue.
131-
$queue = DrupalQueue::get('acadre_mm_import');
132-
while ($item = $queue->claimItem()) {
133-
$queue->deleteItem($item);
134-
}
140+
db_delete('queue')
141+
->condition('name', 'acadre_mm_import')
142+
->execute();
135143

136144
drupal_set_message(t('Deleted queue'));
137145
}
@@ -256,7 +264,7 @@ function _os2web_esdh_provider_status_confirm_submit($form, &$form_state) {
256264
}
257265
$queue->createItem(array('post_import_process' => TRUE));
258266

259-
drupal_goto('admin/config/os2web/esdh_provider');
267+
drupal_goto('admin/config/os2web_esdh_provider/status');
260268
}
261269
// Use normal batch processing if external queue is disabled.
262270
else {

0 commit comments

Comments
 (0)