diff --git a/backend/index.js b/backend/index.js index 4e186a2a3..faa2ddb7f 100644 --- a/backend/index.js +++ b/backend/index.js @@ -3,7 +3,7 @@ const bodyParser = require('body-parser') const { errors } = require('celebrate') const path = require('path') const helmet = require('helmet') -const sslRedirect = require('heroku-ssl-redirect') +// const sslRedirect = require('heroku-ssl-redirect') /** Create Express application */ const app = express() @@ -76,19 +76,27 @@ const migrations = require('./migrations/index') const throng = require('./misc/throng') const memoryUsage = () => { - const formatMemoryUsage = (data) => `${Math.round(data / 1024 / 1024 * 100) / 100} MB` + const formatMemoryUsage = data => + `${Math.round((data / 1024 / 1024) * 100) / 100} MB` const memoryData = process.memoryUsage() const memoryUsage = { - rss: `${formatMemoryUsage(memoryData.rss)} -> Resident Set Size - total memory allocated for the process execution`, - heapTotal: `${formatMemoryUsage(memoryData.heapTotal)} -> total size of the allocated heap`, - heapUsed: `${formatMemoryUsage(memoryData.heapUsed)} -> actual memory used during the execution`, - external: `${formatMemoryUsage(memoryData.external)} -> V8 external memory`, + rss: `${formatMemoryUsage( + memoryData.rss, + )} -> Resident Set Size - total memory allocated for the process execution`, + heapTotal: `${formatMemoryUsage( + memoryData.heapTotal, + )} -> total size of the allocated heap`, + heapUsed: `${formatMemoryUsage( + memoryData.heapUsed, + )} -> actual memory used during the execution`, + external: `${formatMemoryUsage( + memoryData.external, + )} -> V8 external memory`, } console.log(memoryUsage) - } throng({ @@ -109,21 +117,15 @@ throng({ httpServer.listen(PORT, () => { logger.info( - `Worker ${process.pid} started, listening on port ${httpServer.address().port}`, - + `Worker ${process.pid} started, listening on port ${ + httpServer.address().port + }`, ) - }) memoryUsage() - - - - }, - - /** This is run only if the master function errors out, which means the * server could not start properly. Workers are automatically revived on failure, if e.g. * the app crashes or runs out of memory while processing a request. @@ -138,4 +140,4 @@ throng({ }) process.exit(1) }, -}) \ No newline at end of file +}) diff --git a/backend/modules/alert/graphql.js b/backend/modules/alert/graphql.js index 9c6e4674d..5915495ad 100644 --- a/backend/modules/alert/graphql.js +++ b/backend/modules/alert/graphql.js @@ -1,5 +1,5 @@ const { withFilter } = require('graphql-subscriptions') -const { RedisPubSub } = require('graphql-redis-subscriptions') +// const { RedisPubSub } = require('graphql-redis-subscriptions') const { GraphQLString, GraphQLObjectType, @@ -11,16 +11,12 @@ const { const { GraphQLDate } = require('graphql-iso-date') const RegistrationController = require('../registration/controller') const Event = require('../event/model') -const Redis = require('ioredis') -//const client = new Redis("rediss://default:JSVhlHFiXTnFo1Z1IVok05TOQqccA2qB@redis-11912.c226.eu-west-1-3.ec2.cloud.redislabs.com:11912"); -//console.log(client,"##") - - -const pubsub = new RedisPubSub({ - publisher: new Redis(process.env.REDISCLOUD_URL), - subscriber: new Redis(process.env.REDISCLOUD_URL) -}) +// const Redis = require('ioredis') +// const pubsub = new RedisPubSub({ +// publisher: new Redis(process.env.REDISCLOUD_URL), +// subscriber: new Redis(process.env.REDISCLOUD_URL), +// }) const AlertInput = new GraphQLInputObjectType({ name: 'AlertInput', @@ -120,13 +116,13 @@ const Resolvers = { throw new Error('You are not an organiser of this event') } - pubsub.publish('ALERT_SENT', { - newAlert: { - ...args.alert, - sentAt: new Date(), - sender: userId, - }, - }) + // pubsub.publish('ALERT_SENT', { + // newAlert: { + // ...args.alert, + // sentAt: new Date(), + // sender: userId, + // }, + // }) return context.controller('Alert').send(args.alert, userId) }, @@ -135,9 +131,9 @@ const Resolvers = { newAlert: { subscribe: withFilter( () => { - return pubsub.asyncIterator('ALERT_SENT') + // return pubsub.asyncIterator('ALERT_SENT') }, - async ({newAlert}, { eventId, slug }, { user }) => { + async ({ newAlert }, { eventId, slug }, { user }) => { // Check authentication from context const userId = user ? user.sub : null if (!userId) { diff --git a/backend/modules/event/model.js b/backend/modules/event/model.js index a072f21e8..f5c62099e 100644 --- a/backend/modules/event/model.js +++ b/backend/modules/event/model.js @@ -407,7 +407,10 @@ const EventSchema = new mongoose.Schema({ type: [EventPageScriptSchema.mongoose], default: [], }, - meetingsEnabled: false, + meetingsEnabled: { + type: Boolean, + default: false, + }, meetingRooms: { type: [MeetingRoomSchema.mongoose], default: [], @@ -426,6 +429,12 @@ const EventSchema = new mongoose.Schema({ //New fields for score criteria and score settings scoreCriteriaSettings: { type: ScoreCriteriaSettingsSchema.mongoose, + default: { + scoreCriteria: [{criteria: 'overall', label: 'Overall'}], + showScore: false, + showFeedback: false, + reviewAnyChallenge: false, + }, }, experimental: { type: Boolean, diff --git a/backend/modules/message/graphql.js b/backend/modules/message/graphql.js index 43f2bce5b..78a9b4399 100644 --- a/backend/modules/message/graphql.js +++ b/backend/modules/message/graphql.js @@ -1,6 +1,6 @@ const { GraphQLBoolean } = require('graphql') const { withFilter } = require('graphql-subscriptions') -const { RedisPubSub } = require('graphql-redis-subscriptions') +// const { RedisPubSub } = require('graphql-redis-subscriptions') const { GraphQLString, GraphQLObjectType, @@ -10,13 +10,12 @@ const { GraphQLInputObjectType, } = require('graphql') const { GraphQLDate } = require('graphql-iso-date') -const Redis = require('ioredis') +// const Redis = require('ioredis') - -const pubsub = new RedisPubSub({ - publisher: new Redis(process.env.REDISCLOUD_URL), - subscriber: new Redis(process.env.REDISCLOUD_URL) -}) +// const pubsub = new RedisPubSub({ +// publisher: new Redis(process.env.REDISCLOUD_URL), +// subscriber: new Redis(process.env.REDISCLOUD_URL) +// }) const MessageInput = new GraphQLInputObjectType({ name: 'MessageInput', fields: { @@ -119,13 +118,13 @@ const Resolvers = { const userId = context.req.user ? context.req.user.sub : null if (!userId) return null - pubsub.publish('MESSAGE_SENT', { - newMessage: { - ...args.message, - sentAt: new Date(), - sender: userId, - }, - }) + // pubsub.publish('MESSAGE_SENT', { + // newMessage: { + // ...args.message, + // sentAt: new Date(), + // sender: userId, + // }, + // }) return context.controller('Message').send(args.message, userId) }, @@ -146,7 +145,7 @@ const Resolvers = { newMessage: { subscribe: withFilter( () => { - return pubsub.asyncIterator('MESSAGE_SENT') + // return pubsub.asyncIterator('MESSAGE_SENT') }, ({ newMessage }, _, { user }) => { // Check authentication from context diff --git a/backend/modules/registration/controller.js b/backend/modules/registration/controller.js index 1f7ac5d0b..c355ca616 100644 --- a/backend/modules/registration/controller.js +++ b/backend/modules/registration/controller.js @@ -522,8 +522,13 @@ controller.rejectSoftRejected = async eventId => { return rejected } +// TODO optimize how gavelData and registrations are matched to avoid O(n^2) complexity controller.addGavelLoginToRegistrations = async (eventId, gavelData) => { - console.log('Gavel data received', gavelData, typeof gavelData) + let updateCount = 0 + const registrations = await Registration.find({ + event: eventId, + status: RegistrationStatuses.asObject.checkedIn.id, + }) gavelData.forEach(gavel => { if ( typeof gavel.registration !== 'string' || @@ -531,17 +536,6 @@ controller.addGavelLoginToRegistrations = async (eventId, gavelData) => { ) { throw new Error('Gavel data is invalid') } - }) - let updateCount = 0 - const registrations = await Registration.find({ - event: eventId, - status: RegistrationStatuses.asObject.checkedIn.id, - }) - console.log('Registrations found', registrations.length) - console.log('Registrations data', registrations) - const registrationCount = registrations.length - - gavelData.forEach(gavel => { const registration = registrations.find( r => r._id.toString() === gavel.registration, ) @@ -552,7 +546,10 @@ controller.addGavelLoginToRegistrations = async (eventId, gavelData) => { registration.save() } }) - + console.log('Registrations found', registrations.length) + console.log('Registrations data', registrations) + const registrationCount = registrations.length + console.log( 'Modified counts, updated/total', updateCount, diff --git a/frontend/src/components/layouts/MaterialTabsLayout/index.js b/frontend/src/components/layouts/MaterialTabsLayout/index.js index 2613ac8c7..1a0103710 100644 --- a/frontend/src/components/layouts/MaterialTabsLayout/index.js +++ b/frontend/src/components/layouts/MaterialTabsLayout/index.js @@ -57,7 +57,6 @@ export default ({ tabs, location, baseRoute, transparent = false }) => { const pushRoute = useCallback( path => { - console.log("pushing", `${baseRoute}${path}`) dispatch(push(`${baseRoute}${path}`)) }, [baseRoute, dispatch], @@ -69,15 +68,12 @@ export default ({ tabs, location, baseRoute, transparent = false }) => { const activeIndex = useMemo(() => { const relativePath = location.pathname.replace(baseRoute, '') - console.log("relativePath matTab", relativePath) const idx = findIndex(tabs, item => item.path === relativePath) - console.log("safeIndex matTab", idx, idx !== -1) return idx }, [baseRoute, location.pathname, tabs]) useEffect(() => { if (activeIndex === -1) { - console.log("pushRoute(tabs[0].path)", pushRoute(tabs[0].path)) pushRoute(tabs[0].path) } }, [tabs, activeIndex, pushRoute]) diff --git a/frontend/src/components/layouts/SidebarLayout/index.js b/frontend/src/components/layouts/SidebarLayout/index.js index 629d3d9ab..045e6b837 100644 --- a/frontend/src/components/layouts/SidebarLayout/index.js +++ b/frontend/src/components/layouts/SidebarLayout/index.js @@ -130,7 +130,6 @@ export default React.memo( }) => { const dispatch = useDispatch() const routes = _routes.filter(route => !route.hidden) - console.log("ROUTES", routes) const activeIndex = useMemo(() => { const relativePath = location.pathname.replace(baseRoute, '') @@ -141,21 +140,16 @@ export default React.memo( return relativePath.indexOf(item.path) !== -1 } }) - console.log("INDEX", idx) - console.log(relativePath) if (idx === -1) { switch (relativePath) { case '/events': idx = routes.length - console.log('/events', idx) break case '/events/organize': idx = routes.length - console.log('/events', idx) break case '/events/partner': idx = routes.length - console.log('/events', idx) break case '/profile': idx = routes.length + 1 @@ -166,13 +160,11 @@ export default React.memo( default: idx = -1 } } - console.log("IDX", idx) return idx }, [baseRoute, location.pathname, routes]) const pushRoute = useCallback( path => { - console.log(`push(${baseRoute}${path})`) dispatch(push(`${baseRoute}${path}`)) }, [baseRoute, dispatch], @@ -180,7 +172,6 @@ export default React.memo( useEffect(() => { if (activeIndex === -1) { - console.log("PUSHING ", routes, "activeIndex", activeIndex) //pushRoute(routes[0].path) } }, [routes, activeIndex, pushRoute]) @@ -271,7 +262,6 @@ export default React.memo( selected: classes.listItemSelected, }} onClick={() => { - console.log("safeIndex", safeIndex) pushRoute('/events') }} > @@ -340,11 +330,6 @@ export default React.memo( primary={'Log Out'} /> - - {/*TODO: language menu */} - {/* */} - - @@ -426,24 +411,8 @@ export default React.memo( }, index, ) => { - // console.log("PROPS: ", "key", key, - // "path", `${baseRoute}${path}`, - // "hidden", hidden, - // "component", component, - // exact = false, - // "locked", locked, - // "index", index) if (hidden || locked) { return null - // } else if (index === 5) { - // console.log("ROUTING EVENT_ID") - // return (< Route - // key={'eventId2'} - // exact={false} - // path={`${baseRoute}/event-id` - // } - // component={LogoutPage} - // />) } else { return ( diff --git a/frontend/src/graphql/queries/events.js b/frontend/src/graphql/queries/events.js index 65e9386af..5647c265a 100644 --- a/frontend/src/graphql/queries/events.js +++ b/frontend/src/graphql/queries/events.js @@ -84,7 +84,6 @@ export const useActiveEvents = ({ limit }) => { limit, }, }) - console.log("data", data) return [data?.activeEvents, loading, error] } @@ -104,7 +103,6 @@ export const usePastEvents = ({ limit }) => { limit, }, }) - console.log("usePastEvents", data) return [data?.pastEvents, loading, error] } @@ -119,7 +117,6 @@ export const GET_MY_EVENTS = gql` export const useMyEvents = () => { const { data, loading, error } = useQuery(GET_MY_EVENTS) - console.log("data", data) return [data?.myEvents, loading, error] } diff --git a/frontend/src/graphql/queries/registrations.js b/frontend/src/graphql/queries/registrations.js index efaa36d7b..b2bcc58d9 100644 --- a/frontend/src/graphql/queries/registrations.js +++ b/frontend/src/graphql/queries/registrations.js @@ -37,6 +37,5 @@ export const useRegistrationsByUser = userId => { userId, }, }) - console.log('useRegistrationsByUser', userId, data, loading, error) return [data?.registrationsByUser, loading, error] } diff --git a/frontend/src/hocs/RequiresPermission.js b/frontend/src/hocs/RequiresPermission.js index e5ac0b20f..6e72e9043 100644 --- a/frontend/src/hocs/RequiresPermission.js +++ b/frontend/src/hocs/RequiresPermission.js @@ -19,7 +19,6 @@ export default (ComposedComponent, requiredPermissions = []) => { const hasProfile = useSelector(UserSelectors.hasProfile) const hasRequiredPermissions = useMemo(() => { - console.log(permissions, requiredPermissions) return ( requiredPermissions.filter(x => !permissions?.includes(x)) .length === 0 diff --git a/frontend/src/pages/_dashboard/renderDashboard/default/events/Organizer.js b/frontend/src/pages/_dashboard/renderDashboard/default/events/Organizer.js index cf5b256bc..5837a85ca 100644 --- a/frontend/src/pages/_dashboard/renderDashboard/default/events/Organizer.js +++ b/frontend/src/pages/_dashboard/renderDashboard/default/events/Organizer.js @@ -76,36 +76,6 @@ export default () => { ['Organiser', 'AssistantOrganiser', 'SuperAdmin'].includes(r), ) - // useEffect(() => { - // if (hasError) { - // if (name.length < 5) { - // setError(t('Name_must_five_')) - // } else if (name.length >= 50) { - // setError(t('Name_must_under_')) - // } else if (name === 'default') { - // setError(t('Name_not_default_')) - // } else { - // setError() - // } - // } - // }, [name, hasError, t]) - - // const checkName = useCallback(() => { - // if (name.length < 5) { - // setError(t('Name_must_five_')) - // return false - // } else if (name.length >= 50) { - // setError(t('Name_must_under_')) - // return false - // } else if (name === 'default') { - // setError(t('Name_not_default_')) - // return false - // } - // return true - // }, [name.length, t]) - - console.log('organizerEvents', organizerEvents) - //TODO implement pagination to improve performance of organize tab useEffect(() => { @@ -140,7 +110,7 @@ export default () => { @@ -157,8 +127,8 @@ export default () => { - {searchResults.map(event => ( - + {searchResults.map((event, index) => ( +
{event.published && event.approved ? ( diff --git a/frontend/src/pages/_dashboard/renderDashboard/default/events/Participant.js b/frontend/src/pages/_dashboard/renderDashboard/default/events/Participant.js index 314b1fb6d..5fdf20e6c 100644 --- a/frontend/src/pages/_dashboard/renderDashboard/default/events/Participant.js +++ b/frontend/src/pages/_dashboard/renderDashboard/default/events/Participant.js @@ -23,11 +23,6 @@ export default () => { const activeEvents = useSelector(DashboardSelectors.activeEvents) const pastEvents = useSelector(DashboardSelectors.pastEvents) const [registrations, loading, error] = useRegistrationsByUser(userId) - //useSelector(UserSelectors.registrations) - - console.log('activeEvents', activeEvents) - console.log('pastEvents', pastEvents) - console.log('registrations', registrations) const dispatch = useDispatch() const { t } = useTranslation() @@ -53,9 +48,10 @@ export default () => { )} - {registrations?.map(registration => ( - + {registrations?.map((registration, index) => ( + { dispatch( @@ -92,12 +88,6 @@ export default () => { isodate > event.registrationStartTime const eventStarted = isodate > event.startTime - console.log( - 'button render', - event.slug, - canApply && !event.galleryOpen, - event.galleryOpen && eventStarted, - ) return ( {