Evaluating google calendar "quick add" string instead of creating event - calendar

Google calendar supports "quick add" strings, such as adding "meeting with Peter tomorrow 15:00 in room 2".
Do anyone know of a way to evaluate the string without before a calendar entry? Something along the lines of the following example:
REQUEST:
action: "just_parse_don't_insert"
text: "Lunch tomorrow 15:00 in room 2"
RESPONSE:
text: "Lunch"
date: "05-03-2013"
location: "room 2"
I can understand why Google would not offer this functionality, so alternatively, I'm looking for services/scripts (preferably JS) that offers similar functionality.

Related

Create Day view calendar and display event in React

I'm using React Native to create a Day view calendar like Google that display event time block.
I have an array that have many object with title, start time, end time and duration. For example:
[
{title: "Event A", startTime: "01:00:00", endTime: "02:00:00",duration: "60 min"},
{title: "Event B", startTime: "01:00:00", endTime: "03:00:00",duration: "120 min"},
{title: "Event C", startTime: "02:00:00", endTime: "04:00:00",duration: "120 min"},
{title: "Event D", startTime: "03:00:00", endTime: "04:00:00",duration: "60 min"},
]
And I want it to display event like this
Example calendar ( I draw it with GG sheet )
I have look through this library https://github.com/duyluonglc/ but it's last updated 3 years ago. So I clone that Repo and review the code. But his code really hard for me to understand the part that he calculated number of columns and expand the event time block width.
I understand that he using position absolute style to draw black line of hours, start time is for position for the block, duration and end time is for the height of block. But the part that he calculated to divide columns and width of many event block in the same hour this really complicated.
If anyone understand the algorithm or have better way to calculate it, please explain it clearly so I can understand how it display. Thank you.

How to model this NoSQL data structure in Firestore (Review my first approach)

I am a fairly new web developer and would need your help with a project I am currently working on. I have worked in the past on a very simple realtime database example and have little to none experience in firestore or NoSql in general.
I want to create a system which allows end-users to get an email once a week that contains a list of special offers from bars the end-user has subscribed to. The offers change each day of the week. Bar owners can fill out a form in a vue.js web application every week with their weekly special offers.
Every Monday morning a cron job has to look up which end user has subscribed to which bars and then aggregate the data and send it via email.
The question is how would you structure the data so that I can easily compose the email and send it via a cloud function?
My approach would be to have three main collections: RestaurantOwner, EndUser, SpecialOfferings
Please see the graphic for an example process:
BarOwner and EndUser are pretty straight forward. However, the difficult part is how to structure the SpecialOffers in order to be queried the right way.
My idea would be to structure it based on the calendar week and link it to the uid from the barOwner:
specialOffers: {
2019_CW27: {
barUID001: {
mon: {
title: 'Banana Daiquir',
price: 4.99,
},
tue: {
title: 'After Five',
price: 2.99,
},
wed: {
title: 'Cool Colada',
price: 6.99
},
thu: {
title: 'Crantini',
price: 5.99
},
fri: {
title: 'French Martini',
price: 4.99
}
},
barUID002: {
mon: {
title: 'Gin & Tonic',
price: 8.99,
},
tue: {
title: 'Cratini',
price: 4.99,
},
wed: {
title: 'French Martini',
price: 4.99
},
thu: {
title: 'After Five',
price: 3.99
},
fri: {
title: 'Cool Colada',
price: 6.99
}
}
},
2019_CW28: {
barUID01: {~~~},
barUID02: {~~~}
}
}
The disadvantage of this approach is that it creates a deeply nested object when you imagine that there are 52 calendar weeks, f.e 100 signed up bars à 5 special offers per week and I am not sure if I am able to query it the way I need to.
Is this approach reasonable or what would you do differently?
Thank you so much for your help! I highly appreciate it.
I'm assuming the following scenarios:
1) The bar owners make modifications to their offers very often.
2) The bar owners should be the only ones allowed to modify each bar's offers.
If you have these two scenarios, I would recommend a sub-collections approach here.
When to use sub-collections:
1) When there are lot of fields in a document. Cloud Firestore has 20,000 field limit. (If the number of Bars can exceed more than 20,000 fields)
2) When updating the parent collection is a common operation. Firestore only lets you update the document at rate of 1 write/second. (If the SpecialOffers information of each bar is modified very often. If two bar owners modify their offers, only 1 write is successful and the second write operation waits until the first is completed. This can delay the updation offers particularly at the end of a week when almost all the bars update the offers.)
3) When you want to limit the access to particular fields of a document. (If you want to restrict the access to a Bar's Offers to the barOwner alone. You can restrict the access to each document in the Bars sub-collection according to its owner using Firestore Security Rules)
So I would recommend a sub-collection Bars under the main collection SpecialOffers. This way the design becomes scalable and you can add restaurants and super-markets as other similar sub-collections in the future without heavily altering your design.
Another advantage is that sub-collections are basically collections and they don't have a limit for number of documents it can hold. So even if the number of bars registered is above 20,000 which is the limit of number of fields for a fire-store document, your sub-collection wont be having a problem but your document will run out of fields to save the offers for a new bar.
Ultimately the choice depends on your use cases.
Hope this helps.

Drupal Services Plugin ignoring multi-value fields

I'm using drupal 7 with services plugin 3.17
I'm trying to create a node with a field that accepts multiple values via json api with the following data:
{
"type":"custom_type_article",
"title":"My title",
"language":"und",
"body": {
"und": [ { "value": "Article body" } ]
},
"field_article_auhtors": {
"und": [{"value": "author 1"}, {"value": "author 2"}, {"value": "author 3"}]
}
}
The node is succesfully created but only the first value of field_article_auhtors is populated.
Is my json structure incorrect to create multiple values on "field_article_auhtors"?
Version 3.17 of Services has a bug with multi value fields. It looks like the bug is a regression introduced around version v3.6.
A patch was released in November, and multiple users are reporting it as working, though officially it's marked as 'Needs Work'. (The author has asked for a review of the code, and it has already been included in the dev version of Services. That said, a gentle nudge / reminder to test it in a dev environment. ;)
See the conversation, the patch, and a dev release of Services that includes it over on Drupal's official Services Project section at https://www.drupal.org/project/services/issues/2224803

MongoDB Nested - Search TrackingValues

We need to perform a phrased-based search (like Google's "") over a nested array of key words, by order.
For instance, let us suppose the data looks like:
{
Name: "question",
body: [
"We",
"need",
"to",
"perform",
"a",
"search",
"like",
"google's"
]
}
By searching: "we search" – I will get no result, but the document will be returned by searching any of the followings: "we need", "to perform a search", "we" etc.
I do need to tokenize the words for encryption, so saving them as a string could not do for me here…
Is that any possible?
Folks, I tried to solve it with the technical support of MongoDB. Apparently, there is not out-of-the-box solution.
I have been able to "solve" this by keeping another field, concatenating all the tokenized, encrypted words in one string, and use regex expression over it.
Not ideal, and required to duplicate some data – but it works foe our needs.

How do I figure out Data Model for Angular 2/Ionic 2 application

I'm working on a travel application in Angular 2/Ionic 2 with Typescript. I need to figure out how to model my services / objects. This app will have users.
Each user can create an overall Trip. You could name it "Europe 2016." Then you could add multiple days to it. They could be be travelling for 14 days. Each day they can have plans on what to do that day including things like what time the activity is, where that activity is, etc... They could also check the weather, add hotel info, etc to each day.
Roughly may be it looks like (sorry this is ugly)
Trip: {
"name": "Europe 2016",
"tripPlans": [
{"day1": [{plan1: do something, time: 01000}, {plan2: do something else, time: 01000}}], "time": "0800", "date":"09/01"2016, hotel, weather},
{"day2": [{plan1: do something, plan2: do something}], "time": "0800", "date":"09/01"2016, hotel info, weather info}
]
}
Would also need to know the first and last date of trips.
I also may want to go back and query for what the user group find popular, like "most common activity in Gotham"
This is my first major application after spending 100's of hours learning to code and its my personal projects been keeping me excited to learn. It solves a personal problem of mine. I've gotten to the point where I'm having a hard time finding good examples/resources to help me figure this out.
I've sunk a lot of time in to the framework choice so I'd like to stick with it. So far I've landed on trying to use PouchDB/CouchDB. I'm currently only building the mobile version in Ionic right now.
Any advice would be much appreciated even if its github projects to look at, tutorials that you've saved, etc.
I mostly work with CouchDB but I've also started to develop an Ionic app with PouchDB/CouchDB. First of all, you need to know that NoSQL is good when you have a lot of nested documents but sometimes you don't have the choice to make "relations".
First, I reworked a bit your data model :
{
"name": "Europe 2016",
"type": "trip",
"tripPlans": [{
"name": "This is the first plan",
"days": {
"day1": [{
"registeredActivityId": null,
"plan": "do something",
"time": 1000
}, {
"registeredActivityId": "activty_goToTheMoon",
"plan": "Go to the moon and the previous activity",
"time": 1000
}],
"time": "0800",
"date": "09/01/2016",
"hotel": "Hotel name",
"weather": "Sunny"
}
}]
}
Now, you have few options :
You can build a view on your nested actives like this one
function(doc) {
if (doc.type == "trip" && doc.tripPlans && doc.tripPlans.join)
for (var i = 0; i < doc.tripPlans.length; i++) {
var plan = doc.tripPlans[i];
if (plan.days)
for (var n in plan.days)
if (plan.days.hasOwnProperty(n)) {
var day = plan.days[n];
//We emit the activity id for a better tracking.
//If it's not available, we emit the description(not recommanded)
emit(day.registeredActivityId ? day.registeredActivityId : day.plan);
}
}
}
You could make relations between your documents
Using the nested approaches make faster query if the views are calculated often. Else, the "relational approach" makes it easier link "predefined activities" for example. You can contact me in private if you need further pieces of information.

Resources