⌈⌋ branch:  freshcode


Check-in [b4a8119636]

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

Overview
Comment:Added transactions as suggested by Lothar.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b4a81196362b4e35c65aec3e90fe7fcea325e17a
User & Date: mario 2014-12-07 21:11:54
Context
2014-12-07
21:12
Block `wagic` (auto-regenerated master release stamps). check-in: 86d391b93b user: mario tags: trunk
21:11
Added transactions as suggested by Lothar. check-in: b4a8119636 user: mario tags: trunk
21:11
No more .trimmed for github-releases sidebar block. check-in: 1285c138f7 user: mario tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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");