MCPcopy Create free account
hub / github.com/douglance/devsql / prompts

Function prompts

crates/ccql/src/cli/commands.rs:14–101  ·  view source on GitHub ↗
(
    config: &Config,
    session: Option<String>,
    project: Option<String>,
    since: Option<String>,
    until: Option<String>,
    limit: Option<usize>,
    format: OutputFormat,
)

Source from the content-addressed store, hash-verified

12use comfy_table::Cell;
13
14pub async fn prompts(
15 config: &Config,
16 session: Option<String>,
17 project: Option<String>,
18 since: Option<String>,
19 until: Option<String>,
20 limit: Option<usize>,
21 format: OutputFormat,
22) -> Result<()> {
23 let history = HistoryDataSource::new(config.clone());
24 let mut entries = history.filter_prompts().await?;
25
26 if let Some(ref proj) = project {
27 entries.retain(|e| {
28 e.project
29 .as_ref()
30 .map(|p| p.contains(proj))
31 .unwrap_or(false)
32 });
33 }
34
35 if let Some(ref sess) = session {
36 entries.retain(|e| {
37 e.session_id
38 .as_ref()
39 .map(|s| s.contains(sess))
40 .unwrap_or(false)
41 });
42 }
43
44 if let Some(ref since_str) = since {
45 if let Ok(since_date) = chrono::NaiveDate::parse_from_str(since_str, "%Y-%m-%d") {
46 let since_ts = since_date
47 .and_hms_opt(0, 0, 0)
48 .unwrap()
49 .and_utc()
50 .timestamp_millis();
51 entries.retain(|e| e.timestamp >= since_ts);
52 }
53 }
54
55 if let Some(ref until_str) = until {
56 if let Ok(until_date) = chrono::NaiveDate::parse_from_str(until_str, "%Y-%m-%d") {
57 let until_ts = until_date
58 .and_hms_opt(23, 59, 59)
59 .unwrap()
60 .and_utc()
61 .timestamp_millis();
62 entries.retain(|e| e.timestamp <= until_ts);
63 }
64 }
65
66 entries.sort_by_key(|e| std::cmp::Reverse(e.timestamp));
67
68 if let Some(limit) = limit {
69 entries.truncate(limit);
70 }
71

Callers 1

mainFunction · 0.85

Calls 5

create_tableFunction · 0.85
filter_promptsMethod · 0.80
write_jsonMethod · 0.80
write_tableMethod · 0.80
writelnMethod · 0.80

Tested by

no test coverage detected