Week number 7 in AESTE. Last week I had problem generating a workable QR code image to attach it in the registration slip. After some discussion with Dr Shawn, he told me that the issue might be caused by the color type of the PNG file. Previously, I was using color type palette to produce the QR code PNG image. Dr Shawn then suggested me to use gray scale color type instead because we just need black and white for the QR code. After some research, I changed the code to produce the QR code PNG image using gray scale color type. Thankfully, it worked! So, right now I have a working code which is able to generate a working QR code image in PNG format. After that, I have to figure out a way to implement it with the source code so that our application would generate a QR code image in PNG format based on the entry ID and attach it to the registration slip. I am pretty familiar with the application and I have a clear idea on what I have to add in. However, things did not go smoothly. I struggled for a while trying to add in and call the new function. Basically, what I have to do was just calling the function from another class and that’s it. But it took me a few hours to do just that, I went through the c++ documentation again trying to understand how the classes and functions work. After some “hard work”, finally everything turned out fine! I had successfully add in the new codes to generate the QR code image and attach it to the registration slip, but we are not done yet.

Right now, the QR code images generated are stored in the app root directory but I don’t think that we need them there. After some discussion with Dr Shawn, we have decided to remove the QR code after it has successfully attached to the registration slip. To do this, I am using Poco library or to be more specific, I am using “Poco/TemporaryFile.h”. What it does is that, I am able to generate the QR code PNG in a temporary file which will automatically delete itself after it goes out of scope. On my first try, I had compiling error stating that the QR image was not found. To solve this issue, Dr Shawn asked me to look at my code structure. The reason why I received the error was because of the image already delete itself when some part of the codes was still looking for it. To solve this issue, I spent some time looking into the documentation of Poco Temporary File and found out this function, “keepUntilExit()”. What it does is that, the temporary files will only delete themselves after the application is terminated. I was pretty excited with the function thinking that it could just solve my problem. In fact it did just that. After adding in the function, all the QR codes image generated are stored in the /tmp directory each with a different unique name and all of them would be deleted automatically when the application terminates. So, I was almost done with my third task and what I have to do was making sure that the application passed the test script. And this was when my “NIGHTMARE” came in.

So, after making all the necessary changes, I ran the full test script and looked into all the emails one by one.
Unfortunately, out of the 50 emails, I have 2 emails containing blank registration slips. Something is wrong somewhere. With Dr Shawn’s quote in mind, “There is no magic in software, everything happens for a reason”, I started looking into my code hoping to find out where are the bugs. So, I started by looking into the sample cases where the registration slips sent out were blanked. I realised that, for those blank registration slips, we do not have the category information in the payload. Which means that, when we don’t have the category information in the payload, our application do not know which slip templates to open because right now our application selects the template based on the event category. Yay, at least I know what the problem is now. To solve this bug, I have decided to add in a default template which will be selected by our application when we do not have the category information in the payload from WooCommerce. Oh man, another issue occurred during my final test!

Honestly, I was so excited trying to run the test script one last time before moving on to my next task, but then, I was not receiving the email anymore! In the log files, all the emails were sent out successfully, but I was not receiving them anymore. I didn’t know what happened but I knew it was not something good. I told Dr Shawn about this, and yeah from his reponse I knew I have messed something up. Dr Shawn told me that I had burst the limit of the number of emails we could send out a month. I felt so sorry for causing this problem and Dr Shawn asked me to keep in mind that, nothing in this world is free, everything has a limit, so always be alert about the limit. So, the application is still yet to be tested and I will plan the testing more carefully next time. I am sorry Dr Shawn!


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.