Skip to content

Commit

Permalink
fix: program name can be null when margin is not enough (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
polomarcus authored Sep 26, 2024
1 parent 9cd8967 commit ff9f5bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions quotaclimat/data_processing/mediatree/channel_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
from datetime import datetime
import json
from quotaclimat.data_processing.mediatree.utils import get_epoch_from_datetime, EPOCH__5MIN_MARGIN
from quotaclimat.data_processing.mediatree.utils import get_epoch_from_datetime, EPOCH__5MIN_MARGIN, EPOCH__1MIN_MARGIN

def format_hour_minute(time: str) -> pd.Timestamp:
date_str = "1970-01-01"
Expand Down Expand Up @@ -81,8 +81,8 @@ def get_day_of_week(time: pd.Timestamp) -> int:
def get_matching_program_hour(df_program: pd.DataFrame, start_time: pd.Timestamp):
start_time = get_hour_minute(start_time)
matching_rows = df_program[
(df_program['start'] <= (start_time + pd.Timedelta(seconds=EPOCH__5MIN_MARGIN))) &
(df_program['end'] > (start_time - pd.Timedelta(seconds=EPOCH__5MIN_MARGIN))) # stricly > to avoid overlapping programs
(df_program['start'] <= (start_time + pd.Timedelta(seconds=EPOCH__5MIN_MARGIN + EPOCH__1MIN_MARGIN))) &
(df_program['end'] > (start_time - pd.Timedelta(seconds=EPOCH__5MIN_MARGIN + EPOCH__1MIN_MARGIN)))
]
if(len(matching_rows) > 1): # no margin necessary because programs are next to each others
return df_program[
Expand Down
1 change: 1 addition & 0 deletions quotaclimat/data_processing/mediatree/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

timezone='Europe/Paris'
EPOCH__5MIN_MARGIN = 300
EPOCH__1MIN_MARGIN = 60 # to add margin for program

def get_keyword_time_separation_ms(duration_seconds: int = 15):
return duration_seconds * 1000
Expand Down

1 comment on commit ff9f5bb

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
postgres
   insert_data.py43784%36–38, 56–58, 63
   insert_existing_data_example.py19384%25–27
postgres/schemas
   models.py1501093%124–131, 143–144, 202–203, 217–218
quotaclimat/data_ingestion
   scrap_sitemap.py1341787%27–28, 33–34, 66–71, 95–97, 138–140, 202, 223–228
quotaclimat/data_ingestion/ingest_db
   ingest_sitemap_in_db.py553733%21–42, 45–58, 62–73
quotaclimat/data_ingestion/scrap_html
   scrap_description_article.py36392%19–20, 32
quotaclimat/data_processing/mediatree
   api_import.py21413537%44–48, 53–72, 76–79, 85, 88–130, 136–151, 156, 169–181, 185–191, 204–216, 219–223, 229, 265–266, 269–305, 308–310
   channel_program.py1625864%28–30, 41–43, 60–61, 64–66, 100, 112, 117–119, 164–205
   config.py15287%7, 16
   detect_keywords.py209896%220, 278–285
   update_pg_keywords.py624527%14–107, 130, 137–141, 164–190, 197
   utils.py712269%29–53, 56, 65, 86–87
quotaclimat/utils
   healthcheck_config.py291452%22–24, 27–38
   logger.py241154%22–24, 28–37
   sentry.py11282%22–23
TOTAL126037470% 

Tests Skipped Failures Errors Time
89 0 💤 0 ❌ 0 🔥 1m 40s ⏱️

Please sign in to comment.