I have a Symfony 4 application on which users can view sports events and register themselves for these events. I use Doctrine as ORM and EasyAdminBundle for an admin panel.
I'm having difficulty with figuring out how to structure my entities and how things should be stored in the database. I have 2 main entities, Event and Registration. I will explain these in detail.
Event
Event stores all details about an event. There are some fixed properties that all events have, like:
id
title
description
startDate
endDate (optional)
isPublic
eventType
As you can see, each event has a type. Most events are simple and do not contain additional properties. However, there is an event type for which I want to store some additional properties. I'll call this type complexEventType from here on out. I'll describe what kind of properties I want to keep for these events:
How many days does the event take (this varies)?
For each day: what activities can be done one this day. This should be editable by an admin in the admin panel. There are activities like running, biking, walking, but it should be possible to add other sports.
Each activity has an optional array of generic options (string). Most of the time, these represent distances.
An example complexEventType could look like this:
Day 1
Walking
5km
8km
12km
Running
10km
12km
16km
Biking
30km
40km
60km
Day 2
Walking
8km
10km
12km
Running
12km
14km
18km
Biking
40km
50km
70km
Day 3
Swimming
Running
12km
14km
18km
Biking
40km
50km
70km
Some questions arise here:
Should I subclass the Event instead of keeping a type property?
If I subclass, should each event type have a separate table?
Instead of subclassing, should I keep the options property and make it nullable so that it doesn't need to be set for events where there are no options?
How to store the options in the database? As a JSON object? Or separate tables for days and activities?
Registration
Users can register for events. Their registration will be saved in a Registration object. A registration contains the following properties:
id
event (reference to the event object)
user (reference to the registered user)
If the isPublic boolean from the event is true, the event is public and non-authenticated users can register for them. In that case, I want to keep some extra information:
firstName
lastName
email
Depending on the eventType property from the event, some extra properties need to be saved. For example, one event type takes places in a foreign country. For this event type, I want to know if the user wants to stay in a hotel (boolean) and whether it's ok if he/she sleeps in a shared room (boolean). For another event type, no details are kept. For the complexEventType, we need to store which activity the user is doing on what days, and the chosen option for each activity (distance).
I'm kind of in the dark about how I should approach this situation. For now, I created an abstract Registration entity, which is subclassed by PublicRegistration and PrivateRegistration. PublicRegistration keeps properties like firstName and lastName, while PrivateRegistration stores a pointer to the User object. Right now, Registration stores all possible options, which are all nullable. This works, but it doesn't look good at all. I'd rather have the options separated. I was thinking to make an RegistrationOptionInterface. Then, for each event type, I could create a class that implements this interface and adds options. However, I don't know how this would then be saved to the database...
Can anybody point me in the right direction? Has anybody encountered a similar situation before, and if so, how did you solve it?
Related
I can’t find a solid answer for this, I’ve thought about using event listeners but I can’t seem to find a doctrine event to do what I want.
So the system we are building has different user accounts where each user is able to create a record, let’s say they can create a task using a Task entity and they can create a calendar event using a CalendarEvent entity.
Both entities have $createdBy mapped to the User entity.
When we pull data from the database, say a list of tasks, we only want the tasks for the current user but this would mean for every single entity in the system we would have to make sure the user is passed in the database query which easily becomes a mess.
What I want to do is automatically fill the $createdBy during persist and automatically add it as a where parameter during retrieval.
So instead in every repo function we write doing this for example:
$this->findBy([‘createdBy’=>$user]);
The createdBy part should be added automatically ; perhaps with some doctrine event?
I have been tasked with using Google Analytics to report of use of a desktop app so we can see which parts of the program are being used and how heavily, and potentially also see which companies are using which parts of the program (each company has a unique companyID). Ideally I'd like to be able to look at correlations (e.g., How many users who use report A also use process B?)
I currently have my program set to fire off a call to analytics. I've set it up to use the event tracking, but I'm open to app/screen tracking or something else if something would work better. I'm passing values like
v=1
&t=event // Event hit type
&tid=UA-XXXXX-Y // our ID; real code has valid value here
&cid=12345 // CustomerID
&ec=JobFinancialReport // Event Category
&ea=Run // Event Action
&el=Manager // Event label
&ev=7 // Event value
What I can't figure out is how in Google Analytics to set up reports that would show me something like:
CustomerID Category Label Total Hits Unique Users
12345 JobFinancialReport Manager 27 2
12345 MarketingReport1 Manager 6 4
I'm totally new to analytics so pardon my ignorance if I have some key misconception here. I've searched Googles sites and other questions here, but I may be wording my question incorrectly so I'm not finding something that's there. This is only one example; in some cases we might want to see how broadly each customer is using the program; in other cases we'd want to take the customerID out and just see how much a particular report is being used overall. Appreciate any guidance. Thanks.
The "cid" parameter is the client id, the value that is used to stitch single interactions into sessions and users.
The first problem that comes to mind with your setup is that the client id is not exposed in the user interface (with the single exception of the user explorer report) or the API.
You would need to implement this via a custom dimension (probably user scope, since it probably will never change for a given user) where you pass in the client id (you still need the cid parameter).
Then you could create a custom report (or create a report in Google Data Studio) with the custom value as primary dimension and your selected metric.
If you want to report "Unique Users" you would probably need to create a cid per logged-in user (if all users of the app have the same cid then you will always have but a single user reported). You should then probably create a second custom dimension for the company id, so you can segment your reports by company.
you can use custom reports in google analytics to get your desired output. here is how to create custom reports https://support.google.com/analytics/answer/1151300?hl=en
I've a problem with a complex query. I've a node type Event and the list of users. Between events and users may exists (or may not) RSVP relations created with the Relation module (https://www.drupal.org/project/relation). Inside any relation there are infos about the RSVP (presence, invites, ecc.). I need to make a page where I show next events with related RSVP informations about current logged user.
I won't cover event filtering problem, the main problem is that not every event<->user has an RSVP relation, but only where the users has been interested about the event (why is obvious).
My incomplete solution was:
starting from event list, filter only events which I'm interested in,
create a relation "node<->RSVP relation" for get RSVP relation's fields,
from previous relation, create a new relation "RSVP relation<->user" to get the linked user
filter only user that is the currently logged in
This solution works only if the event<->current user RSVP relation exists! If it doesn't exist the event disappear where I want to show it without any RSVP informations.
My last idea of solution goes in direction of a filter applied only on relations and not to events, or the possibility to make two views (events and current user's RSVPs) and left join them.
My old idea was to accept (I don't know how) also events without an event<->current user relation, but I realized that this solution may accepts all event<->!current user relations and I don't want this.
How can I do? Thank you!
You should start checking if you set relationship as required. The difference will be an inner join instead of left join. Check the query to see what join are you getting
At the end I've solved with the Drupal's module Views Field View with which I've included a View that selects RSVP informations inside an other View that list events
im starting to implement some security features in my application. When initially trying to implement some ACL I came acress two questions I could not figure out:
Where to implement the setting of acl
I could do it in the controller action where my entities are created or on the entity itself with lifecyclecallbacks. For example I have a Group Entity which holds some Userentities. It is easier to set the view or edit access on a lifecyclecallback for all group entities. I would prefer to make my controller as slim as possible. Or is this a bad approach? I would need the security container in my entity. What is your approach to this?
How to check for related entities:
Extending my previous example, I have a Group and this group can hold some appointments. In my actions where the appointments are shown or edited, I only want to check for the group. This is mainly for using the "view" rights. Meaning if someone is in the Group which holds the appointment, the person should also be able to view the appointment. I would like to implement this with JMSExtraSecurityBundle and SecureParam, but I have no Idea how to do that.
Let's say I have a class Person, with a string[] nickNames, where Person can have 0 or more nicknames stored. I want to create an asp.net page where a user can go and add/edit/delete nicknames.
Question is- how to i persist the Person object between postbacks? I query the DB and create the object then display it on a form, but then the user has the option to edit/delete fields of that object.. once the page is displayed with the fields of Person, how do I update that object with the changes the user made, to store to db?
Thanks!
Well if your Person Object is serializable you could store it in ViewState and if not, you could stick it in Session, but it sounds like you might have a general lack of understanding about Data Persistance in general
Depending on your implementation, and whether you're coding this all by hand or using the built in DataSource/DataAdapter controls, theres a bunch of ways to do it.
You could have a look at some basic ASP.NET/ADO.NET Tutorials to point you in the right direction
http://aspnet101.com/aspnet101/tutorials.aspx?id=17
Query the object it again (you could store it in a session variable but that doesn't scale), gather and apply changes from user upon postback.