Skip to content

Commit

Permalink
Merge pull request #8 from DiamondLightSource/SCI-8592
Browse files Browse the repository at this point in the history
New SP retrieve_sessions_for_beamline_and_run
  • Loading branch information
KarlLevik committed Apr 23, 2019
2 parents 950a8e9 + b8fba90 commit e4e3810
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
39 changes: 36 additions & 3 deletions schema/routines.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- MySQL dump 10.17 Distrib 10.3.13-MariaDB, for Linux (x86_64)
-- MySQL dump 10.17 Distrib 10.3.14-MariaDB, for Linux (x86_64)
--
-- Host: localhost Database: ispyb_build
-- ------------------------------------------------------
-- Server version 10.3.13-MariaDB
-- Server version 10.3.14-MariaDB

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
Expand Down Expand Up @@ -3806,6 +3806,39 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `retrieve_sessions_for_beamline_and_run` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE PROCEDURE `retrieve_sessions_for_beamline_and_run`(
IN p_beamline varchar(15),
IN p_run varchar(7)
)
READS SQL DATA
COMMENT 'Returns a multi-row result-set with the sessions (mx12345-123), their start and end dates for beamline p_beamline and run p_run'
BEGIN
SELECT
bs.sessionId "sessionId",
concat(p.proposalCode, p.proposalNumber, '-', bs.visit_number) "session",
bs.startDate "startDate",
bs.endDate "endDate"
FROM Proposal p
INNER JOIN BLSession bs on p.proposalId = bs.proposalId
INNER JOIN v_run vr ON bs.startDate BETWEEN vr.startDate AND vr.endDate
WHERE bs.beamlinename = p_beamline AND vr.run = p_run
ORDER BY bs.startDate, bs.sessionId;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `retrieve_sessions_for_person_login` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
Expand Down Expand Up @@ -7290,4 +7323,4 @@ DELIMITER ;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2019-04-08 16:26:29
-- Dump completed on 2019-04-23 10:22:27
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
DELIMITER ;;
CREATE OR REPLACE DEFINER=`ispyb_root`@`%` PROCEDURE `retrieve_sessions_for_beamline_and_run`(
IN p_beamline varchar(15),
IN p_run varchar(7)
)
READS SQL DATA
COMMENT 'Returns a multi-row result-set with the sessions (mx12345-123), their start and end dates for beamline p_beamline and run p_run'
BEGIN
SELECT
bs.sessionId "sessionId",
concat(p.proposalCode, p.proposalNumber, '-', bs.visit_number) "session",
bs.startDate "startDate",
bs.endDate "endDate"
FROM Proposal p
INNER JOIN BLSession bs on p.proposalId = bs.proposalId
INNER JOIN v_run vr ON bs.startDate BETWEEN vr.startDate AND vr.endDate
WHERE bs.beamlinename = p_beamline AND vr.run = p_run
ORDER BY bs.startDate, bs.sessionId;
END;;

DELIMITER ;

0 comments on commit e4e3810

Please sign in to comment.