jessejanderson

jessejanderson

Creating a calendar in OTP

I’ve been reading Lance Halvorsen’s new beta book “Functional Web Development with Elixir, OTP and Phoenix” and it’s got me thinking about new ways of using processes.

In the book, you build a battleship-clone, and the gameboard you build is built with coordinates - each of which is its own process. The advantage you get out of this is that each coordinate is independent yet can hold it’s own state, and also a coordinate exists independent of any sort of heirarchy. Since it is just a process, it can be a part of different branches of data and easily read / updated.

I was wondering if it would be possible to do the same sort of thing with a calendar app. Each date could be a process that stores the events/times happening that day, one advantage being that you could potentially check for room conflicts when creating a new weekly event that just calls up the processes associated with the dates you are scheduling to check for any potential conflicts.

Obviously, one huge issue with this thought process is timezones - so maybe it’s an entirely wrong-headed approach.

My work currently has several calendar apps built in Rails and finding/resolving conflicts is one of the biggest sluggishness factors - so that is definitely one factor that I’m trying to find a solution for.

Just sort of spinning this stuff around in my head and wondering if anyone has any thoughts or ideas for a way to take advantage of OTP in a scheduling/calendar app. :slight_smile:

Most Liked

DianaOlympos

DianaOlympos

Well if you can translate both to a timestamp, then Range would work as it takes integer :stuck_out_tongue:

lance

lance

Author of Functional Web Development with Elixir, OTP, and Phoenix

I’d just like to say that this is exactly what I had hoped for when I began writing the book. <3

dom

dom

Why is finding conflicts sluggish in the Rails app?

jessejanderson

jessejanderson

Heh, actually I have no idea - I’m actually not super familiar with Rails.

Honestly, I’m more focused on “how to think about a scheduling calendar within OTP” than specifically fixing problems with the Rails app, though that is what sort of sparked this.

radar

radar

I couldn’t think of a reason for the finding or resolving of conflicts to be difficult. With a liberal use of PostgreSQL’s OVERLAP operator (https://www.postgresql.org/docs/9.0/static/functions-datetime.html) it should be fairly trivial to do.


Now regarding this OTP app idea of yours. What kind of granularity would the processes have? I can’t think of a level of granularity that would actually work for this example, hence why I ask. You couldn’t have a process per hour because then what if an event spans multiple hours? You can scale that idea up to days, weeks and months.

I see you suggested days, but what about an event that spans over two days?

I am not entirely sure that an OTP app here would work, but I am not an OTP expert by any stretch of anyone’s imagination. I’m open to being proven wrong here.

Where Next?

Popular in Questions Top

pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New

Other popular topics Top

chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

We're in Beta

About us Mission Statement