Skip to content

Commit e6ec23c

Browse files
Merge branch 'dev'
2 parents 052d2c8 + e7fb258 commit e6ec23c

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

backend-python/src/media_impact_monitor/data_loaders/news_online/mediacloud_.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import random
22
from datetime import date, timedelta
33
from typing import Literal
4+
from time import sleep
45

56
import mediacloud.api
67
import pandas as pd
8+
from tqdm import tqdm
79
from dateutil.relativedelta import relativedelta
810
from mcmetadata import extract
911
from mcmetadata.exceptions import BadContentError
@@ -55,6 +57,7 @@ def get_mediacloud_counts(
5557

5658
@cache
5759
def _story_list(**kwargs):
60+
sleep(30) # undocumented rate limit, see https://github.com/mediacloud/api-client/issues/107#issuecomment-2977041385
5861
return search.story_list(**kwargs)
5962

6063

@@ -126,12 +129,7 @@ def func(start_and_end):
126129
)
127130

128131
label = "Downloading metadata by month"
129-
stories_lists = parallel_tqdm(
130-
func,
131-
_slice_date_range(start_date, end_date),
132-
desc=f"{label:<{40}}",
133-
n_jobs=8,
134-
)
132+
stories_lists = [func(start_and_end) for start_and_end in tqdm(_slice_date_range(start_date, end_date), desc=f"{label:<{40}}")]
135133
stories = [s for sl in stories_lists for s in sl]
136134
if len(stories) == 0:
137135
return None

backend-python/src/media_impact_monitor/fulltexts_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def test_get_fulltexts_for_org(default_start_date, default_end_date):
3434

3535
def test_get_fulltexts_for_event():
3636
for event_id in [
37-
"5599ac04e1fab5e59639d5646ed331ec", # LG event on 2024-05-17
38-
"7c46b5c07afe076ee58ae1c79eccc367", # LG event on 2024-05-18
37+
"36c654cae3ba2fc2ec18d6e537a0f286",
38+
"1e9fd86a4b093ee9edb7f807fd30078f",
3939
]:
4040
texts = get_fulltexts(
4141
FulltextSearch(

0 commit comments

Comments
 (0)