Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
geoserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
backend
geoserver
Commits
06dc1ba0
Commit
06dc1ba0
authored
Sep 25, 2019
by
王凯
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '刷新数据' into 'meilai'
刷新数据 See merge request
!21
parents
76f7bdb3
2c9fceb5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
unit.py
home/unit.py
+1
-1
views.py
home/views.py
+6
-1
No files found.
home/unit.py
View file @
06dc1ba0
...
@@ -19,7 +19,7 @@ def refresh_cache_locations():
...
@@ -19,7 +19,7 @@ def refresh_cache_locations():
locations
=
rpc_client
[
'api/hospital/location'
]()
.
unwrap
()
locations
=
rpc_client
[
'api/hospital/location'
]()
.
unwrap
()
cache_key
=
"hospital_location"
cache_key
=
"hospital_location"
cache_diuration
=
24
*
60
*
6
0
cache_diuration
=
60
*
1
0
#将地理位置信息加入redis缓存
#将地理位置信息加入redis缓存
for
item
in
locations
:
for
item
in
locations
:
lat
=
item
.
get
(
"baidu_loc_lat"
)
if
item
.
get
(
"baidu_loc_lat"
)
else
item
.
get
(
"google_loc_lat"
)
lat
=
item
.
get
(
"baidu_loc_lat"
)
if
item
.
get
(
"baidu_loc_lat"
)
else
item
.
get
(
"google_loc_lat"
)
...
...
home/views.py
View file @
06dc1ba0
...
@@ -72,13 +72,18 @@ def specify_hospitals_distance(q_lng,q_lat,hospital_ids):
...
@@ -72,13 +72,18 @@ def specify_hospitals_distance(q_lng,q_lat,hospital_ids):
message
=
""
message
=
""
result
=
True
result
=
True
cache_key
=
"hospital_location"
if
not
r
.
exists
(
cache_key
):
refresh_cache_locations
()
try
:
try
:
temp_key
=
"hospital_location_temp"
temp_key
=
"hospital_location_temp"
lock_key
=
"hospital_location_lock"
lock_key
=
"hospital_location_lock"
with
r
.
lock
(
lock_key
,
blocking_timeout
=
15
)
as
lock
:
with
r
.
lock
(
lock_key
,
blocking_timeout
=
15
)
as
lock
:
r
.
geoadd
(
cache_key
,
float
(
q_lng
),
float
(
q_lat
),
temp_key
)
r
.
geoadd
(
cache_key
,
float
(
q_lng
),
float
(
q_lat
),
temp_key
)
for
item
in
hospital_ids
:
for
item
in
hospital_ids
:
distance
=
r
.
geodist
(
cache_key
,
temp_key
,
item
)
distance
=
r
.
geodist
(
cache_key
,
temp_key
,
item
,
"km"
)
if
not
distance
:
if
not
distance
:
distance
=
0
distance
=
0
...
...
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