Ignore:
Timestamp:
03/27/14 14:44:36 (11 years ago)
Author:
hendrikvanantwerpen
Message:
  • Return to using truly ISO formatted dates, including milliseconds.
  • Also set constraint on surveyrun dates when value is initially set.
  • Separate runs & results from surveys and questions.
  • Moved date & email format to schema itself.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/src/server/config/couchdb-design-docs.js

    r525 r531  
    3030        _id: "schemaInfo",
    3131        version: "4",
    32         viewsVersion: "1"
     32        viewsVersion: "2"
    3333    },
    3434
     
    4949            by_type: {
    5050                map: function(doc){
    51                     emit(doc.type, doc);
    52                 }
     51                    emit(doc.type, 1);
     52                },
     53                reduce: function(keys,values){ return sum(values); }
    5354            },
    5455            typeless: {
     
    104105                    emit(doc.topic||"(default)",1);
    105106                },
    106                 reduce: function(key, values, rereduce) { return sum(values); }
     107                reduce: function(key, values ) { return sum(values); }
    107108            },
    108109            all_variables: {
     
    137138                map: function(doc){
    138139                    if ( doc.type !== 'Question' ) { return; }
    139                     emit(doc.code,doc);
    140                 }
     140                    emit(doc.code,1);
     141                },
     142                reduce: function(key, values) { return sum(values); }
    141143            },
    142144            published_by_code: {
    143145                map: function(doc){
    144                     if ( doc.type !== 'Question' || !doc.publicationDate ) { return; }
    145                     emit(doc.code,doc);
    146                 }
     146                    if ( doc.type !== 'Question' ||
     147                         !doc.publicationDate ) { return; }
     148                    emit(doc.code,1);
     149                },
     150                reduce: function(key, values) { return sum(values); }
    147151            },
    148152            lib: {
     
    159163            drafts: {
    160164                map: function(doc){
    161                     if ( doc.type !== 'Survey' || doc.publicationDate ) { return; }
     165                    if ( doc.type !== 'Survey' ||
     166                         doc.publicationDate ) { return; }
    162167                    emit(doc._id,doc);
    163168                }
     
    165170            published: {
    166171                map: function(doc){
    167                     if ( doc.type !== 'Survey' || !doc.publicationDate ) { return; }
     172                    if ( doc.type !== 'Survey' ||
     173                         !doc.publicationDate ) { return; }
    168174                    emit(doc._id,doc);
    169175                }
     
    176182        language: "javascript",
    177183        views: {
    178             by_dates: {
     184            by_start_date: {
    179185                map: function(doc){
    180186                    if ( doc.type !== 'SurveyRun' ) { return; }
    181                     var startDate = doc.startDate || "";
    182                     var endDate = doc.endDate || {};
    183                     emit([startDate,endDate,doc.liveName||null],doc);
    184                 }
     187                    emit(doc.startDate||null,1);
     188                },
     189                reduce: function(keys,values){ return sum(values); }
     190            },
     191            by_end_date: {
     192                map: function(doc){
     193                    if ( doc.type !== 'SurveyRun' ) { return; }
     194                    emit(doc.endDate||{},1);
     195                },
     196                reduce: function(keys,values){ return sum(values); }
    185197            }
    186198        }
     
    194206                map: function(doc){
    195207                    if ( doc.type !== 'Response' ) { return; }
    196                     emit(doc.surveyRunId, doc);
    197                 }
     208                    emit(doc.surveyRunId, 1);
     209                },
     210                reduce: function(keys,values){ return sum(values); }
    198211            }
    199212        }
Note: See TracChangeset for help on using the changeset viewer.