Changes between Version 4 and Version 5 of Data Storage
- Timestamp:
- Sep 23, 2005, 3:48:55 PM (19 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Data Storage
v4 v5 16 16 * Total lines of code in the unit 17 17 * Percentage of lines executed 18 * Number of times every lin was executed18 * Number of times every line was executed 19 19 20 Other data such as compilation errors/warnings or style checks would consist of the message of the error or warning.20 Other data such as style check results would in turn consist of other properties. 21 21 22 22 == Database Schema == … … 28 28 [[Image(tables.png)]] 29 29 30 There is one `bitten_report` record per report. This record associates the report with a step of a specific build (see ObjectModel), and stores the ''category'' and the ''generator'' of the report. The category can be seen as indicator of the schema with which the report data complies. For example, there's a category "test" for test results, and a category "coverage" for code coverage. Test results data may be generated by different recipe commands and tools, but as long as they comply with the schema of the "test" category, the data can be analyzed and visualized by the same generic components.30 There is one `bitten_report` record per report. This record associates the report with a step of a specific build (see ObjectModel), and stores the ''category'' and the ''generator'' of the report. 31 31 32 The report data itself is stored in the `bitten_report_item` table. The basic assumption is that a report consists of a flat, unordered list of data points, each having a variable set of named properties. The names and values of these properties are storeds in the `name` and `value` columns of the `bitten_report_item` table, respectively. The `item` column simply contains a number that groups the individual properties into "report items". 32 ''The category can be seen as indicator of the schema with which the report data complies. For example, there's a category “test” for test results, and a category “coverage” for code coverage. Test results data may be generated by different recipe commands and tools, but as long as they comply with the schema of a known category, the data can be analyzed and visualized by the same generic components.'' 33 34 The report data itself is stored in the `bitten_report_item` table. The basic assumption is that a report consists of a flat, unordered list of data points, each having a variable set of named properties. The names and values of these properties are storeds in the `name` and `value` columns of the `bitten_report_item` table, respectively. The `item` column simply contains an artificial key that groups the individual properties into "report items". 33 35 34 36 == Mapping XML Reports to Database Tables == … … 48 50 }}} 49 51 50 For such a report, Bitten first inserts a record into the `bitten_report` table, taking the category and generator from the corresponding attributes of the `<report>` element. Next, a couple of records are inserted into the `bitten_report_item` table for every immediatechild element of `<report>`; one for every attribute of the child element. In addition, the tag name is stored as a property named `type`.52 For such a report, Bitten first inserts a record into the `bitten_report` table, taking the category and generator from the corresponding attributes of the `<report>` element. Next, a couple of records are inserted into the `bitten_report_item` table for every child element of `<report>`; one for every attribute of the child element. In addition, the tag name is stored as a property named `type`. 51 53 52 Children of the child element are also mapped to properties: here the tag name of the "grandchild"is used as the property name, and its´ body text is used as the property value.54 To allow for the transmission of data that cannot be easily encoded into XML attribute values, children of the child element itself are also mapped to properties: the tag name of the “grandchild” is used as the property name, and its´ body text is used as the property value. 53 55 54 Sothe following snippets would be stored in exactly the same way:56 For example, the following snippets would be stored in exactly the same way: 55 57 56 58 {{{ … … 73 75 }}} 74 76 75 These two methods can be mixed. When multiple child elements with the same tag name are encountered, only the last one is stored.77 These two methods can be mixed. When multiple properties with the same name are encountered, only the last one is stored. Child elements take precedence over attributes. 76 78 77 The tables will contain the following data for this report:79 For the example above, the database tables should contain the following data: 78 80 79 81 '''`bitten_report`''': … … 83 85 '''`bitten_report_item`''': 84 86 || report || item || name || value || 85 || 123 || 1|| `type` || `test` ||86 || 123 || 1|| `duration` || `0.073` ||87 || 123 || 1|| `status` || `success` ||88 || 123 || 1|| `fixture` || `bitten.tests.model.BuildConfigTestCase` ||89 || 123 || 1|| `name` || `test_config_update_name` ||90 || 123 || 1|| `file` || `bitten/tests/model.py` ||91 || 123 || 1|| `stdout` || `Renaming build configuration` ||87 || 123 || bar || `type` || `test` || 88 || 123 || bar || `duration` || `0.073` || 89 || 123 || bar || `status` || `success` || 90 || 123 || bar || `fixture` || `bitten.tests.model.BuildConfigTestCase` || 91 || 123 || bar || `name` || `test_config_update_name` || 92 || 123 || bar || `file` || `bitten/tests/model.py` || 93 || 123 || bar || `stdout` || `Renaming build configuration` || 92 94 93 95 == Querying the Report Store == 94 96 95 Querying the report data is not straight-forward due to the generic nature of the tables. This usually re quires a number of self-joins.97 Querying the report data is not straight-forward due to the generic nature of the tables. This usually results in a number of “self-joins” in the SQL `SELECT` statement. 96 98 97 99 For example, the following query aggregates the number of failed/succeeded unit tests by fixture: … … 122 124 }}} 123 125 124 ''(This code is from the [source://trunk/bitten/trac_ext/summarizers.py TestResultsSummarizer] .)''126 ''(This code is from the [source://trunk/bitten/trac_ext/summarizers.py TestResultsSummarizer] component in Bitten.)''