Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
  •  
  •  
  •  
136 changes: 136 additions & 0 deletions Functions/ComputeOCR
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import json
import boto3
import random
from botocore.vendored import requests
import math

def lambda_handler(event, context):
# TODO implement

#data=json.loads(event['body'])
# print (data)

type="ocr"
path= "https://qph.fs.quoracdn.net/main-qimg-bbbd1a99c44f892c9210e2a82d39b916"

#path="https://mshack2020.s3.amazonaws.com/uploads/image.jpg"
s3 = boto3.resource('s3')
dynamodb = boto3.resource('dynamodb')

table_Claimed = dynamodb.Table('Claimed')
table_Documents = dynamodb.Table('Documents')
table_Rewards = dynamodb.Table('Rewards')
table_Trips = dynamodb.Table('Trips')

bucket = s3.Bucket('mshack2020')

url='http://datalake.intelligeni.com:9999/getocr'
headers = {'Content-Type': 'application/json'}



table_Documents.put_item(
Item={
'Path': path,
'Type' : type,
'Current_status' : 'Unrewarded'
}
)

if type == "ocr":

#params=json.dumps(params)
params={'type': type, 'image': path }
response = requests.request("POST", url, json=params,headers=headers,verify=False)
print (response.json())
result_ocr=response.json()

date = result_ocr['date']
print (date)
print("1")
distance= result_ocr['distance']
start=result_ocr['from']
end=result_ocr['to']
cost=(result_ocr['fare'])
trip_id=result_ocr['tripId']
mode= 'KSRTC'

elif type == 'document':
params={'type': type, 'pdf': path }
response = requests.request("POST", url, headers=headers, json=params, verify=False)
print (response)
result_doc=response.json()
print (result_doc)
date = result_doc['date']
distance= int(result_doc['distance'])
start=result_doc['from']
end=result_doc['to']
cost=int(result_doc['fare'])
trip_id=result_doc['tripId']
mode=result_doc['mode']


elif mode == 'Uber':
Image = " https://upload.wikimedia.org/wikipedia/commons/7/79/Uber_App_Icon.svg"
elif mode == "Ola":
Image = "https://res-5.cloudinary.com/crunchbase-production/image/upload/c_lpad,h_120,w_120,f_auto,b_white,q_auto:eco/v1459446250/xx0u5xwwzygivm67ogsk.jpg"
elif mode == 'Quickride':
Image = "https://pbs.twimg.com/profile_images/1095218429798182912/qvGI0No-_400x400.jpg"

table_Trips.put_item(
Item={
'Path': path,
'Type' : type,
'Date' : date,
'Start' : start,
'End': end,
'Cost': str(cost),
'Trip_ID': trip_id,
'Distance': str(distance),


}
)
if mode == 'KSRTC':
value = int(cost/2 + distance)
elif mode == 'Ola' or mode == 'Uber':
value = int(cost/5 + distance)
elif mode == 'Quickride':
value = int(cost/3 +distance)

table_Rewards.put_item(
Item={
'Path': path,
'Type' : type,
'Date' : date,
'Start' : start,
'End': end,
'Cost': str(cost),
'Trip_ID': trip_id,
'Distance': str(distance),
'Mode': 'KSRTC',
'Reward_value': str(value)

}
)

response = table_Documents.update_item(
Key={
'Path': path
},
UpdateExpression="set Current_status = :r",
ExpressionAttributeValues={
':r': 'Reward points awarded'
},
ReturnValues="UPDATED_NEW"
)





return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}

54 changes: 54 additions & 0 deletions Functions/Dashboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import boto3
import json
import decimal
from botocore.vendored import requests
from boto3.dynamodb.conditions import Key, Attr


def lambda_handler(event, context):
# TODO implement
dynamodb = boto3.resource('dynamodb')
table_Claimed = dynamodb.Table('Claimed')
table_Documents = dynamodb.Table('Documents')
table_Rewards = dynamodb.Table('Rewards')
table_Trips = dynamodb.Table('Trips')

response_rewards = table_Rewards.scan()
items_rewards = response_rewards['Items']
print (items_rewards)

response_trips = table_Trips.scan()
items_trips = response_trips['Items']

response_claimed = table_Claimed.scan()
items_claimed = response_claimed['Items']

sum_rewards=0
sum_trips=0
sum_claimed=0
i=0
for item in items_trips:
sum_trips=sum_trips+int(item['Cost'])
i+=1

for item in items_rewards:
sum_rewards=sum_rewards+int(item['Reward_value'])

for item in items_claimed:
sum_claimed=sum_claimed+int(item['Claimed_value'])

params= {
"trips": sum_trips,
"rewards": sum_rewards,
"claimed" : sum_claimed,
"total": i
}




return {
'statusCode': 200,
'body': json.dumps(params)
}

27 changes: 27 additions & 0 deletions Functions/GetClaims
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import boto3
import json
import decimal
from botocore.vendored import requests
from boto3.dynamodb.conditions import Key, Attr


def lambda_handler(event, context):
# TODO implement
#data=json.loads(event['body']['trip_id'])
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('Claimed')

response = table.scan()
items = response['Items']
print(items)

headers = {'Content-Type': 'application/json'}
params={ 'claimed' : items }
print (params)


return {
'statusCode': 200,
'body': json.dumps(params)
}

27 changes: 27 additions & 0 deletions Functions/GetTrips
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import boto3
import json
import decimal
from botocore.vendored import requests
from boto3.dynamodb.conditions import Key, Attr


def lambda_handler(event, context):
# TODO implement
#data=json.loads(event['body']['trip_id'])
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('Trips')

response = table.scan()
items = response['Items']
print(items)

headers = {'Content-Type': 'application/json'}
params={ 'trips' : items }
print (params)


return {
'statusCode': 200,
'body': json.dumps(params)
}

27 changes: 27 additions & 0 deletions Functions/Rewards
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import boto3
import json
import decimal
from botocore.vendored import requests
from boto3.dynamodb.conditions import Key, Attr


def lambda_handler(event, context):
# TODO implement
#data=json.loads(event['body']['trip_id'])
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('Rewards')

response = table.scan()
items = response['Items']
print(items)
url=''
headers = {'Content-Type': 'application/json'}
params={ 'rewards' : items }
print (params)


return {
'statusCode': 200,
'body': json.dumps(params)
}

6 changes: 6 additions & 0 deletions WeCare/.buckconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[android]
target = Google Inc.:Google APIs:23

[maven_repositories]
central = https://repo1.maven.org/maven2
4 changes: 4 additions & 0 deletions WeCare/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: '@react-native-community',
};
75 changes: 75 additions & 0 deletions WeCare/.flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
[ignore]
; We fork some components by platform
.*/*[.]android.js

; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

; Ignore polyfills
node_modules/react-native/Libraries/polyfills/.*

; These should not be required directly
; require from fbjs/lib instead: require('fbjs/lib/warning')
node_modules/warning/.*

; Flow doesn't support platforms
.*/Libraries/Utilities/LoadingView.js

[untyped]
.*/node_modules/@react-native-community/cli/.*/.*

[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow/

[options]
emoji=true

esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable

module.file_ext=.js
module.file_ext=.json
module.file_ext=.ios.js

munge_underscores=true

module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

[lints]
sketchy-null-number=warn
sketchy-null-mixed=warn
sketchy-number=warn
untyped-type-import=warn
nonstrict-import=warn
deprecated-type=warn
unsafe-getters-setters=warn
inexact-spread=warn
unnecessary-invariant=warn
signature-verification-failure=warn
deprecated-utility=error

[strict]
deprecated-type
nonstrict-import
sketchy-null
unclear-type
unsafe-getters-setters
untyped-import
untyped-type-import

[version]
^0.105.0
1 change: 1 addition & 0 deletions WeCare/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj -text
Loading