-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
34 lines (28 loc) · 1.09 KB
/
Copy pathmain.py
File metadata and controls
34 lines (28 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from datetime import datetime, timedelta, timezone
from github import github_repo_count
from stackoverflow import stack_overflow_tag_count
from job import remotive_job_count
from trends import get_google_trends
from redis_cache import analysis_cache, analysis_cache_key
def run_analysis(keyword):
keyword = keyword.strip().lower()
since_date = (datetime.now(timezone.utc) - timedelta(days=30)).date()
cache_key = analysis_cache_key(keyword, since_date)
cached_result = analysis_cache.get_json(cache_key)
if cached_result is not None:
print(f"Cache hit for: {keyword}")
return cached_result
github = github_repo_count(keyword, since_date)
stack = stack_overflow_tag_count(keyword)
jobs = remotive_job_count(keyword)
print(f"GitHub: {github}, Stack: {stack}, Jobs: {jobs}")
# if keyword != 'python' and keyword != 'javascript':
# _, graph_path = get_google_trends(keyword)
result = {
"github": github,
"stack": stack,
"jobs": jobs
}
analysis_cache.set_json(cache_key, result)
return result
# , graph_path