优化计算方式
This commit is contained in:
@@ -33,9 +33,11 @@ def calc(city, year_month):
|
|||||||
if pd.notna(year_month):
|
if pd.notna(year_month):
|
||||||
last_year_month = dateutils.format_date(
|
last_year_month = dateutils.format_date(
|
||||||
dateutils.add_months(dateutils.parse_date(str(year_month), '%Y%m'), months=-13), '%Y%m')
|
dateutils.add_months(dateutils.parse_date(str(year_month), '%Y%m'), months=-13), '%Y%m')
|
||||||
|
last_month = dateutils.format_date(dateutils.add_months(dateutils.parse_date(str(year_month), '%Y%m'), months=-1), '%Y%m')
|
||||||
sql += "and p_date >= '" + last_year_month + "01' "
|
sql += "and p_date >= '" + last_year_month + "01' "
|
||||||
else:
|
else:
|
||||||
last_year_month = dateutils.format_date(dateutils.add_months(datetime.now(), months=-13), '%Y%m')
|
last_year_month = dateutils.format_date(dateutils.add_months(datetime.now(), months=-13), '%Y%m')
|
||||||
|
last_month = dateutils.format_date(dateutils.add_months(datetime.now(), months=-1), '%Y%m')
|
||||||
sql += "and p_date >= '" + last_year_month + "01' "
|
sql += "and p_date >= '" + last_year_month + "01' "
|
||||||
date = dateutils.add_months(datetime.today(), months=-1)
|
date = dateutils.add_months(datetime.today(), months=-1)
|
||||||
year_month = int(dateutils.format_date(date, '%Y%m'))
|
year_month = int(dateutils.format_date(date, '%Y%m'))
|
||||||
@@ -126,7 +128,8 @@ def calc(city, year_month):
|
|||||||
'$match': {
|
'$match': {
|
||||||
'estate_type2': estate_type2,
|
'estate_type2': estate_type2,
|
||||||
'bed_kind': bed_kind,
|
'bed_kind': bed_kind,
|
||||||
'calc_type': 1
|
'calc_type': 1,
|
||||||
|
'date': year_month
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -184,7 +187,8 @@ def calc(city, year_month):
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$match': {
|
'$match': {
|
||||||
'estate_type2': estate_type2
|
'estate_type2': estate_type2,
|
||||||
|
'date': year_month
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -222,7 +226,8 @@ def calc(city, year_month):
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
'$match': {
|
'$match': {
|
||||||
'bed_kind': bed_kind
|
'bed_kind': bed_kind,
|
||||||
|
'date': year_month
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -283,6 +288,11 @@ def calc(city, year_month):
|
|||||||
'spherical': True
|
'spherical': True
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'$match': {
|
||||||
|
'date': year_month
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'$limit': 5
|
'$limit': 5
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user