a
This commit is contained in:
parent
9492afe5ad
commit
86d9af63a9
@ -20,10 +20,13 @@ module.exports = function (sequelize, DataTypes) {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: true
|
||||
},
|
||||
date: {
|
||||
init_date: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
},
|
||||
},
|
||||
end_date: {
|
||||
type: DataTypes.DATE,
|
||||
},
|
||||
init_available_date: {
|
||||
type: DataTypes.DATE,
|
||||
},
|
||||
@ -109,22 +112,24 @@ module.exports = function (sequelize, DataTypes) {
|
||||
Event.UserCreate = Event.belongsTo(models.User, { foreignKey: 'userId', as: "user" });
|
||||
Event.Venue = Event.belongsTo(models.Venue, { foreignKey: 'venueId', as: "venue" });
|
||||
|
||||
Event.Schedule = Event.hasMany(models.EventSchedule, { foreignKey: 'eventId', as: "schedule" });
|
||||
Event.Details = Event.hasMany(models.EventDetail, { foreignKey: 'eventId', as: "details" });
|
||||
|
||||
Event.Comments = Event.hasMany(models.Comment, {
|
||||
foreignKey: 'entityId',
|
||||
scope: {
|
||||
entityName: 'event'
|
||||
},
|
||||
as: "comments"
|
||||
});
|
||||
//OJOJOJOJOJOJOJJOJ
|
||||
// OJO GENERA UN FOREIGN KEY Con eventos y habrá ID de otras entidades que no exitan en la tabla eventos, porque son post o speakers
|
||||
// Event.Comments = Event.hasMany(models.Comment, {
|
||||
// foreignKey: 'entityId',
|
||||
// scope: {
|
||||
// entityName: 'event'
|
||||
// },
|
||||
// as: "comments"
|
||||
// });
|
||||
|
||||
Event.Multimedias = Event.hasMany(models.Multimedia, {
|
||||
foreignKey: 'entityId',
|
||||
scope: {
|
||||
entityName: 'event'
|
||||
},
|
||||
as: { singular: 'multimedia', plural: 'multimedias' }});
|
||||
// Event.Multimedias = Event.hasMany(models.Multimedia, {
|
||||
// foreignKey: 'entityId',
|
||||
// scope: {
|
||||
// entityName: 'event'
|
||||
// },
|
||||
// as: { singular: 'multimedia', plural: 'multimedias' }});
|
||||
|
||||
Event.Reservations = Event.hasMany(models.EventReservation, { foreignKey: 'eventId', as: "reservations" });
|
||||
Event.Inscriptions = Event.hasMany(models.EventInscription, { foreignKey: 'eventId', as: "inscriptions" });
|
||||
@ -139,10 +144,10 @@ module.exports = function (sequelize, DataTypes) {
|
||||
}
|
||||
});
|
||||
|
||||
Event.addScope('includeSchedule', () => {
|
||||
Event.addScope('includeDetails', () => {
|
||||
return {
|
||||
include: [
|
||||
{ model: sequelize.models.EventSchedule, as: 'schedule' }
|
||||
{ model: sequelize.models.EventDetail, as: 'details' }
|
||||
]
|
||||
}
|
||||
});
|
||||
@ -150,8 +155,8 @@ module.exports = function (sequelize, DataTypes) {
|
||||
Event.addScope('includeSpeakers', () => {
|
||||
return {
|
||||
include: [{
|
||||
model: sequelize.models.EventSchedule,
|
||||
as: 'schedule',
|
||||
model: sequelize.models.EventDetail,
|
||||
as: 'eventdetail',
|
||||
where: {
|
||||
speakerId: {
|
||||
[Sequelize.Op.ne]: null
|
||||
|
||||
@ -35,7 +35,7 @@ routes.get('/events/next',
|
||||
PaginateMiddleware.middleware(),
|
||||
SortMiddleware.middleware({ default: "init_available_date" }),
|
||||
eventController.find({
|
||||
scopes: ['defaultScope', 'next', 'includeVenue', 'includeSchedule', 'includeSpeakers'],
|
||||
scopes: ['defaultScope', 'next', 'includeVenue', 'includeDetails', 'includeSpeakers'],
|
||||
}),
|
||||
//eventController.find
|
||||
// model.scope('next').findAll();
|
||||
|
||||
@ -18,15 +18,11 @@ const extraMethods = {
|
||||
if (context.scopes.includes('includeSpeakers')) {
|
||||
rows = rows.map(event => Object.assign({},
|
||||
event,
|
||||
{ schedule: undefined },
|
||||
{ speakers: event.schedule.map(schedule => ({ ...schedule.speaker, order: schedule.order }) ) }
|
||||
{ details: undefined },
|
||||
{ speakers: event.details.map(details => ({ ...details.speaker, order: details.order }) ) }
|
||||
));
|
||||
}
|
||||
|
||||
/*rows.map(event => {
|
||||
const info = event.schedule
|
||||
})*/
|
||||
|
||||
return {
|
||||
count: rows.length,
|
||||
rows: rows
|
||||
@ -69,7 +65,7 @@ const extraMethods = {
|
||||
}*/
|
||||
|
||||
// Incluir
|
||||
findOptions.include.push({
|
||||
/* findOptions.include.push({
|
||||
model: models.EventSchedule,
|
||||
as: 'schedule',
|
||||
include: {
|
||||
@ -105,6 +101,7 @@ const extraMethods = {
|
||||
} catch(error) {
|
||||
throw error;
|
||||
}
|
||||
*/
|
||||
},
|
||||
|
||||
fetchOne: async (params, context) => {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (sequelize, DataTypes) {
|
||||
const EventSchedule = sequelize.define('EventSchedule', {
|
||||
const EventDetail = sequelize.define('EventDetail', {
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
@ -20,22 +20,26 @@ module.exports = function (sequelize, DataTypes) {
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.STRING,
|
||||
},
|
||||
},
|
||||
type: {
|
||||
type: DataTypes.STRING,
|
||||
default: 'detail', //info, speaker, schedule, detail
|
||||
}
|
||||
}, {
|
||||
indexes: [{
|
||||
unique: false,
|
||||
fields: ['speakerId']
|
||||
}],
|
||||
tableName: 'events_schedules',
|
||||
tableName: 'events_details',
|
||||
freezeTableName: true,
|
||||
timestamps: true,
|
||||
});
|
||||
|
||||
EventSchedule.associate = function (models) {
|
||||
EventSchedule.Event = EventSchedule.belongsTo(models.Event, { foreignKey: 'eventId', as: "event" });
|
||||
EventSchedule.Speaker = EventSchedule.belongsTo(models.Speaker, {foreignKey: 'speakerId', as: "speaker"});
|
||||
EventDetail.associate = function (models) {
|
||||
EventDetail.Event = EventDetail.belongsTo(models.Event, { foreignKey: 'eventId', as: "event" });
|
||||
EventDetail.Speaker = EventDetail.belongsTo(models.Speaker, {foreignKey: 'speakerId', as: "speaker"});
|
||||
};
|
||||
|
||||
|
||||
return EventSchedule;
|
||||
return EventDetail;
|
||||
};
|
||||
@ -63,7 +63,7 @@ module.exports = function (sequelize, DataTypes) {
|
||||
foreignKey: 'speakerId'
|
||||
});
|
||||
|
||||
Speaker.Schedule = Speaker.hasMany(models.EventSchedule, { foreignKey: 'speakerId', as: "schedule" });
|
||||
Speaker.EventDetails = Speaker.hasMany(models.EventDetail, { foreignKey: 'speakerId', as: "eventdetails" });
|
||||
Speaker.Questions = Speaker.hasMany(models.EventQuestion, { foreignKey: 'speakerId', as: "questions" });
|
||||
|
||||
Speaker.Multimedias = Speaker.hasMany(models.Multimedia, {
|
||||
|
||||
@ -7,13 +7,17 @@ script-carga-bd-values.sql
|
||||
script-carga-bd-venues.sql
|
||||
script-carga-bd-envents_venues_aux.sql
|
||||
script-carga-bd-speaker_types.sql
|
||||
script-carga-bd-entidades.sql
|
||||
|
||||
insert into lqdvi_v2.entities_entities_types (entityid, typeid, createdAt, updatedAt)
|
||||
select id, '76b17163-a167-11e9-a57c-000c295f0f58', now(), now() from `entities`
|
||||
|
||||
insert into lqdvi_v2.`multimedia_files` (id, name, description, typeid, provider, code, url, createdAt, userId, updatedAt)
|
||||
SELECT a.id, a.title, a.description, '166fb0aa-5182-4d22-addd-818337194cd7', a.provider, a.code, a.url, a.created, '0939bb2a-d33d-4290-ac81-fc9faa1c015e', now()
|
||||
FROM lqdvi.`video` as a;
|
||||
|
||||
|
||||
insert into lqdvi_v2.`events` (id, name, description, date, init_available_date, end_available_date, gmt, assistants, confirmed, state, typeId, url_streaming, url_poll, url_registration,
|
||||
insert into lqdvi_v2.`events` (id, name, description, init_date, init_available_date, end_available_date, gmt, assistants, confirmed, state, typeId, url_streaming, url_poll, url_registration,
|
||||
userId, CreatedAt, venueId, campaign_text, UpdatedAt)
|
||||
SELECT id, title, address , date, avalible, date, GMT, assistants, confirmed, status, typeId, streaming, poll, url_registration, '0939bb2a-d33d-4290-ac81-fc9faa1c015e',
|
||||
now(), '120c5a99-6e9b-4cc2-875a-af0f8db00e4b', campaign_text, now()
|
||||
@ -65,9 +69,9 @@ SELECT UUID() as ID, speakerID as eventID, 'speaker', videoId as multimediafilei
|
||||
FROM lqdvi.`video-speaker`
|
||||
where videoId in (select id from lqdvi_v2.multimedia_files);
|
||||
|
||||
//METEMOS LAS AGENDAS DE TODOS LOS CONGRESOS
|
||||
//METEMOS LOS DETALLES DE LOS CONGRESOS AGENDAS DE TODOS LOS CONGRESOS
|
||||
Cargar
|
||||
script-carga-bd-events_schedules.sql
|
||||
script-carga-bd-events_details.sql
|
||||
|
||||
//Modificamos la tabla para crear otro campo autoinc que nos rellene el order
|
||||
/*
|
||||
@ -90,8 +94,8 @@ insert into lqdvi_v2.events_questions (id, eventId, speakerId, anonimous, answer
|
||||
SELECT UUID() as ID, conferenceId, speakerId, anonymous, answered, discared, content, '0939bb2a-d33d-4290-ac81-fc9faa1c015e', created, now() FROM lqdvi.question;
|
||||
|
||||
|
||||
//Cargar
|
||||
script-carga-bd-entidades.sql
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
script-carga-bd-entidades2.sql
Normal file
2
script-carga-bd-entidades2.sql
Normal file
File diff suppressed because one or more lines are too long
3
script-carga-bd-events_details.sql
Normal file
3
script-carga-bd-events_details.sql
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,55 +1,2 @@
|
||||
-- MySQL dump 10.13 Distrib 5.7.26, for Linux (x86_64)
|
||||
--
|
||||
-- Host: localhost Database: lqdvi_v2
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 5.7.26-0ubuntu0.16.04.1
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8 */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `events_schedules`
|
||||
--
|
||||
|
||||
LOCK TABLES `events_schedules` WRITE;
|
||||
/*!40000 ALTER TABLE `events_schedules` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `events_schedules` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Dumping data for table `speaker_types`
|
||||
--
|
||||
|
||||
LOCK TABLES `speaker_types` WRITE;
|
||||
/*!40000 ALTER TABLE `speaker_types` DISABLE KEYS */;
|
||||
INSERT INTO `speaker_types` VALUES ('1','conferenciante','2019-07-03 11:10:43','2019-07-03 11:10:43');
|
||||
/*!40000 ALTER TABLE `speaker_types` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Dumping data for table `users`
|
||||
--
|
||||
|
||||
LOCK TABLES `users` WRITE;
|
||||
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2019-07-03 12:54:48
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
|
||||
INSERT INTO `users` VALUES ('0939bb2a-d33d-4290-ac81-fc9faa1c015e','+34686621059',NULL,NULL,'HJAJu6bRrQfVoG0nrET7YQOXe2h1',NULL,NULL,NULL,'media/defaultProfile.png',1,NULL,'2019-06-20 10:10:36','2019-06-20 10:10:36');
|
||||
INSERT INTO `users` (id, phone, fbuid, profile_picture, accessibility,state,createdAt,updatedAt)
|
||||
VALUES ('0939bb2a-d33d-4290-ac81-fc9faa1c015e','+34686621059','HJAJu6bRrQfVoG0nrET7YQOXe2h1','media/defaultProfile.png',1,'active', '2019-06-20 10:10:36','2019-06-20 10:10:36');
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user