# -*- coding: utf-8 -*-
# Copyright (c) 2021, JINGROW
# For license information, please see license.txt


import jingrow


def execute():
	apps = jingrow.db.sql(
		"""
		SELECT
			app.name, `release`.name as 'release'
		FROM
			`tabBench App` app
		LEFT JOIN
			`tabApp Release` `release`
		ON
			(`release`.hash = app.hash AND `release`.source = app.source)
	""",
		as_dict=True,
	)

	for app in apps:
		jingrow.db.set_value("Bench App", app.name, "release", app.release)
