ericaddison / APT_miniProject

0 stars 0 forks source link

Project Structure #23

Open ericaddison opened 7 years ago

ericaddison commented 7 years ago

Discuss structure and architecture related stuff here :)

ericaddison commented 7 years ago

@mspagon OK, let's answer your other questions...

( @psigourney please butt in if any of this sounds unreasonable, or if I'm talking gibberish! )

My vision is that we separate any actual processing of requests into these so-called "Services", which for our purposes are just request handlers that live in our /source/services/ directory (we are not actually using the separate "services" feature of app-engine, though we could think about that for our final project). The reason that they are different is because they are essentially regular functions: you give them some input via a GET or POST request, and then receive some output via an HTTP status code or a JSON formatted string. These "services" should have nothing to do with HTML ... they should exist solely to provide raw information. I think pretty much everything we do that interacts with the database should happen through a service, so in addition to the services listed on the project description, I have created a few more (like Service_CreateTag, and Service_Subscribe, for instance. I will PR these tonight when I get home from work.

The reason this extra layer of complexity is beneficial is for a few reasons (ideally...):

Before we had a clear view of the services part, Patrick and I were just trying to get anything working! It was not simple! Now that we have a more clear-ish (or at least less nothing-ish) view of our architecture, we should probably work on transferring the functionality of Main.py to use the services approach instead of the integrated (do they call that "monolithic"?) approach. So yes, Patrick and I were definitely inconsistent because there is still a lot of code that was just from us getting things going in the first place! Please feel free to make things more consistent and submit a PR :)

The Admin page! That was not a requirement, but making it was helpful when I was figuring out how to even query ndb at all! If you like the appearance, that is HTML blatantly lifted from an example within the Bootstrap HTML/CSS/JS package and modified to work with our templating. It would be awesome if we end up finding a cool Bootstrap theme we like and modifying our HTML pages to use that, because then things look soooo nice. That's probably not a thing for this week though ;)

WHAT ELSE should we talk about?

psigourney commented 7 years ago

Question about the Trending portion: My plan is for it to have two parts... one will be a standard /trending HTML page which will display the top xx Streams with the most views in the previous 3hrs. And for the current user to modify their TrendingEmail frequency (which will be a StringProperty added to their StreamUser record to indicate how frequently they want to receive emails with the top trending Streams).

(/services/crontrends?) The second part will be the cron services. Each Stream will have a repeated DateTimeProperty attribute which will store the timestamp each time the Stream is viewed. Every 5 minutes, a cron job will run, cycle through all Streams and remove timestamps which are older than 3hrs. Every 5mins/1hr/1day, a cron job will run which will cycle through all StreamUsers and find the ones with the appropriate trendEmails attribute ('5min'/'1hr'/'1day'/null) and send an email to those users.

ericaddison commented 7 years ago

@psigourney I think that sounds like a great plan. Do you envision having a service to retrieve the top trending streams as well? Something like /services/trending? Or is that what you were thinking for /services/crontrends?

psigourney commented 7 years ago

I think that sounds like a great plan. Do you envision having a service to retrieve the top trending streams as well? Something like /services/trending? Or is that what you were thinking for /services/crontrends?

Yeah, I think that would be a good plan. Or instead of /services/crontrends, just create a general /services/trends which would handle both requests for the top x Streams and also the cron jobs. Cron is pretty simple, it's just a cron.yaml file which then calls specified URLs on a schedule.

On Tue, Oct 3, 2017 at 9:12 AM, Eric Addison notifications@github.com wrote:

@psigourney https://github.com/psigourney I think that sounds like a great plan. Do you envision having a service to retrieve the top trending streams as well? Something like /services/trending? Or is that what you were thinking for /services/crontrends?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ericaddison/APT_miniProject/issues/23#issuecomment-333854585, or mute the thread https://github.com/notifications/unsubscribe-auth/ACI-Nd0Fu5dvboIUQLHb3fPgJj5DY5isks5sokDLgaJpZM4PsF_E .

ericaddison commented 7 years ago

oh cool, that is a nice feature (the cron.yaml)