diff --git a/dags/office/rent/base_price.py b/dags/office/rent/base_price.py index b43f0d4..a06e66a 100644 --- a/dags/office/rent/base_price.py +++ b/dags/office/rent/base_price.py @@ -33,9 +33,11 @@ def calc(city, year_month): if pd.notna(year_month): last_year_month = dateutils.format_date( 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' " else: 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' " date = dateutils.add_months(datetime.today(), months=-1) year_month = int(dateutils.format_date(date, '%Y%m')) @@ -126,7 +128,8 @@ def calc(city, year_month): '$match': { 'estate_type2': estate_type2, 'bed_kind': bed_kind, - 'calc_type': 1 + 'calc_type': 1, + 'date': year_month } }, { @@ -184,7 +187,8 @@ def calc(city, year_month): }, { '$match': { - 'estate_type2': estate_type2 + 'estate_type2': estate_type2, + 'date': year_month } }, { @@ -222,7 +226,8 @@ def calc(city, year_month): }, { '$match': { - 'bed_kind': bed_kind + 'bed_kind': bed_kind, + 'date': year_month } }, { @@ -283,6 +288,11 @@ def calc(city, year_month): 'spherical': True } }, + { + '$match': { + 'date': year_month + } + }, { '$limit': 5 }