Code Monkey home page Code Monkey logo

ldpd-hours's Introduction

LDPD-Hours

Build Status Code Climate Issue Count Coverage Status

Local Installation

  • Git clone this repo

  • Setup a MySQL db locally and add credentials to config/database.yml

  • $ bundle install

  • $ rake db:migrate

  • If you don't have yarn currently installed please run brew install yarn

  • $ yarn

  • $ rake db:seed

    Seeds the db with two locations and an administrative user. Administrative credentials are:

    name: Test User
    email: [email protected]
    
  • $ rails s

  • Navigate to localhost:3000

Testing

You need to install chromedriver for javascript tests.

With Homebrew: brew cask install chromedriver

And on macOS Catalina (10.15) and later, you'll need to update security settings to allow chromedriver to run because the first-time run will tell you that "the developer cannot be verified." See: https://stackoverflow.com/a/60362134

Then run the test suite with:

bundle exec rspec

Notes

Because updating our hours uses a MySQL specific flavor of a batch upsert, if the db provider changes in the future you will need to modify the TimeTable.batch_update_or_create method with SQL appropriate for the db provider.

Configuration

secrets.yml

Configuring analytics_key will cause the public layout to include the GA analytics snippet if the Rails environment config also has track_users set to true.

Permissions

Editors

For a specific calendar:

  • can change time information
  • can edit notes and url for calendar

Manager

  • can do everything an Editor can do, for all locations
  • can add/delete Editor
  • can assign Editors to locations

Administrator

  • can do everything a Manager can do
  • can edit all user permissions (Can create editors, managers and administrators)
  • can create/delete locations
  • can edit location metadata (comments, url, name, primary location)

API

GET api/v1/locations/:location_code

Query Params

  • location_code: Location code
  • date: valid params are today or a date in YYYY-MM-DD format following the w3cdtf specification.
  • start_date: For a range of dates, provide a start date in YYYY-MM-DD format
  • end_date: For a range of date, provide an end date in YYYY-MM-DD format

Query Restrictions

  • start_date and end_date params can be no more than one year apart

Response Examples

GET api/v1/locations/avery?date=today
{
    "error" : null,
    "data" :
    {
	"butler" :
	[
	    {
		"date" : "2017-07-23",
		"open_time" : "09:00",
		"close_time" : "17:00",
		"closed" : false,
		"tbd" : false,
		"note" : "Free Donuts!",
		"formatted_date" : "09:00AM-05:00PM"
	    }
	]
    }
}
GET api/v1/locations/:location_code?start_date=2017-09-27&end_date=2017-09-29
{
    "error" : null,
    "data" :
    {
	"butler" :
	[
	    {
		"date" : "2017-07-24",
		"open_time" : "09:00",
		"close_time" : "17:00",
		"closed" : false,
		"tbd" : false,
		"note" : "Movie night!",
		"formatted_date" : "09:00AM-05:00PM"
	    }
	    ,
	    {
		"date" : "2017-07-25",
		"open_time" : "09:00",
		"close_time" : "17:00",
		"closed" : false,
		"tbd" : false,
		"note" : "",
		"formatted_date" : "09:00AM-05:00PM"
	    }
	    ,
            {
		"date" : "2017-07-26",
		"open_time" : null,
		"close_time" : null,
		"closed" : false,
		"tbd" : true,
		"note" : "",
		"formatted_date" : "TBD"
            }
	]
    }
}

A few notes about the above JSON structure:

  • The last date entry is an example of the default date values that are returned for a date that does not have any associated data in Hours manager. So, in the above example, there was no information in the hours manager database for 07/26/2017 for location butler, and therefore default values were returned for that date.
  • The middle date entry has an empty string value asociated with the "note" key. This is the default value (not null) if no note value was specified in the database for that date entry for the given location.

GET api/v1/locations/open_now

Query Params

 None

Response Example

GET api/v1/locations/open_now
{
    "error" : null,
    "data" :
    {
	"butler" :
	{
	    "open_time" : "09:00",
	    "close_time" : "22:00",
	    "formatted_date" : "Until 10:00PM"
	}
	,
	"avery" :
	{
	    "open_time" : "09:00",
	    "close_time" : "22:00",
	    "formatted_date" : "Until 10:00PM"
	}
    }
}

ldpd-hours's People

Contributors

barmintor avatar er-k avatar oneill38 avatar elohanlon avatar fcd1 avatar jackblacklight avatar

Watchers

 avatar  avatar James Cloos avatar Terry Catapano avatar  avatar  avatar Brian Luna Lucero avatar Kathryn Pope avatar  avatar Ed Madrid avatar  avatar  avatar Amy Nurnberger avatar Candice avatar  avatar  avatar Nathan avatar YIchao Zhang avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.