Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-090
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-090
2021-090
Commits
ae107536
Commit
ae107536
authored
Nov 08, 2021
by
IT18111170-Silva S.H.I
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: area calculation and value price
parent
6cf873f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
4 deletions
+39
-4
Agri_Backend/Agripreneur_App/Routes/Gamification.py
Agri_Backend/Agripreneur_App/Routes/Gamification.py
+39
-4
No files found.
Agri_Backend/Agripreneur_App/Routes/Gamification.py
View file @
ae107536
from
extensions
import
mongo
,
db
from
Main
import
app
from
flask
import
Response
,
request
from
flask
import
Response
,
request
,
session
# import pymongo
import
json
from
bson.objectid
import
ObjectId
...
...
@@ -13,16 +13,51 @@ from Agripreneur_App.Auth.Token import check_for_token
@
app
.
route
(
"/points/<id>"
,
methods
=
[
"POST"
])
#
@check_for_token
@
check_for_token
def
add_points_earns
(
id
):
# print(request.headers)
# print(request.form)
request
.
headers
area
=
request
.
form
[
'name'
]
print
(
area
)
gArea
=
int
(
area
)
title
=
request
.
form
[
'title'
]
print
(
title
)
id
=
session
[
'Auth'
][
'_id'
]
print
(
id
)
try
:
# points 1-10
# points = 4000
# calculation of earned with area given by user with the selected crop which is given from FE
if
title
==
"carrot"
:
number_plants_can_be_grown_each_meter
=
100
number_of_plants_can_be_grown_in_givenArea
=
100
*
gArea
number_of_plants_contain_in_1kg
=
400000
number_of_kg_of_plant_can_be_grown_in_givenArea
=
number_of_plants_can_be_grown_in_givenArea
/
number_of_plants_contain_in_1kg
kg1_price_of_plants
=
150
earns
=
kg1_price_of_plants
*
number_of_kg_of_plant_can_be_grown_in_givenArea
if
title
==
"tomato"
:
number_plants_can_be_grown_each_meter
=
100
number_of_plants_can_be_grown_in_givenArea
=
100
*
gArea
number_of_plants_contain_in_1kg
=
400000
number_of_kg_of_plant_can_be_grown_in_givenArea
=
number_of_plants_can_be_grown_in_givenArea
/
number_of_plants_contain_in_1kg
kg1_price_of_plants
=
150
earns
=
kg1_price_of_plants
*
number_of_kg_of_plant_can_be_grown_in_givenArea
if
title
==
"chilli"
:
number_plants_can_be_grown_each_meter
=
100
number_of_plants_can_be_grown_in_givenArea
=
100
*
gArea
number_of_plants_contain_in_1kg
=
400000
number_of_kg_of_plant_can_be_grown_in_givenArea
=
number_of_plants_can_be_grown_in_givenArea
/
number_of_plants_contain_in_1kg
kg1_price_of_plants
=
150
earns
=
kg1_price_of_plants
*
number_of_kg_of_plant_can_be_grown_in_givenArea
# area_earn = request.form.get("earns")
earns
=
5000
0
# earns = 50000
points
=
0
# points calculation algorithm
if
earns
>=
5000
:
points
=
10
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment