mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-22 04:54:18 +00:00
Aggiunta la possibilita' di lanciare il crawler su tutte le repository attive
This commit is contained in:
parent
5db3cbb0b2
commit
16579e83a6
1 changed files with 12 additions and 3 deletions
|
@ -4,6 +4,7 @@ from nest_backend.database import *
|
||||||
import tweepy as tw
|
import tweepy as tw
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import smtplib
|
import smtplib
|
||||||
|
from nest_backend.app import app, extension_sqlalchemy
|
||||||
|
|
||||||
ext.init_app(app=app)
|
ext.init_app(app=app)
|
||||||
|
|
||||||
|
@ -24,12 +25,13 @@ def authenticate():
|
||||||
def search_repo_conditions(repository_id):
|
def search_repo_conditions(repository_id):
|
||||||
api = authenticate()
|
api = authenticate()
|
||||||
geocode = "44.3591600,11.7132000,20km"
|
geocode = "44.3591600,11.7132000,20km"
|
||||||
|
|
||||||
repo = Repository.query.filter_by(id=repository_id).first()
|
repo = Repository.query.filter_by(id=repository_id).first()
|
||||||
if repo is None:
|
if repo is None:
|
||||||
print("Non esiste una repository con questo id")
|
print("Non esiste una repository con questo id")
|
||||||
return False
|
return False
|
||||||
conditions = [use for use in repo.conditions]
|
conditions = [use for use in repo.conditions]
|
||||||
|
if len(conditions) == 0:
|
||||||
|
return False
|
||||||
evaluation_mode = repo.evaluation_mode
|
evaluation_mode = repo.evaluation_mode
|
||||||
conditions_type = dict()
|
conditions_type = dict()
|
||||||
# Dividing condition into condition types
|
# Dividing condition into condition types
|
||||||
|
@ -234,7 +236,14 @@ def send_test_tweet():
|
||||||
api = authenticate()
|
api = authenticate()
|
||||||
api.update_status("Test")
|
api.update_status("Test")
|
||||||
|
|
||||||
|
def search_all_repo():
|
||||||
|
active_repos = Repository.query.filter_by(is_active=True)
|
||||||
|
for repo_id in [active_repo.id for active_repo in active_repos]:
|
||||||
|
search_repo_conditions(repo_id)
|
||||||
|
is_repo_alert_triggered(repo_id)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
search_repo_conditions(16)
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
ext.create_all(app=app)
|
search_all_repo()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue