Skip to content

kfreedland/CS169GAP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CS169GAP

RUN CONFIGURATION

Info needed to Run App:

Run the following commands to install all dependencies

sudo npm install

sudo npm install -g

Also need to create the database and tables: instructions found below

<p>To run the app on your local machine:</p>
<p><tt>geddy</tt></p>
<p>Visit <tt>localhost.com:4000</tt></p>

<p>To visit our app online:</p>
<p>Heroku URL: thawing-hamlet-4089.herokuapp.com</p>

<p>Instructions on testing the code found below</p>

CHANGELOGS:

Changelog Entry 17: //Added getEvent API

Changelog Entry 16: //Edited database creation for comments

Changelog Entry 15: //Edited database creation statements for mynotifications field on users

Changelog Entry 14: //Updated Real-Time Invite Notifications Spec in doc

Changelog Entry 13: //Updated getMyEvents API for past events

Changelog Entry 12: //Added Section for Running Socket.IO

Changelog Entry 11: //Added getActivityById Method to Activity

Changelog Entry 10: //Updated Run Configuration

Changelog Entry 9: //Added getMyEvents API //Added response information for User API section

Changelog Entry 8: //Update Testing Information With Code Coverage

Changelog Entry 7: //Updated Header for JSON Object

Changelog Entry 6: //Added Selenium Automation tests

Changelog Entry 5: //Added information on how to test locally

Changelog Entry 4: //Changing all Activities parameters to No Camel Case //Flag is camelCase

Changelog Entry 3: //errCode

7 - Backend Error

Changelog Entry 2: //ActivityModel Fields

  • Category: string

Changelog Entry 1: //required fields that the client checks is valid

  • flag
  • begin_date
  • end_date
  • latitude
  • longitude

Changelog Entry 0: //ActivityModel Fields

  • Name: string
  • Description: string
  • time1: time
  • time2: time
  • flag: string -vals=startEnd, openClose, anyTime, dayTime, nightTime

  • begin_date: date
  • end_date: date
  • low_price: int
  • high_price: int
  • low_num_participants: int
  • high_num_participants: int
  • latitude: number
  • longitude: number
  • category: string

API:

Response Status Codes:

  • 200 - Success
  • 500 - Internal Server Error
  • 401 - Unauthorized
  • 404 - Not Found
errCode:
  • 1 - Success (for all API)
  • 2 - User Exists (for Create User)
  • 3 - Username Too Long / Empty (for Create User)
  • 4 - Password Too Long / Empty (for Create User)
  • 5 - Auth Failed (for Login)
  • 6 - Missing Required Parameter (for Create/Find Activity/Event)
  • 7 - Backend Error - Probably retry
  • 8 - Event dates/times are incorrect (begindate > enddate)
  • 9 - User/Activity specified to add to the event does not exist
  • 10 - EventID passed to backend does not correspond to a valid event
  • 11 - Event date/time is invalid
  • 12 - Atleast one email in the list of emails is malformed
  • 13 - Invite Email failed to send
  • 14 - Email given at user creation is invalid

ACTIVITIES

GET ACTIVITY BY ID
//Gets an activity for the given id

Params:

    { 'activityid': [string, required] }

Response

    {
  • 'errCode': [1 if success, 6 if missing activityid, 7 if database error]
  • 'activity': [JSON encoded Activity Model if errCode=1, null otherwise]
  • }
CREATE ACTIVITY AND SEARCH FOR ACTIVITY:
//Creates activity in database with corresponding fields

Params:

    {
  • 'name': [string, required],
  • 'description': [string],
  • 'time1': [int milliseconds since midnight, required-IF flag=='startEnd' || flag=='openClose'],
  • 'time2': [int, milliseconds since midnight, required-IF flag=='startEnd' || flag=='openClose'],
  • 'flag': [string subset of: {'startEnd', 'openClose', 'anyTime', 'dayTime', 'nightTime'}, required],
  • 'begin_date': [milliseconds since epoch, int],
  • 'end_date': [milliseconds since epoch, int],
  • 'low_price': [int, required],
  • 'high_price': [int, required],
  • 'low_num_participants': [int],
  • 'high_num_participants': [int],
  • 'latitude': [number],
  • 'longitude': [number],
  • 'category': [string]
  • }

EVENTS

CREATE EVENT
//Creates an event and returns it with the corresponding fields

Params:

    {
  • 'name': [string],
  • 'description': [string],
  • 'time1': [int milliseconds since midnight],
  • 'time2': [int, milliseconds since midnight],
  • 'begindate': [milliseconds since epoch, int],
  • 'enddate': [milliseconds since epoch, int],
  • 'attendingusers': [CSV string of user ids, not including creator of event],
  • 'activity':[activity recordID corresponding to this event]
  • }
CHANGE DATE/TIME OF EVENT
//Changes the date and/or time of an event already made

URL:

/events/changedatetime

Params:

    {
  • 'eventid': [string],
  • 'time1': [int milliseconds since midnight],
  • 'time2': [int, milliseconds since midnight],
  • 'begindate': [milliseconds since epoch, int],
  • 'enddate': [milliseconds since epoch, int]
  • }
    
    only pass fields that are changed
    

Response:

  • 'errCode': [1 = success, 6 = missing eventID or date/time parameters, 10 = invalid event, 11 = invalid date/times]
  • 'message': [string] more info about error
INVITE FRIENDS TO AN EVENT
//Sends email to emails provided

URL:

/events/adduserstoevent

Params:

    {
  • 'eventid': [string],
  • 'usernames': [CSV string of usernames]
  • }

Response:

  • 'errCode': [1 = success, 6 = missing eventID or email list parameters, 10 = invalid event, 12 = some emails were malformed, 13 = Invite email failed to send for whatever reason ]
  • 'bademails': [if errCode = 12, contains list of malformed emails, else null]
  • 'message': [string] further explains any error code
GET MY EVENTS
//Returns a list of events for the current user

URL:

/events/getmyevents

Params: (there are no params)

    { }

Response:

  • 'errCode': [1 = success]
  • 'currentEvents': [Contains list of current events for the current user]
  • 'pastEvents': [Contains list of past events for the current user]
  • OR
    <li>Redirect to /login if User Not Authenticated</li>
    
GET EVENT
//Returns a single event for the specified eventId

URL:

/events/getevent

Params:

    { eventId: [eventId of event you want] }

Response:

  • 'errCode': [1 = success]
  • 'event': [Contains single event or empty object]
  • OR
    <li>Redirect to /login if User Not Authenticated</li>
    
REMOVE USER FROM EVENT
//removes a user from attending on an event and removes event from user's myevents

URL:

/events/removeuser

Params:

    {
  • 'eventid': [string],
  • 'userid': [string],
  • }

Response:

  • 'errCode': [1 = success, 6 = missing required param, 7 = backend error, 10 invalid eventid/userid]
ADD COMMENT
//adds a comment to an events list of comments

URL:

/comments/add

Params:

    {
  • 'eventid': [string],
  • 'userid': [userId string],
  • 'text': [String]
  • }

Response:

  • 'errCode': [1 = success, 6 = missing required param or null comment, 7 = backend error, 10 invalid userid/eventid]
GET COMMENTS FOR EVENT
//Returns a list of comments for a given event

URL:

/comments/getcommentsforevent

Params:

    {
  • 'eventid': [string],
  • }

Response:

  • 'errCode': [1 = success, 6 = missing required param, 7 = backend error, 10 invalid eventid]
  • 'comments': json list of comment models from this event
User

Params:

    {
  • 'userName': [string],
  • 'firstName': [string],
  • 'lastName': [string],
  • 'password': [string],
  • 'email': [string],
  • 'myevents': [CSV string of event ID's],
  • }

Response

  • 'errCode': [1 = Success (for all API), 2 = User Exists (for Create User), 3 = Username Too Long / Empty (for Create User),

    4 = Password Too Long / Empty (for Create User), 5 = Auth Failed (for Login), 7 = Backend Error - Probably retry

    ]

Testing Locally

Create a Postgres database locally on your machine with the following parameters: user: 'testing' database name: 'postgres' password: 'gap169' host: 'localhost' port: 5432

Then use the following to costruct the tables required to run GAP:

Queries for Database Setup

CREATE TABLE users ( username text, email text, password text, family_name text, given_name text, created_at timestamptz, updated_at timestamptz, myevents text, mynotifications float8, id text );

CREATE TABLE passports ( auth_type text, key text, user_id text, created_at timestamptz, updated_at timestamptz, id text );

CREATE TABLE activities ( name text, description text, category text, time1 float8, time2 float8, flag text, begindate float8, enddate float8, lowprice float8, highprice float8, lownumparticipants float8, highnumparticipants float8, latitude float8, longitude float8, duration float8, created_at timestamptz, updated_at timestamptz, id text );

CREATE TABLE events ( name text, description text, time1 float8, time2 float8, begindate float8, enddate float8, activityid text, attendingusers text, comments text, created_at timestamptz, updated_at timestamptz, id text );

CREATE TABLE comments ( userid text, text text, created_at timestamptz, updated_at timestamptz, id text );

Testing

Running unit tests: npm install -g install postgres with the database configured like the above^^

Install node-jscoverage Download node-jscoverage from here as ZIP: https://github.com/visionmedia/node-jscoverage Extract zip folder to ./node_modules cd ./node_models/node-jscoverage-master ./configure && make && make install

Run Tests geddy jake test

Selenium Automation UI Testing

The Standalone .jar file is included in the project under /test/selenium. The python client is needed in order to run. So you will need python-pip, which you can install (e.g. on Ubutnu it's sudo apt-get install python-pip). Then run the command to install the selenium client with pip install -U selenium

Each file has all the imports needed, so to run, just run the python command with the file python testFile.py

  • init.py is an example file that has some of API calls to make it work. As of right now the only browser that works is Firefox, so please have it installed
  • find_selenium_test.py is the find activity test that looks for activities most closely resembling the search query: 5-15 people, On March 15th, and All Day event.
  • create_selenium_test.py is the create activity test that creates a new activity
  • create_event_test.py is the create activity test that creates a new even from an existing activity

Running Socket.IO FRONTEND var href = document.location.protocol + document.location.hostname + ':8000'; console.log('href =' + href); var socket = io.connect(href); socket.on('bobEvent', function (data) { console.log(data); socket.emit('bobReturn', { my: 'data' }); }); BACKEND geddy.io = require('socket.io').listen(8000); geddy.io.sockets.on('connection', function(socket) {

socket.emit('bobEvent', {message:"This is a bob event."});

socket.on('bobReturn', function (message){
      console.log("GOT BOB RETURN!!!");
});

});

//Events For Invite Every user will register/listen to an invite event with the following structure: Event names: '{username}InviteEvent'

Backend will emit the event when that particular user is invited to a new event. Frontend will listen to event and update the unseen notifications badge.

Event will contain the following information:

Event
    {
  • 'eventName': [string],
  • 'eventId': [string]
  • }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published