mirror of
https://github.com/YunoHost/yunorunner.git
synced 2024-09-03 20:05:52 +02:00
Get rid of old apps_list stuff, we ain't gonna need it
This commit is contained in:
parent
0136788358
commit
21514377c4
3 changed files with 108 additions and 116 deletions
|
@ -7,7 +7,6 @@ class Repo(peewee.Model):
|
|||
name = peewee.CharField() # TODO make this uniq/index
|
||||
url = peewee.CharField()
|
||||
revision = peewee.CharField(null=True)
|
||||
app_list = peewee.CharField(null=True)
|
||||
|
||||
state = peewee.CharField(choices=(
|
||||
('working', 'Working'),
|
||||
|
|
26
run.py
26
run.py
|
@ -93,9 +93,7 @@ jinja.env.variable_end_string = '}>'
|
|||
jinja.env.comment_start_string = '<#'
|
||||
jinja.env.comment_end_string = '#>'
|
||||
|
||||
APPS_LISTS = {
|
||||
"Apps": "https://app.yunohost.org/apps.json",
|
||||
}
|
||||
APPS_LIST = "https://app.yunohost.org/default/v2/apps.json"
|
||||
|
||||
subscriptions = defaultdict(list)
|
||||
|
||||
|
@ -197,18 +195,18 @@ async def monitor_apps_lists(type="stable", dont_monitor_git=False):
|
|||
commit_sha = data.decode().strip().replace("\t", " ").split(" ")[0]
|
||||
return commit_sha
|
||||
|
||||
for app_list_name, url in APPS_LISTS.items():
|
||||
async with aiohttp.ClientSession() as session:
|
||||
task_logger.info(f"Downloading {app_list_name}.json...")
|
||||
async with session.get(url) as resp:
|
||||
task_logger.info(f"Downloading applist...")
|
||||
async with session.get(APPS_LIST) as resp:
|
||||
data = await resp.json()
|
||||
data = data["apps"]
|
||||
|
||||
repos = {x.name: x for x in Repo.select().where(Repo.app_list == app_list_name)}
|
||||
repos = {x.name: x for x in Repo.select()}
|
||||
|
||||
for app_id, app_data in data.items():
|
||||
commit_sha = await get_master_commit_sha(app_data["git"]["url"])
|
||||
|
||||
if app_data["state"] not in ("working", "validated"):
|
||||
if app_data["state"] not in "working":
|
||||
task_logger.debug(f"skip {app_id} because state is {app_data['state']}")
|
||||
continue
|
||||
|
||||
|
@ -257,7 +255,7 @@ async def monitor_apps_lists(type="stable", dont_monitor_git=False):
|
|||
|
||||
await create_job(app_id, repo.url)
|
||||
|
||||
repo_state = "working" if app_data["state"] in ("working", "validated") else "other_than_working"
|
||||
repo_state = "working" if app_data["state"] == "working" else "other_than_working"
|
||||
|
||||
if repo.state != repo_state:
|
||||
repo.state = repo_state
|
||||
|
@ -277,13 +275,12 @@ async def monitor_apps_lists(type="stable", dont_monitor_git=False):
|
|||
|
||||
# new app
|
||||
elif app_id not in repos:
|
||||
task_logger.info(f"New application detected: {app_id} in {app_list_name}" + (", scheduling a new job" if not dont_monitor_git else ""))
|
||||
task_logger.info(f"New application detected: {app_id} " + (", scheduling a new job" if not dont_monitor_git else ""))
|
||||
repo = Repo.create(
|
||||
name=app_id,
|
||||
url=app_data["git"]["url"],
|
||||
revision=commit_sha,
|
||||
app_list=app_list_name,
|
||||
state="working" if app_data["state"] in ("working", "validated") else "other_than_working",
|
||||
state="working" if app_data["state"] == "working" else "other_than_working",
|
||||
random_job_day=random.randint(1, 28),
|
||||
)
|
||||
|
||||
|
@ -319,7 +316,7 @@ async def monitor_apps_lists(type="stable", dont_monitor_git=False):
|
|||
"data": data,
|
||||
}, ["jobs", f"job-{job_id}", f"app-jobs-{job.url_or_path}"])
|
||||
|
||||
task_logger.info(f"Delete application {repo_name} because it has been removed from the {app_list_name} apps list.")
|
||||
task_logger.info(f"Delete application {repo_name} because it has been removed from the apps list.")
|
||||
data = model_to_dict(repo)
|
||||
repo.delete_instance()
|
||||
|
||||
|
@ -605,7 +602,6 @@ async def ws_apps(request, websocket):
|
|||
"name",
|
||||
"url",
|
||||
"revision",
|
||||
"app_list",
|
||||
"state",
|
||||
"random_job_day",
|
||||
"job_id",
|
||||
|
@ -653,7 +649,6 @@ async def ws_apps(request, websocket):
|
|||
"name": x.name,
|
||||
"url": x.url,
|
||||
"revision": x.revision,
|
||||
"app_list": x.app_list,
|
||||
"state": x.state,
|
||||
"random_job_day": x.random_job_day,
|
||||
"job_id": x.job_id,
|
||||
|
@ -673,7 +668,6 @@ async def ws_apps(request, websocket):
|
|||
"name": repo.name,
|
||||
"url": repo.url,
|
||||
"revision": repo.revision,
|
||||
"app_list": repo.app_list,
|
||||
"state": repo.state,
|
||||
"random_job_day": repo.random_job_day,
|
||||
"job_id": None,
|
||||
|
|
|
@ -113,7 +113,6 @@
|
|||
Vue.set(app.apps[i], 'state', data.state);
|
||||
Vue.set(app.apps[i], 'url', data.url);
|
||||
Vue.set(app.apps[i], 'revision', data.revision);
|
||||
Vue.set(app.apps[i], 'app_list', data.app_list);
|
||||
Vue.set(app.apps[i], 'random_job_day', data.random_job_day);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue