⌈⌋ branch:  freshcode


Check-in [b4a8119636]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1:b4a81196362b4e35c65aec3e90fe7fcea325e17a
Date: 2014-12-07 21:11:54
User: mario
Comment:Added transactions as suggested by Lothar.
Tags And Properties
  • branch=trunk inherited from [82405bb421]
  • sym-trunk inherited from [82405bb421]
Context
2014-12-07
21:12
[86d391b93b] Block `wagic` (auto-regenerated master release stamps). (user: mario, tags: trunk)
21:11
[b4a8119636] Added transactions as suggested by Lothar. (user: mario, tags: trunk)
21:11
[1285c138f7] No more .trimmed for github-releases sidebar block. (user: mario, tags: trunk)
Changes

Changes to cron.daily/tags.php.

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
35
36
37
38
39
40
41
42


<?php
/**
 * api: cli
 * title: Update `tags` table
 * description: Splits out tags from according column in project `release`.
 * version: 0.3
 * category: postprocessing
 * type: cron
 * x-cron: 10 *\/2 * * *
 *
 * Manually update tags table.
 *   - Splits up comma separated release.tags field
 *   - Maximum of 10 tags each
 *   - Populates separate tags table with name=>tag list.
 *
 * While this could be done in the release::update/::store handler,
 * it's not really urgent to have per-project tags mirrored there.
 * (Externalizing this avoids database load/locks.)

 *
 * Runs every 2 hours.
 *
 */

chdir(dirname(__DIR__)); 
include("config.php");

/**
 * Scan each project,
 * split up `tags` as CSV and just fille up according tags table.
 *
 */

foreach (db("SELECT name, tags, MAX(t_changed) FROM release_versions GROUP BY name")->fetchAll() as $entry) {

    $name = $entry["name"];
    $tags = array_slice(array_filter(p_csv($entry["tags"])), 0, 10);

    db("DELETE FROM tags WHERE name=?", $name);
    foreach ($tags as $t) {
        db("INSERT INTO tags (name, tag) VALUES (?, ?)", $name, $t);
    }

}







|











|
>













>











>
>
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
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
 * api: cli
 * title: Update `tags` table
 * description: Splits out tags from according column in project `release`.
 * version: 0.4
 * category: postprocessing
 * type: cron
 * x-cron: 10 *\/2 * * *
 *
 * Manually update tags table.
 *   - Splits up comma separated release.tags field
 *   - Maximum of 10 tags each
 *   - Populates separate tags table with name=>tag list.
 *
 * While this could be done in the release::update/::store handler,
 * it's not really urgent to have per-project tags mirrored there.
 * (Externalizing this avoids immediate database load, though not locks;
 * but the transactions cut down on that.)
 *
 * Runs every 2 hours.
 *
 */

chdir(dirname(__DIR__)); 
include("config.php");

/**
 * Scan each project,
 * split up `tags` as CSV and just fille up according tags table.
 *
 */
db("BEGIN IMMEDIATE TRANSACTION");
foreach (db("SELECT name, tags, MAX(t_changed) FROM release_versions GROUP BY name")->fetchAll() as $entry) {

    $name = $entry["name"];
    $tags = array_slice(array_filter(p_csv($entry["tags"])), 0, 10);

    db("DELETE FROM tags WHERE name=?", $name);
    foreach ($tags as $t) {
        db("INSERT INTO tags (name, tag) VALUES (?, ?)", $name, $t);
    }

}
db("END TRANSACTION");