Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ncov
/
back
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
lintry
2020-01-29 15:14:30 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ef3ac93ecee355d7cdd8ab51b9b2177115263311
ef3ac93e
1 parent
033feac2
连续日期中缺失的日期为上一天数据
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
server/routers/c/info_action.js
server/routers/c/info_action.js
View file @
ef3ac93
...
...
@@ -33,15 +33,25 @@ module.exports = function (dbo) {
// 代码逻辑区域
let
result
=
await
dbo
.
query
(
`
with days as (
select generate_series('2020-01-24'::date, CURRENT_DATE, '1 days')::date today
select generate_series('2020-01-24'::date, CURRENT_DATE, '1 days')::date today
)
select province_short_name, d.today, max(confirmed_count) confirmed_count
, stats as (
select province_short_name province, d.today, max(confirmed_count) confirmed_count
from days d
left join tb_mf_timeline_area ta on ta.update_time::date = d.today
where 1=1
and province_name ~ :province_name
group by 1,2
order by 2, 1
)
, pr as (
select province from stats group by 1
)
select pr.province, d.today, COALESCE(st.confirmed_count, lag(st.confirmed_count) over(partition by pr.province order by d.today))
from pr
cross join days d
left join stats st on st.province = pr.province and st.today = d.today
order by 1,2
`
,
{
replacements
:
{
province_name
},
type
:
dbo
.
QueryTypes
.
SELECT
});
return
Result
.
Ok
(
'成功!'
,
result
);
...
...
@@ -66,11 +76,11 @@ module.exports = function (dbo) {
// 代码逻辑区域
let
result
=
await
dbo
.
query
(
`
with t as (
select update_time, province_short_name, confirmed_count, suspected_count, cured_count, dead_count, "comment", cities, country, row_number() over(partition by province_short_name order by update_time desc) rn
select update_time, province_short_name
province
, confirmed_count, suspected_count, cured_count, dead_count, "comment", cities, country, row_number() over(partition by province_short_name order by update_time desc) rn
from tb_mf_timeline_area
where update_time::date = :date
)
select update_time, province
_short_name
, confirmed_count, suspected_count, cured_count, dead_count, "comment", cities, country
select update_time, province, confirmed_count, suspected_count, cured_count, dead_count, "comment", cities, country
from t
where rn = 1
order by confirmed_count desc
...
...
Please
register
or
login
to post a comment