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
e84a2e96
Commit
e84a2e96
authored
Aug 11, 2021
by
IT18111170-Silva S.H.I
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UPdate: gamification points calculation
parent
4ba367a6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
25 deletions
+49
-25
Agri_Backend/Agripreneur_App/Routes/Gamification.py
Agri_Backend/Agripreneur_App/Routes/Gamification.py
+21
-21
Agri_Backend/Agripreneur_App/Routes/PricePage.py
Agri_Backend/Agripreneur_App/Routes/PricePage.py
+28
-4
No files found.
Agri_Backend/Agripreneur_App/Routes/Gamification.py
View file @
e84a2e96
...
@@ -13,29 +13,29 @@ from bson.objectid import ObjectId
...
@@ -13,29 +13,29 @@ from bson.objectid import ObjectId
def
add_points_earns
(
id
):
def
add_points_earns
(
id
):
try
:
try
:
# points 1-10
# points 1-10
points
=
4000
#
points = 4000
earns
=
2000
earns
=
2000
# points calculation algorithm
# points calculation algorithm
#
if earns >= 5000:
if
earns
>=
5000
:
#
points = 10
points
=
10
# elif earns >=
4000 and earns <= 5000:
elif
earns
>
4000
and
earns
<=
5000
:
#
points = 9
points
=
9
# elif earns >=
3000 and earns <= 4000:
elif
earns
>
3000
and
earns
<=
4000
:
#
points = 8
points
=
8
# elif earns >=
2000 and earns <= 3000:
elif
earns
>
2000
and
earns
<=
3000
:
#
points = 7
points
=
7
# elif earns >=
1500 and earns <= 2000:
elif
earns
>
1500
and
earns
<=
2000
:
#
points = 6
points
=
6
# elif earns >=
1000 and earns <= 1500:
elif
earns
>
1000
and
earns
<=
1500
:
#
points = 5
points
=
5
# elif earns >=
500 and earns <= 1000:
elif
earns
>
500
and
earns
<=
1000
:
#
points = 4
points
=
4
# elif earns >= 500 and earns <= 10
00:
elif
earns
>
400
and
earns
<=
5
00
:
#
points = 3
points
=
3
# elif earns >= 500 and earns <= 10
00:
elif
earns
>
300
and
earns
<=
4
00
:
#
points = 2
points
=
2
# elif earns >= 100 and earns <= 5
00:
elif
earns
>
100
and
earns
<=
3
00
:
#
points = 1
points
=
1
user_earns
=
db
.
users
.
find_one
({
"_id"
:
ObjectId
(
id
)})
user_earns
=
db
.
users
.
find_one
({
"_id"
:
ObjectId
(
id
)})
# for user in user_earns:
# for user in user_earns:
...
...
Agri_Backend/Agripreneur_App/Routes/PricePage.py
View file @
e84a2e96
...
@@ -6,13 +6,37 @@ import json
...
@@ -6,13 +6,37 @@ import json
from
bson.objectid
import
ObjectId
from
bson.objectid
import
ObjectId
@
app
.
route
(
"/
points
/<id>"
,
methods
=
[
"POST"
])
@
app
.
route
(
"/
discount
/<id>"
,
methods
=
[
"POST"
])
# @check_for_token
# @check_for_token
def
calculate_discount
():
def
calculate_discount
(
id
):
user_earns
=
db
.
CropData
.
find_one
({
"_id"
:
ObjectId
(
id
)})
print
(
user_earns
)
return
Response
(
# if points >= 1:
response
=
json
.
dumps
({
"message"
:
"user points entered"
}),
# discount = 1
# elif points > 2:
# discount = 2
# elif points > 3:
# discount = 3
# elif points > 4:
# discount = 4
# elif points > 5:
# discount = 5
# elif points > 6:
# discount = 6
# elif points > 7:
# discount = 7
# elif points > 8:
# discount = 8
# elif points > 9:
# discount = 9
# elif points > 10:
# discount = 10
return
Response
(
response
=
json
.
dumps
({
"Discount price"
:
discount
}),
status
=
200
,
status
=
200
,
)
)
\ No newline at end of file
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