Check-in [1064dfac12]
Not logged in

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

Overview
Comment:Expanded "search" command flags: (-limit|-n #) limits the number of results and (-all|-a) disables the "lopping off" of the bottom fraction of the results.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:1064dfac1221b19d1c0e29a1ad3615f7c75e153a
User & Date: stephan 2013-07-21 16:38:57
Context
2013-07-22
08:55
Better outlining of output from "fossil status", "fossil changes" and "fossil ls --verbose". Let "fossil ls --verbose" differentiate between EDITED, CONFLICT, UPD_BY_MERGE and ADD_BY_MERGE, just like "fossil status" and "fossil changes" check-in: c41d70dccd user: jan.nijtmans tags: trunk
2013-07-21
16:38
Expanded "search" command flags: (-limit|-n #) limits the number of results and (-all|-a) disables the "lopping off" of the bottom fraction of the results. check-in: 1064dfac12 user: stephan tags: trunk
2013-07-20
17:04
Re-added the 'Total Events' label to /stats_report, but did it outside the table so that the JS sorting does not hose it. Replaced a double calculation with an equivalent int one. check-in: 8adf0db1c8 user: stephan tags: trunk
Changes

Changes to src/search.c.

164
165
166
167
168
169
170
171
172
173








174
175
176
177
178

179
180






181
182
183
184
185
186
187
...
196
197
198
199
200
201
202
203
204




205
206
207





208
209
210
     search_score_sqlfunc, 0, 0);
}

/*
** Testing the search function.
**
** COMMAND: search*
** %fossil search pattern...
**
** Search for timeline entries matching the pattern.








*/
void search_cmd(void){
  Search *p;
  Blob pattern;
  int i;

  Stmt q;
  int iBest;







  db_must_be_within_tree();
  if( g.argc<2 ) return;
  blob_init(&pattern, g.argv[2], -1);
  for(i=3; i<g.argc; i++){
    blob_appendf(&pattern, " %s", g.argv[i]);
  }
................................................................................
     "   SELECT blob.rid, uuid, datetime(event.mtime, 'localtime'),"
     "          coalesce(ecomment,comment),"
     "          score(coalesce(ecomment,comment)) AS y"
     "     FROM event, blob"
     "    WHERE blob.rid=event.objid AND y>0;"
  );
  iBest = db_int(0, "SELECT max(x) FROM srch");
  db_prepare(&q, 
    "SELECT rid, uuid, date, comment, 0, 0 FROM srch"




    " WHERE x>%d ORDER BY x DESC, date DESC",
    iBest/3
  );





  print_timeline(&q, 1000, 0);
  db_finalize(&q);
}







|

|
>
>
>
>
>
>
>
>





>


>
>
>
>
>
>







 







|
|
>
>
>
>
|
<
<
>
>
>
>
>



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
...
211
212
213
214
215
216
217
218
219
220
221
222
223
224


225
226
227
228
229
230
231
232
     search_score_sqlfunc, 0, 0);
}

/*
** Testing the search function.
**
** COMMAND: search*
** %fossil search [-all|-a] [-limit|-n #] pattern...
**
** Search for timeline entries matching all words
** provided on the command line. Whole-word matches
** scope more highly than partial matches.
**
** Outputs, by default, some top-N fraction of the
** results. The -all option can be used to output
** all matches, regardless of their search score.
** -limit can be used to limit the number of entries
** returned.
*/
void search_cmd(void){
  Search *p;
  Blob pattern;
  int i;
  Blob sql = empty_blob;
  Stmt q;
  int iBest;
  char fAll = NULL != find_option("all", "a", 0); /* If set, do not lop
                                                     off the end of the
                                                     results. */
  char const * zLimit = find_option("limit","n",1);
  int const nLimit = zLimit ? atoi(zLimit) : -1; /* Max number of entries
                                                    to list */

  db_must_be_within_tree();
  if( g.argc<2 ) return;
  blob_init(&pattern, g.argv[2], -1);
  for(i=3; i<g.argc; i++){
    blob_appendf(&pattern, " %s", g.argv[i]);
  }
................................................................................
     "   SELECT blob.rid, uuid, datetime(event.mtime, 'localtime'),"
     "          coalesce(ecomment,comment),"
     "          score(coalesce(ecomment,comment)) AS y"
     "     FROM event, blob"
     "    WHERE blob.rid=event.objid AND y>0;"
  );
  iBest = db_int(0, "SELECT max(x) FROM srch");
  blob_append(&sql,
              "SELECT rid, uuid, date, comment, 0, 0 FROM srch "
              "WHERE 1 ", -1);
  if(!fAll){
    blob_appendf(&sql,"AND x>%d ", iBest/3);
  }
  blob_append(&sql, "ORDER BY x DESC, date DESC ", -1);


  if(nLimit>0){
    blob_appendf(&sql, "LIMIT %d", nLimit);
  }
  db_prepare(&q, blob_str(&sql));
  blob_reset(&sql);
  print_timeline(&q, 1000, 0);
  db_finalize(&q);
}