CUL-DigitalServices / libraries-gateway

Cambridge Libraries
1 stars 4 forks source link

Opening hours missing - the wrong db column is being read #228

Closed ucamhal closed 10 years ago

ucamhal commented 10 years ago

See the postit on the library gateway board. The complaint is that opening hours are not always displayed (even though they are in the library directory).

I've looked into this and the code is accessing the wrong opening hours column (there are 3!).

It's reading libraries.opening_hours, but should be using libraries.new_opening which is what the library directory uses.

2 examples: http://www.libraries.cam.ac.uk/find-a-library/ancient-india-and-iran-trust http://www.lib.cam.ac.uk/libraries_directory/libraries_directory.cgi?library_id=71&type_code=A

select library_id, library_name, opening_hours, new_opening, opening_hours_txt from libraries where library_name='Ancient India and Iran Trust';
+------------+------------------------------+-------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
| library_id | library_name                 | opening_hours                                                                 | new_opening                                                                                                                                                                                                            | opening_hours_txt                                                                                                                          |
+------------+------------------------------+-------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
|         71 | Ancient India and Iran Trust | Mon.-Thurs.: 9am-1pm, Fri.: 09:30am-13:30pm. Afternoons by appointment only. | <table><tr><td>Term:</td><td>Mon-Thu 09:00-13:00, Fri 09:30-13:30</td></tr><tr><td>Vacation:</td><td>Mon-Thu 09:00-13:00, Fri 09:30-13:30</td></tr><tr><td colspan=2>Afternoons by appointment only.</td></tr></table> | Term: Mon-Thu 09:00-13:00, Fri 09:30-13:30. Vacation: Mon-Thu 09:00-13:00, Fri 09:30-13:30. Opening notes: Afternoons by appointment only. |
+------------+------------------------------+-------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

http://www.lib.cam.ac.uk/libraries_directory/libraries_directory.cgi?library_id=38&type_code=A http://www.libraries.cam.ac.uk/find-a-library/computer-laboratory

mysql> select library_id, library_name, opening_hours, new_opening, opening_hours_txt from libraries where library_name='Computer Laboratory';
+------------+---------------------+---------------+---------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+
| library_id | library_name        | opening_hours | new_opening                                                                                                               | opening_hours_txt                                        |
+------------+---------------------+---------------+---------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+
|         38 | Computer Laboratory | NULL          | <table><tr><td>Term:</td><td>Mon-Fri 09:00-17:00</td></tr><tr><td>Vacation:</td><td>Mon-Fri 09:00-17:00</td></tr></table> | Term: Mon-Fri 09:00-17:00. Vacation: Mon-Fri 09:00-17:00 |
+------------+---------------------+---------------+---------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+
1 row in set (0.00 sec)
Coenego commented 10 years ago

Apparently we don't have the latest dump of the database on the dev instance (new_opening column is missing in libraries table). Maybe @timdegroote knows how/where to fetch a copy of the latest data/structure.

CREATE TABLE `libraries` (
  `library_id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
  `library_code` varchar(5) NOT NULL DEFAULT '',
  `library_name` varchar(100) NOT NULL DEFAULT '',
  `dbase_id` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `library_system_id` tinyint(3) unsigned NOT NULL DEFAULT '1',
  `cs_id` tinyint(3) unsigned NOT NULL DEFAULT '1',
  `security_system_id` tinyint(3) unsigned NOT NULL DEFAULT '1',
  `has_items` enum('Y','N') NOT NULL DEFAULT 'Y',
  `type_code` enum('C','D','O','U','E') NOT NULL DEFAULT 'C',
  `UC_id` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `library_notes` text,
  `display_index` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `library_display_name` varchar(100) DEFAULT NULL,
  `admits` text,
  `stock` text,
  `special_collections` text,
  `services` text,
  `opening_hours` text,
  `publications` varchar(250) DEFAULT NULL,
  `see` varchar(250) DEFAULT NULL,
  `see_also` varchar(250) DEFAULT NULL,
  `display_notes` text,
  `display_only` enum('Y','N') NOT NULL DEFAULT 'N',
  `contributes_to` varchar(250) DEFAULT NULL,
  `uses_newton` enum('Y','N') NOT NULL DEFAULT 'Y',
  PRIMARY KEY (`library_id`)
) ENGINE=MyISAM AUTO_INCREMENT=129 DEFAULT CHARSET=latin1;
ucamhal commented 10 years ago

I've got a copy of the latest I could give you. Tim dumped it from the db on Fri.

Coenego commented 10 years ago

Created PR at https://github.com/CUL-DigitalServices/libraries-gateway/pull/229

Coenego commented 10 years ago

This has been fixed in https://github.com/CUL-DigitalServices/libraries-gateway/pull/229