File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -113,18 +113,19 @@ pub async fn create_dataset(
113113
114114 let organization_sub_plan = get_org_from_id_query ( org_id, pool. clone ( ) ) . await ?;
115115
116- let dataset_count = get_org_dataset_count ( org_id, pool. clone ( ) ) . await ?;
117-
118116 let unlimited = std:: env:: var ( "UNLIMITED" ) . unwrap_or ( "false" . to_string ( ) ) ;
119- if unlimited == "false"
120- && dataset_count
117+ if unlimited == "false" {
118+ let dataset_count = get_org_dataset_count ( org_id, pool. clone ( ) ) . await ?;
119+ if dataset_count
121120 >= organization_sub_plan
122121 . plan
123122 . unwrap_or ( StripePlan :: default ( ) )
124123 . dataset_count
125- {
126- return Ok ( HttpResponse :: UpgradeRequired ( )
127- . json ( json ! ( { "message" : "Your plan must be upgraded to create additional datasets" } ) ) ) ;
124+ {
125+ return Ok ( HttpResponse :: UpgradeRequired ( ) . json (
126+ json ! ( { "message" : "Your plan must be upgraded to create additional datasets" } ) ,
127+ ) ) ;
128+ }
128129 }
129130
130131 let dataset = Dataset :: from_details (
@@ -138,6 +139,7 @@ pub async fn create_dataset(
138139 ) ;
139140
140141 let d = create_dataset_query ( dataset, pool) . await ?;
142+
141143 Ok ( HttpResponse :: Ok ( ) . json ( d) )
142144}
143145
Original file line number Diff line number Diff line change @@ -331,7 +331,14 @@ pub async fn get_org_dataset_count(
331331 . select ( organization_usage_counts_columns:: dataset_count)
332332 . first ( & mut conn)
333333 . await
334- . map_err ( |_| ServiceError :: BadRequest ( "Error loading org dataset count" . to_string ( ) ) ) ?;
334+ . map_err ( |e| {
335+ log:: error!(
336+ "Error loading org dataset count in get_org_dataset_count: {:?}" ,
337+ e
338+ ) ;
339+
340+ ServiceError :: BadRequest ( "Error loading org dataset count" . to_string ( ) )
341+ } ) ?;
335342
336343 Ok ( dataset_count)
337344}
You can’t perform that action at this time.
0 commit comments