Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr branch #582

Open
wants to merge 492 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
492 commits
Select commit Hold shift + click to select a range
be0db2d
udpated compute happiness
jesbu1 Feb 20, 2018
62170c2
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Feb 20, 2018
7a8b054
fixed division by zero
jesbu1 Feb 20, 2018
b58da47
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Feb 22, 2018
5a5a983
changed structure of debugging statements
jesbu1 Feb 22, 2018
00fb237
changed suggestion_sys to say something else when user has 0 trips
jesbu1 Feb 22, 2018
3556d52
Creating polar bear for a user upon sign up
vasvenk Feb 23, 2018
89d2787
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
vasvenk Feb 23, 2018
f061508
Changed to update oldhappiness to curr happiness
vasvenk Feb 23, 2018
338f7b8
changed webpage
jesbu1 Feb 23, 2018
47b3714
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
1763ae4
User is now added to Tiersys immediately after signup
vasvenk Feb 23, 2018
9cecd4e
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
vasvenk Feb 23, 2018
9820a72
Jesse changes
jesbu1 Feb 23, 2018
824ae3e
analytics and bold
jesbu1 Feb 23, 2018
57aca19
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
08b08cd
must commit
jesbu1 Feb 23, 2018
34afe2e
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
32329e4
Changed because none is bad
vasvenk Feb 23, 2018
c8c089f
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
vasvenk Feb 23, 2018
ac81e4c
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
1a54679
Temporary solution
vasvenk Feb 23, 2018
4afe1b9
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
151bdc9
More none checks
vasvenk Feb 23, 2018
7d6af9e
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
7f4aa12
Commented out immediate polarbear code for now
vasvenk Feb 23, 2018
1528458
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
e54891d
added support for new users in tiersys
jesbu1 Feb 23, 2018
fe5baaa
added polarbear support for new users
jesbu1 Feb 23, 2018
23bb211
more polearbear.py support for new users
jesbu1 Feb 23, 2018
b48aef9
indexing
jesbu1 Feb 23, 2018
656fb0c
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
fa8106e
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Feb 23, 2018
2e49e82
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
130f6da
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Feb 23, 2018
0754dbc
update_one syntax
jesbu1 Feb 23, 2018
7b078f6
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
832e226
fixed syntax
jesbu1 Feb 23, 2018
24975e8
Uncommmented registration polabear code
vasvenk Feb 23, 2018
f9586f9
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
vasvenk Feb 23, 2018
e7e4182
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
4baf351
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
d5ec752
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Feb 23, 2018
01c28e1
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
e7c07ce
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Feb 23, 2018
884c29c
fixed another error
jesbu1 Feb 23, 2018
fe4bb43
fixed another syntax
jesbu1 Feb 23, 2018
621b76e
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
2f21b35
testing
jesbu1 Feb 23, 2018
b748627
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
2336a06
fixed jesse error
jesbu1 Feb 23, 2018
03727c2
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
3dea5be
wef
jesbu1 Feb 23, 2018
5eb380c
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
3fa1a08
Added to get_databast
vasvenk Feb 23, 2018
ebc5f6e
fix keyerror possibly
jesbu1 Feb 23, 2018
583373a
Made changes to db
vasvenk Feb 23, 2018
a29e0c4
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
vasvenk Feb 23, 2018
6808603
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
4364f56
fixing keyerrror
jesbu1 Feb 23, 2018
115eac5
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
97fdd4d
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
8c8eb40
fixed syntax error
jesbu1 Feb 23, 2018
0ae21dc
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
db75360
fixed nonetype errro'
jesbu1 Feb 23, 2018
60cfa98
Syntax
vasvenk Feb 23, 2018
d107930
Why
vasvenk Feb 23, 2018
ed14e7f
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
4911eab
just trying somethign
jesbu1 Feb 23, 2018
497f469
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
0560dda
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
0b5392f
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
27f7eab
trying to fix issues
jesbu1 Feb 23, 2018
be648ee
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
0adcf57
pls
jesbu1 Feb 23, 2018
ec23180
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
1918d8c
please
jesbu1 Feb 23, 2018
0ac15e4
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
bbede65
hopefully fuixed
jesbu1 Feb 23, 2018
47afaea
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
b47abdb
maybe fixed deletion error
jesbu1 Feb 23, 2018
e8338b0
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
83c80f0
maybe fixed
jesbu1 Feb 23, 2018
95296f9
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
ce1861b
temp fix'
jesbu1 Feb 23, 2018
169066d
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
943b8ee
fix
jesbu1 Feb 23, 2018
79af493
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
a781ecd
fix
jesbu1 Feb 23, 2018
4eb8a00
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
1292522
nonecheck
jesbu1 Feb 23, 2018
240ebb3
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 23, 2018
81354c8
fixed nonechecks
jesbu1 Feb 23, 2018
5278917
get_new_tier_db() method change
jackcsullivan Feb 24, 2018
2624f88
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 24, 2018
a8d9caa
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 24, 2018
ba13e22
update
jesbu1 Feb 24, 2018
2c06f20
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 24, 2018
69d8320
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 24, 2018
06f88e2
added debug
jesbu1 Feb 24, 2018
1c886c5
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 24, 2018
81f2bce
logging error
jesbu1 Feb 24, 2018
081c4de
Fixed none error
vasvenk Feb 24, 2018
8ed0870
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 24, 2018
3b2f0e5
updated suggestion message to ask to tap the suggesiton
jesbu1 Feb 25, 2018
0b50cdc
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 26, 2018
a462b0e
merging
jesbu1 Feb 26, 2018
e4aad38
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Feb 26, 2018
bbdf860
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Feb 26, 2018
205b6f6
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 26, 2018
644929c
added support for new modes mentioned by decision tree in suggestions…
jesbu1 Feb 26, 2018
0e9f07e
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 27, 2018
93d8e65
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Feb 27, 2018
719db6a
fixed typo
jesbu1 Feb 27, 2018
12351fe
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Feb 27, 2018
507ff3c
Added safety check for User.getUsername(user_id)
AndyLc Feb 27, 2018
31d650b
Fix tab-space usage
AndyLc Feb 27, 2018
d00e6c1
Fixed issue with usernames
vasvenk Feb 28, 2018
f711535
Who knows
jesbu1 Feb 28, 2018
325c717
Pls dont break
jesbu1 Feb 28, 2018
308e445
None check:
vasvenk Feb 28, 2018
78e0805
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 28, 2018
22bcdae
First batch of landing page changes
jackcsullivan Feb 28, 2018
c0dc15f
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jackcsullivan Feb 28, 2018
2a54ade
This code dont make no sense
vasvenk Feb 28, 2018
8cae37a
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
vasvenk Feb 28, 2018
3fe9319
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 28, 2018
39e164e
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 28, 2018
bf4e507
Draft of study details on landing page
jackcsullivan Feb 28, 2018
048b2d8
changed website text
jesbu1 Feb 28, 2018
ac35d1f
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 28, 2018
c8610c0
landing pages misc changes
jackcsullivan Feb 28, 2018
d44386f
made landing page header black and bold
jesbu1 Feb 28, 2018
4f0bca9
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Feb 28, 2018
06807cb
website changes
jesbu1 Feb 28, 2018
182baa2
added support for scss filepath in webapp
jesbu1 Feb 28, 2018
0d346c5
webserver changes
jesbu1 Feb 28, 2018
4a26ca5
added navbar collapsable menu so it doesn't take up the whole screen …
jesbu1 Mar 1, 2018
21bc61d
log intake
AndyLc Mar 1, 2018
88ce09a
added raw carbon metric for user
jesbu1 Mar 2, 2018
ab07647
Modified tiersys to save user metrics in a new DB
vasvenk Mar 2, 2018
9e1044a
conf
AndyLc Mar 2, 2018
310c82a
emission
AndyLc Mar 2, 2018
80702ad
Added client in try block
vasvenk Mar 2, 2018
830d691
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Mar 2, 2018
465bb03
added note to step 2 of landing page
jackcsullivan Mar 4, 2018
bc142d1
fixing error in suggestion sys
jesbu1 Mar 4, 2018
a6c1f8f
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Mar 4, 2018
f03a793
polar bear math update
AndyLc Mar 4, 2018
bf9605f
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Mar 4, 2018
e21701b
fix addition
AndyLc Mar 4, 2018
7e11692
Fixed carbonTierRank
vasvenk Mar 4, 2018
f16c016
fixing new user tier maybe
jesbu1 Mar 5, 2018
239f1c2
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Mar 5, 2018
1a22ad6
pushing hotfix
jesbu1 Mar 5, 2018
4e5b789
hotfix for polarbear
jesbu1 Mar 5, 2018
231d83d
forgot to import datetime
jesbu1 Mar 5, 2018
a565e31
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Mar 5, 2018
ea92cca
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Mar 5, 2018
e3688a4
fixed divding into buckets
jesbu1 Mar 5, 2018
d4194fa
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Mar 5, 2018
9144bf9
trying another way to divide into buckets
jesbu1 Mar 5, 2018
fe4021b
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Mar 5, 2018
0502bf8
added debugging print statements
jesbu1 Mar 5, 2018
518a614
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Mar 5, 2018
3b11f2d
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Mar 5, 2018
8f4c880
found source of weird buckets error
jesbu1 Mar 5, 2018
2149e80
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Mar 5, 2018
4776975
syntax fix
jesbu1 Mar 5, 2018
242b229
refactor
jesbu1 Mar 5, 2018
e0c8c74
added logging statement
jesbu1 Mar 5, 2018
efef18d
fix for polar bear usernames
jesbu1 Mar 5, 2018
f3ebab9
logging debug syntax
jesbu1 Mar 5, 2018
47a44fe
changed to inferred_section for suggestion sys and notification checking
jesbu1 Mar 5, 2018
1b9ae13
Nonetype check
jesbu1 Mar 5, 2018
bb5fa8f
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Mar 5, 2018
a11e319
Changed step 1 come back to this page text to red
jackcsullivan Mar 5, 2018
63964bc
checking in website test file
jesbu1 Mar 5, 2018
95a9642
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Mar 5, 2018
397f9b1
making script more generalizeable
jesbu1 Mar 5, 2018
92b4a88
limiting to 5 polar bears
jesbu1 Mar 7, 2018
fead010
added another nonetype check for username
jesbu1 Mar 8, 2018
cbe2a9c
none error
jesbu1 Mar 8, 2018
5ec3406
cfc_webapp update to get uuid from request
jesbu1 Mar 9, 2018
b8e602a
Made a none chec for tierNum
vasvenk Mar 9, 2018
527923a
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
vasvenk Mar 9, 2018
7b036fe
added faq
tsekylekobie Mar 9, 2018
e3f3d26
omg i think we fixed it
jesbu1 Mar 9, 2018
ed09597
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
tsekylekobie Mar 9, 2018
ed1b1a7
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Mar 9, 2018
b43e8be
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Mar 9, 2018
c37f098
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Mar 9, 2018
16c0169
another nonechcek
jesbu1 Mar 9, 2018
acd2df8
faq
jesbu1 Mar 9, 2018
3209cce
syntax
jesbu1 Mar 9, 2018
a2c90ae
idk man
jesbu1 Mar 9, 2018
5653986
aoiwejf
jesbu1 Mar 9, 2018
d14fd2a
faq
jesbu1 Mar 9, 2018
dbe3315
fixed faq links
tsekylekobie Mar 9, 2018
2044725
fix the css and js links
tsekylekobie Mar 9, 2018
fe72875
fixing dict stuff
jesbu1 Mar 9, 2018
5080f88
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Mar 9, 2018
1eb9057
force kill faq
tsekylekobie Mar 9, 2018
eb412bd
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
tsekylekobie Mar 9, 2018
ebd902a
fixed link to home page
tsekylekobie Mar 9, 2018
db9fc2c
fixed penalty metric
jesbu1 Mar 12, 2018
57d9d30
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Mar 12, 2018
a0e4035
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Mar 12, 2018
5f3b387
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Mar 12, 2018
ac9eea0
fixing leaderboard and polar bear size
jesbu1 Mar 12, 2018
45505e4
fix vas error lmao xd
AndyLc Mar 12, 2018
9261dea
hello vas
jesbu1 Mar 12, 2018
3b8465f
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 Mar 12, 2018
8627d55
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
AndyLc Mar 12, 2018
9f0ca5b
user.py and polarbear.py
AndyLc Mar 13, 2018
296864d
adding for info about error
jesbu1 Mar 16, 2018
d8dbe0e
omg
jesbu1 Mar 16, 2018
e0ca162
specialized faq and social media links
tsekylekobie Mar 16, 2018
1a2888a
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
tsekylekobie Mar 16, 2018
7b02fb5
added shared/footer route
tsekylekobie Mar 16, 2018
bf16e9d
preferences screenshot
jackcsullivan Mar 16, 2018
e83c805
fixed social media links
tsekylekobie Mar 19, 2018
bcd8860
Stop landing page image
jackcsullivan Mar 19, 2018
5f9d210
twitter/fb images
jackcsullivan Mar 19, 2018
8f31ccb
rescaled stop sign
jackcsullivan Mar 19, 2018
a7b257d
more stop sign resizing issues
jackcsullivan Mar 19, 2018
ee3376f
changed android link to e++mission
jesbu1 Mar 22, 2018
0395667
added qr code, removed image of second step
jesbu1 Mar 29, 2018
d97024a
weird fixes
jesbu1 Mar 29, 2018
ba68ed1
removed comment
jesbu1 Mar 29, 2018
1ba3d8d
fixed parentheses for suggestion sys
jesbu1 Apr 6, 2018
5ca967e
got rid of stop sign and second arrow
jesbu1 Apr 7, 2018
a862d53
open links in new tab
jesbu1 Apr 10, 2018
ca0373a
fixed typo in faq
tsekylekobie Apr 13, 2018
bbd41d1
updated experiment timeline
tsekylekobie Apr 13, 2018
32f014e
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
tsekylekobie Apr 13, 2018
3c20da6
updated end date
tsekylekobie Apr 13, 2018
33ee0a9
less text on beginning of landing page
jackcsullivan Apr 28, 2018
d5f7d5b
new computecarbon and penalty
jesbu1 May 16, 2018
f6306c4
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 May 16, 2018
dcabbcd
new computecarbon and penalty
jesbu1 May 16, 2018
cc7e8a2
fixed penalty
jesbu1 May 16, 2018
1c369fd
fixed syntax error
jleyden May 18, 2018
3872cbf
fixed syntax error
jesbu1 May 18, 2018
783e646
Merge branch 'master' of https://github.com/AndyLc/e-mission-server
jesbu1 May 18, 2018
9f895fc
another syntax error
jesbu1 May 18, 2018
ab13189
adding responses csv for analysis
jesbu1 Jun 6, 2018
13609ce
removed stuff that shouldn't be checked in
jesbu1 Jun 11, 2018
ca72110
removed matplotlib
jesbu1 Jun 11, 2018
2444df7
removed timeline files that were unnecessary
jesbu1 Jun 11, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
156 changes: 115 additions & 41 deletions Timeseries_Sample.ipynb

Large diffs are not rendered by default.

120 changes: 120 additions & 0 deletions bin/check_for_notifications.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
import emission.storage.timeseries.abstract_timeseries as esta
import emission.net.ext_service.push.notify_usage as pnu
import emission.core.wrapper.user as ecwu
from future import standard_library
standard_library.install_aliases()
from builtins import *
import logging
import logging.config
import argparse
import pandas as pd
import requests
import json
import re
import emission.core.get_database as edb
from uuid import UUID
import emission.core.wrapper.polarbear as pb

def handle_insert(tripDict, tripID, collection, uuid):
if tripDict == None:
collection.insert_one({'uuid': uuid, 'trip_id': tripID})
return True
else:
if tripDict['trip_id'] != tripID:
collection.update_one({'uuid': uuid}, {'$set': {'trip_id' : tripID}})
return True
else:
return False

def calculate_single_suggestion(uuid):
logging.debug("About to calculate single suggestion for %s" % uuid)
all_users = pd.DataFrame(list(edb.get_uuid_db().find({}, {"uuid": 1, "_id": 0})))
#Given a single UUID, create a suggestion for them
suggestion_trips = edb.get_suggestion_trips_db()
return_obj = { 'message': "Good job walking and biking! No suggestion to show.",
'savings': "0", 'start_lat' : '0.0', 'start_lon' : '0.0',
'end_lat' : '0.0', 'end_lon' : '0.0', 'method' : 'bike'}
user_id = all_users.iloc[all_users[all_users.uuid == uuid].index.tolist()[0]].uuid
time_series = esta.TimeSeries.get_time_series(user_id)
cleaned_sections = time_series.get_data_df("analysis/inferred_section", time_query = None)
#Go in reverse order because we check by most recent trip
counter = 40
for i in range(len(cleaned_sections) - 1, -1, -1):
counter -= 1
if counter < 0:
#Iterate 20 trips back
return False
if cleaned_sections.iloc[i]["end_ts"] - cleaned_sections.iloc[i]["start_ts"] < 5 * 60:
continue
distance_in_miles = cleaned_sections.iloc[i]["distance"] * 0.000621371
trip_id = cleaned_sections.iloc[i]['trip_id']
tripDict = suggestion_trips.find_one({'uuid': uuid})
logging.debug("%s" % tripDict)
mode = cleaned_sections.iloc[i]["sensed_mode"]
if mode == 5 and distance_in_miles >= 5 and distance_in_miles <= 15:
logging.debug("Considering section from %s -> %s" %
(cleaned_sections.iloc[i]["start_fmt_time"],
cleaned_sections.iloc[i]["end_fmt_time"]))
#Suggest bus if it is car and distance between 5 and 15
return handle_insert(tripDict, trip_id, suggestion_trips, uuid)
elif mode == 5 or mode == 3 or mode == 4 and distance_in_miles < 5 and distance_in_miles >= 1:
logging.debug("Considering section from %s -> %s" %
(cleaned_sections.iloc[i]["start_fmt_time"],
cleaned_sections.iloc[i]["end_fmt_time"]))
#Suggest bike if it is car/bus and distance between 5 and 1
#TODO: Change ret_boj and figure out how to change lat and lon to places
return handle_insert(tripDict, trip_id, suggestion_trips, uuid)
logging.debug("Considering section from %s -> %s" %
(cleaned_sections.iloc[i]["start_fmt_time"],
cleaned_sections.iloc[i]["end_fmt_time"]))
elif mode == 5 or mode == 3 or mode == 4 and distance_in_miles < 1:
logging.debug("Considering section from %s -> %s" %
(cleaned_sections.iloc[i]["start_fmt_time"],
cleaned_sections.iloc[i]["end_fmt_time"]))
#Suggest walking if it is car/bus and distance less than 1
return handle_insert(tripDict, trip_id, suggestion_trips, uuid)
return False

def push_to_user(uuid_list, message):
logging.debug("About to send notifications to: %s users" % len(uuid_list))
json_data = {
"title": "TripAware Notification",
"message": message
}
logging.debug(uuid_list)
response = pnu.send_visible_notification_to_users(uuid_list,
json_data["title"],
json_data["message"],
json_data,
dev = False)
pnu.display_response(response)

def check_all_suggestions():
suggestion_uuids = []
happiness_uuids = []
all_users = pd.DataFrame(list(edb.get_uuid_db().find({}, {"user_email":1, "uuid": 1, "_id": 0})))
logging.debug("About to iterate over %s users" % len(all_users))
for i in range(len(all_users)):
try:
curr_uuid = all_users.iloc[i].uuid
client = edb.get_profile_db().find_one({"user_id": curr_uuid})['client']
if client == "urap-2017-emotion":
if pb.getMoodChange(curr_uuid):
happiness_uuids.append(curr_uuid)
elif client == "urap-2017-information":
if calculate_single_suggestion(curr_uuid):
suggestion_uuids.append(curr_uuid)
except (KeyError, Exception) as e:
logging.debug("error: " + str(e) + " on %s" % all_users.iloc[i].user_email)
continue
push_to_user(suggestion_uuids, "You have a new suggestion! Tap me to see it.")
push_to_user(happiness_uuids, "Your polar bear's mood has changed since yesterday! Tap me to see it.")

if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
print("Set log level to DEBUG")
check_all_suggestions()
8 changes: 8 additions & 0 deletions bin/make_tiersys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from emission.core.wrapper.tiersys import TierSys
import arrow

if __name__ == '__main__':
ts = TierSys(3)
time = arrow.utcnow().shift(weeks=-1).timestamp
print(ts.updateTiers(time))
print(ts.saveTiers(time))
4 changes: 4 additions & 0 deletions bin/update_polarbear.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import emission.core.wrapper.polarbear as pb

if __name__ == '__main__':
pb.updateAll()
40 changes: 40 additions & 0 deletions conf/log/intake.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"handlers": {
"errors": {
"backupCount": 2,
"mode": "a",
"level": "ERROR",
"formatter": "detailed",
"class": "logging.handlers.RotatingFileHandler",
"maxBytes": 1073741824,
"filename": "/log/intake-errors.log"
},
"console": {
"class": "logging.StreamHandler",
"level": "WARNING"
},
"file": {
"backupCount": 8,
"filename": "/log/intake.log",
"maxBytes": 1073741824,
"mode": "a",
"formatter": "detailed",
"class": "logging.handlers.RotatingFileHandler"
}
},
"version": 1,
"root": {
"handlers": [
"console",
"file",
"errors"
],
"level": "DEBUG"
},
"formatters": {
"detailed": {
"class": "logging.Formatter",
"format": "%(asctime)s:%(levelname)s:%(thread)d:%(message)s"
}
}
}
42 changes: 42 additions & 0 deletions conf/log/webserver.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"handlers": {
"errors": {

"backupCount": 2,
"mode": "a",
"level": "ERROR",
"formatter": "detailed",
"class": "logging.handlers.RotatingFileHandler",
"maxBytes": 1073741824,
"filename": "/log/webserver-errors.log"
},
"console": {
"class": "logging.StreamHandler",
"level": "WARNING"
},
"file": {
"backupCount": 3,

"filename": "/log/webserver.log",
"maxBytes": 1073741824,
"mode": "a",
"formatter": "detailed",
"class": "logging.handlers.RotatingFileHandler"
}
},
"version": 1,
"root": {
"handlers": [
"console",
"file",
"errors"
],
"level": "DEBUG"
},
"formatters": {
"detailed": {
"class": "logging.Formatter",
"format": "%(asctime)s:%(levelname)s:%(thread)d:%(message)s"
}
}
}
16 changes: 16 additions & 0 deletions conf/net/api/webserver.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"paths" : {
"static_path" : "webapp/www/",
"python_path" : "main",
"log_base_dir" : ".",
"log_file" : "debug.log"
},
"__comment" : "Fill this in for the production server. port will almost certainly be 80 or 443. For iOS, using localhost allows you to test without an internet connection. For AWS and android, make sure that the host 0.0.0.0, localhost does not seem to work",
"server" : {
"host" : "0.0.0.0",
"port" : "80",
"__comment": "1 hour = 60 min = 60 * 60 sec",
"timeout" : "3600",
"auth" : "skip"
}
}
5 changes: 5 additions & 0 deletions conf/storage/db.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"timeseries": {
"url":
}
}
2 changes: 1 addition & 1 deletion e-mission-py.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# As we increase the number of directories that we need, this becomes useful.
# Maybe we can restructure the code to avoid this, but this is a useful placeholder until then.

# Make sure that the python here is the anaconda python if that is not the one in the path
# Make sure that the python here is the anaconda python if that is not the one in the pat

PYTHONPATH=. python $*
28 changes: 24 additions & 4 deletions emission/core/get_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@
def _get_current_db():
return _current_db

def get_carbon_usage_db():
return _get_current_db().CarbonUsage

def get_username_db():
return _get_current_db().Usernames

def get_polarbear_db():
return _get_current_db().PolarBear

def get_suggestion_trips_db():
return _get_current_db().SuggestionSys

def get_mode_db():
# #current_db = MongoClient().Stage_database
Modes= _get_current_db().Stage_Modes
Expand Down Expand Up @@ -64,7 +76,7 @@ def get_routeDistanceMatrix_db():
def get_routeDistanceMatrix_db(user_id, method):
if not os.path.exists('routeDistanceMatrices'):
os.makedirs('routeDistanceMatrices')

routeDistanceMatrix = {}
if not os.path.exists('routeDistanceMatrices/' + user_id + '_' + method + '_routeDistanceMatrix.json'):
data = {}
Expand All @@ -79,7 +91,7 @@ def get_routeDistanceMatrix_db(user_id, method):
def update_routeDistanceMatrix_db(user_id, method, updatedMatrix):
f = open('routeDistanceMatrices/' + user_id + '_' + method + '_routeDistanceMatrix.json', 'w+')
f.write(json.dumps(updatedMatrix))
f.close()
f.close()


def get_client_db():
Expand Down Expand Up @@ -256,9 +268,17 @@ def get_fake_sections_db():
FakeSections = _get_current_db().Stage_fake_sections
return FakeSections

def get_tiersys_db():
TierSys=_get_current_db().Tier_Sys
return TierSys

def get_new_tier_db():
newTier =_get_current_db().New_tier
return newTier

# Static utility method to save entries to a mongodb collection. Single
# drop-in replacement for collection.save() now that it is deprecated in
# pymongo 3.0.
# drop-in replacement for collection.save() now that it is deprecated in
# pymongo 3.0.
# https://github.com/e-mission/e-mission-server/issues/533#issuecomment-349430623
def save(db, entry):
# if '_id' in entry:
Expand Down
8 changes: 8 additions & 0 deletions emission/core/wrapper/happiness_change.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import emission.storage.timeseries.abstract_timeseries as esta
import pandas as pd
import requests
import json
import re
import emission.core.get_database as edb
from uuid import UUID
from emission.core.wrapper.user import User
Loading