Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier-Do committed Dec 17, 2024
1 parent 09b14e1 commit 4465a14
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions runbot/models/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ class BuildResult(models.Model):
commit_export_ids = fields.One2many('runbot.commit.export', 'build_id')

static_run = fields.Char('Static run URL')
has_database = fields.Boolean()

access_token = fields.Char('Token', default=lambda self: uuid.uuid4().hex)

Expand Down Expand Up @@ -962,6 +963,7 @@ def _get_modules_to_test(self, modules_patterns=''):

def _local_pg_dropdb(self, dbname):
msg = ''
self._build_from_dest(dbname).has_database = False
try:
with local_pgadmin_cursor() as local_cr:
query = 'SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname=%s'
Expand All @@ -981,6 +983,7 @@ def _local_pg_createdb(self, dbname):
with local_pgadmin_cursor() as local_cr:
local_cr.execute(sql.SQL("""CREATE DATABASE {} TEMPLATE %s LC_COLLATE 'C' ENCODING 'unicode'""").format(sql.Identifier(dbname)), (db_template,))
self.env['runbot.database'].create({'name': dbname, 'build_id': self.id})
self.has_database = True

def _log(self, func, message, *args, level='INFO', log_type='runbot', path='runbot'):
def truncate(message, maxlenght=300000):
Expand Down
9 changes: 7 additions & 2 deletions runbot/templates/utils.xml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,12 @@
<a t-if="bu.static_run" t-att-href="bu.static_run" class="btn btn-info" title="View result" aria-label="View result">
<i class="fa fa-sign-in"/>
</a>
<a groups="base.group_user" t-if="bu.local_state=='done' and (not bu.parent_id.database_ids or user_id.has_group('runbot.group_runbot_advanced_user')) and bu.requested_action != 'wake_up' and bu.database_ids" href="#" data-runbot="wakeup" t-att-data-runbot-build="bu.id" class="btn btn-default" title="Wake up this build" aria-label="Wake up this build">
<a groups="base.group_user"
t-if="bu.local_state=='done' and (not bu.parent_id.database_ids or user_id.has_group('runbot.group_runbot_advanced_user')) and bu.requested_action != 'wake_up' and bu.host_id.active and bu.has_database"
href="#" data-runbot="wakeup" t-att-data-runbot-build="bu.id"
t-attf-class="btn btn-{{'default' if bu.has_database else 'danger'}}"
t-attf-title="Wake up this build {{'()' if bu.has_database else 'No database found, may create an empty one'}}"
aria-label="Wake up this build">
<i class="fa fa-coffee"/>
</a>
<a t-attf-href="/runbot/build/{{bu['id']}}" class="btn btn-default" title="Build details" aria-label="Build details">
Expand Down Expand Up @@ -335,7 +340,7 @@
</t>
</t>
<t t-if="bu.global_state == 'done'">
<t t-if="bu.requested_action != 'wake_up' and bu.database_ids">
<t t-if="bu.requested_action != 'wake_up' and any(not db.gced for db in bu.database_ids)">
<a groups="base.group_user" class="dropdown-item" href="#" data-runbot="wakeup" t-att-data-runbot-build="bu['id']">
<i class="fa fa-coffee"/>
Wake up
Expand Down

0 comments on commit 4465a14

Please sign in to comment.