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

Fl4m3Ph03n1x
Background Let’s assume I have a typical GenServer that receives messages as requests, does some operation in a DB and returns responses....
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
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
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
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
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
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
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
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
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
beno
I will often find my self writing things similar to: case some_value do nil -&gt; something() "" -&gt; something() _ -&gt; someth...
New

We're in Beta

About us Mission Statement