How to create or use a Ticket System [Flow]

Dear All,

I am working on my thesis and I am fighting with the time since I just have two weeks in order to finish my prototype.However I am new on meteor [and I want to be the difference on my university since nobody knows about how great meteor is].

Then I am trying to build a ticket system, and I am finishing the prototype [I have it on **75%**], but I have not idea how can I do the following ticket flow (I know that it could be hard to understand but I have created a horrible image that could help to get the idea)

I have a list of tickets then once that I give a click in one of these tickets I should be able to see something like the following picture…

Picture:

I am really appreciate all your help on this matter. I am not requesting the code for copy and paste, because I recognize your time. But I just want to capture:

Ideas about how I can I build this? Packages, HTML, JS and Mongo code that can help.

The pain for me is to add as many updates as a ticket needs for a conversation flow [Knowing that a client should have the ability for a start rating and an administrator for a administration panel {Green}]. Then that could be the main question for me.

I just want to say thank you in advance! I can be stressed or sad or something that I can’t think in a solution. That’s why I am requesting your help, if you have any question just let me know.

Hope you can help me about it, I want to approve my thesis.

Have a great day,
Best Regards,

You have two ways:

1. Save the updates in the same ticket object
You would add a field updates to the object, which would be an array of objects like:

{
    _id: "wqeriug65sd4gf",
    createdAt: somedate,
    ticketNumber: 213564,
    ticketStatus, "open",
    clientId: "dsfg354ssdg6dsf56",
    updates: [
        {
            createdAt: somedate,
            author: "dsfg354ssdg6dsf56",
            content: "some long string with text"
        },
        {
            createdAt: somedateslightlylater,
            author: "sdfg456sd31f5ds64f",
            content: "some other long string with text"
        },
    ]
}

You’ll obviously need a lot more fields than that, but this is just to give you an idea.

2. Create a separate collection for ticket updates. Then add a field updates to your main ticket object which would be an array of the id’s to the corresponding update object in the ticket updates collection. So in essence, the same as the above, but you store the updates in a separate collection and reference them by their id’s in the main ticket object,

Once you’ve got the data for the updates you simply use an {{#each updates}} helper in your template if you’re using blaze or a .map( when using react.

1 Like

Thank you so much for all your help on this matter, I really appreciate all your help and time.

I will vote for the second option. However I have a question. How can I insert N numbers of updates ids in the main ticket object, adding it at the end and keeping the other ones. For example:

updates: [
    { id: dsfg354ssdg6dsf56 },
    { id: "sdfg456sd31f5ds64f"},
    ....
]

I will use the insert in a meteor method at server side calling it in the client side.

I really appreciate your help, you have no idea how I really appreciate the help on this.

You can use the $addToSet operator during update, this will add an element to the updates array, unless it already exists. If you don’t want to check if it already exists, you can use $push instead.

Tickets.update({_id: "sdfgsdfgdsfg654sadfg"}, {$addToSet: {updates: "s4f6s22df8s8d63sdf1fsd"}})
1 Like

For bulk updates, you can use:

Tickets.update(
   {_id: "iJdKnjlpiow23n"},
   {
      $addToSet: {
         updates: ["dsfg354ssdg6dsf56", "sdfg456sd31f5ds64f"]
      }
   }
);
1 Like

Thank you so much for your help. I have been able to make the insert. However I am getting problems when I am trying to publish the main ticket description and after this the updates.

Because the I have to publish first the ticket description and after this the updates where the updates ids are in the main ticket object so for example

on server side I create a publish for Tickets.find({}); but how can I get the ticket first and then the updates where the update id will be a match coming from updates collection?

In simple words I am getting problems making the mongo query from updates using the ids filters in the main ticket object

Thank you so much for all your help and time on this matter. Have a great day.

You can do that with an aggregate mongodb query. This package allows you to write aggregation:
https://atmospherejs.com/meteorhacks/aggregate

What I suggest however is that you store the main ticket _id in the update object in the updates collection as well. So your update objects would have a field “parentTicket” that has the _id of the main ticket.

That way you can query the updates by the main _id instead of querying the update _id’s separately, which is a lot easier/faster and you don’t even need aggregation necessarily.

Thank you so much for your help. I will try this.

Have a great day,

Best regards. Pura Vida.

Hello @fquesada. This is such a helpful document. I am new to Meteor and the first task I am assigned is to find how to do ticketing using meteor. While this document is really been useful I would like to know did an aggregate mongodb query worked finally? Also which packages did you used to implement ticketing? TIA @nlammertyn

Hi @neilchoksi!

My apologies by the delay in my response. According to your questions the aggregate mongodb query works as expected and I used a few packages just for features like start rating, chart, login and mongo integration.

However, have passed about 3 months and I guess that you have finished it successfully.

Best regards from CR.

Have a great day.