Skip to content

Commit 1eb5d8e

Browse files
committed
Add wrapper for get_report
1 parent d5545bd commit 1eb5d8e

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

src/command/area.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,6 @@ pub fn set_area_icon(args: &SetAreaIconArgs) -> Result<()> {
6363
.print()
6464
}
6565

66-
#[derive(Args)]
67-
pub struct GenerateAreasElementsMappingArgs {
68-
pub from_element_id: i64,
69-
pub to_element_id: i64,
70-
}
71-
72-
pub fn generate_areas_elements_mapping(args: &GenerateAreasElementsMappingArgs) -> Result<()> {
73-
rpc::call(
74-
"generate_areas_elements_mapping",
75-
json!({"from_element_id": args.from_element_id,"to_element_id": args.to_element_id}),
76-
)?
77-
.print()
66+
pub fn generate_areas_elements_mapping() -> Result<()> {
67+
rpc::call("generate_areas_elements_mapping", json!({}))?.print()
7868
}

src/command/common.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ pub fn search(args: &SearchArgs) -> Result<()> {
1111
rpc::call("search", json!({"query": args.query}))?.print()
1212
}
1313

14+
#[derive(Args)]
15+
pub struct GetReportArgs {
16+
#[arg(long)]
17+
pub start: String,
18+
#[arg(long)]
19+
pub end: String,
20+
}
21+
22+
pub fn get_report(args: &GetReportArgs) -> Result<()> {
23+
rpc::call("get_report", json!({"start": args.start, "end": args.end}))?.print()
24+
}
25+
1426
#[derive(Args)]
1527
pub struct CustomArgs {
1628
pub method: String,

src/command/event.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ use serde_json::{json, Map, Value};
88
#[derive(Args)]
99
pub struct CreateEventArgs {
1010
#[clap(allow_hyphen_values = true)]
11+
#[arg(long)]
1112
pub lat: f64,
1213
#[clap(allow_hyphen_values = true)]
14+
#[arg(long)]
1315
pub lon: f64,
16+
#[arg(long)]
1417
pub name: String,
18+
#[arg(long)]
1519
pub website: String,
20+
#[arg(long = "starts-at")]
1621
pub starts_at: String,
22+
#[arg(long = "ends-at")]
1723
pub ends_at: Option<String>,
1824
}
1925

src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ enum Commands {
8787
/// Set icon to a certain area. You can use either numeric id or a string alias (th). Icon needs to be base64-encoded, and you also need to provide file extension
8888
SetAreaIcon(command::area::SetAreaIconArgs),
8989
/// Ensure that elements and areas are correctly mapped to each other. You need to provide element id range in order to operate on a specific slice of elements
90-
GenerateAreasElementsMapping(command::area::GenerateAreasElementsMappingArgs),
90+
GenerateAreasElementsMapping,
9191
/// Fetch the latest user actions. You need to provide OSM username and the number of latest entries you are interested in
9292
GetUserActivity(command::user::GetUserActivityArgs),
9393
/// Generate daily reports. It will skip report generation if current date is already covered
@@ -106,6 +106,9 @@ enum Commands {
106106
GetEvents,
107107
GetEvent(command::event::GetEventArgs),
108108
DeleteEvent(command::event::DeleteEventArgs),
109+
110+
/// Generate montly activity report. We use it as a data source in our monthly reports
111+
GetReport(command::common::GetReportArgs),
109112
}
110113

111114
type Result<T> = std::result::Result<T, Box<dyn Error>>;
@@ -187,7 +190,7 @@ fn main() -> Result<()> {
187190
Commands::SetAreaTag(args) => area::set_area_tag(args),
188191
Commands::RemoveAreaTag(args) => area::remove_area_tag(args),
189192
Commands::SetAreaIcon(args) => area::set_area_icon(args),
190-
Commands::GenerateAreasElementsMapping(args) => area::generate_areas_elements_mapping(args),
193+
Commands::GenerateAreasElementsMapping => area::generate_areas_elements_mapping(),
191194
// User
192195
Commands::GetUserActivity(args) => command::user::get_user_activity(args),
193196
// Report
@@ -203,6 +206,7 @@ fn main() -> Result<()> {
203206
Commands::GetEvents => command::event::get_events(),
204207
Commands::GetEvent(args) => command::event::get_event(args),
205208
Commands::DeleteEvent(args) => command::event::delete_event(args),
209+
Commands::GetReport(args) => command::common::get_report(args),
206210
}
207211
}
208212

0 commit comments

Comments
 (0)