@@ -652,7 +652,7 @@ def get_growth_rates(experiment: str) -> ResponseReturnValue:
652652 WHERE experiment=? AND timestamp > ?
653653 ), stats AS (
654654 SELECT pioreactor_unit,
655- CASE WHEN ? > 0 THEN MAX(1, CAST(( COUNT(*) + ? - 1) / ? AS INT)) ELSE 1 END AS step
655+ COUNT(*) AS total
656656 FROM filtered
657657 GROUP BY pioreactor_unit
658658 )
@@ -662,11 +662,11 @@ def get_growth_rates(experiment: str) -> ResponseReturnValue:
662662 json_group_array(json_object('x', timestamp, 'y', y)) AS series_data
663663 FROM filtered
664664 JOIN stats USING (pioreactor_unit)
665- WHERE (abs(random()) % step) = 0
665+ WHERE total <= ? OR (abs(random()) % total) < ?
666666 GROUP BY pioreactor_unit
667667 );
668668 """ ,
669- (experiment , cutoff_timestamp , target_points , target_points , target_points ),
669+ (experiment , cutoff_timestamp , target_points , target_points ),
670670 one = True ,
671671 )
672672
@@ -742,7 +742,7 @@ def get_od_readings_filtered(experiment: str) -> ResponseReturnValue:
742742 WHERE experiment=? AND timestamp > ?
743743 ), stats AS (
744744 SELECT pioreactor_unit,
745- CASE WHEN ? > 0 THEN MAX(1, CAST(( COUNT(*) + ? - 1) / ? AS INT)) ELSE 1 END AS step
745+ COUNT(*) AS total
746746 FROM filtered
747747 GROUP BY pioreactor_unit
748748 )
@@ -752,11 +752,11 @@ def get_od_readings_filtered(experiment: str) -> ResponseReturnValue:
752752 json_group_array(json_object('x', timestamp, 'y', y)) AS series_data
753753 FROM filtered
754754 JOIN stats USING (pioreactor_unit)
755- WHERE (abs(random()) % step) = 0
755+ WHERE total <= ? OR (abs(random()) % total) < ?
756756 GROUP BY pioreactor_unit
757757 );
758758 """ ,
759- (experiment , cutoff_timestamp , target_points , target_points , target_points ),
759+ (experiment , cutoff_timestamp , target_points , target_points ),
760760 one = True ,
761761 )
762762
@@ -787,7 +787,7 @@ def get_od_readings(experiment: str) -> ResponseReturnValue:
787787 ), stats AS (
788788 SELECT pioreactor_unit,
789789 channel,
790- CASE WHEN ? > 0 THEN MAX(1, CAST(( COUNT(*) + ? - 1) / ? AS INT)) ELSE 1 END AS step
790+ COUNT(*) AS total
791791 FROM filtered
792792 GROUP BY pioreactor_unit, channel
793793 )
@@ -797,11 +797,11 @@ def get_od_readings(experiment: str) -> ResponseReturnValue:
797797 json_group_array(json_object('x', timestamp, 'y', y)) AS series_data
798798 FROM filtered
799799 JOIN stats USING (pioreactor_unit, channel)
800- WHERE (abs(random()) % step) = 0
800+ WHERE total <= ? OR (abs(random()) % total) < ?
801801 GROUP BY pioreactor_unit, channel
802802 );
803803 """ ,
804- (experiment , cutoff_timestamp , target_points , target_points , target_points ),
804+ (experiment , cutoff_timestamp , target_points , target_points ),
805805 one = True ,
806806 )
807807
@@ -832,7 +832,7 @@ def get_od_raw_readings(experiment: str) -> ResponseReturnValue:
832832 ), stats AS (
833833 SELECT pioreactor_unit,
834834 channel,
835- CASE WHEN ? > 0 THEN MAX(1, CAST(( COUNT(*) + ? - 1) / ? AS INT)) ELSE 1 END AS step
835+ COUNT(*) AS total
836836 FROM filtered
837837 GROUP BY pioreactor_unit, channel
838838 )
@@ -842,11 +842,11 @@ def get_od_raw_readings(experiment: str) -> ResponseReturnValue:
842842 json_group_array(json_object('x', timestamp, 'y', y)) AS series_data
843843 FROM filtered
844844 JOIN stats USING (pioreactor_unit, channel)
845- WHERE (abs(random()) % step) = 0
845+ WHERE total <= ? OR (abs(random()) % total) < ?
846846 GROUP BY pioreactor_unit, channel
847847 );
848848 """ ,
849- (experiment , cutoff_timestamp , target_points , target_points , target_points ),
849+ (experiment , cutoff_timestamp , target_points , target_points ),
850850 one = True ,
851851 )
852852
@@ -927,7 +927,7 @@ def get_growth_rates_per_unit(pioreactor_unit: str, experiment: str) -> Response
927927 WHERE experiment=? AND pioreactor_unit=? AND timestamp > ?
928928 ), stats AS (
929929 SELECT pioreactor_unit,
930- CASE WHEN ? > 0 THEN MAX(1, CAST(( COUNT(*) + ? - 1) / ? AS INT)) ELSE 1 END AS step
930+ COUNT(*) AS total
931931 FROM filtered
932932 GROUP BY pioreactor_unit
933933 )
@@ -937,7 +937,7 @@ def get_growth_rates_per_unit(pioreactor_unit: str, experiment: str) -> Response
937937 json_group_array(json_object('x', timestamp, 'y', y)) AS series_data
938938 FROM filtered
939939 JOIN stats USING (pioreactor_unit)
940- WHERE (abs(random()) % step) = 0
940+ WHERE total <= ? OR (abs(random()) % total) < ?
941941 GROUP BY pioreactor_unit
942942 );
943943 """ ,
@@ -947,7 +947,6 @@ def get_growth_rates_per_unit(pioreactor_unit: str, experiment: str) -> Response
947947 cutoff_timestamp ,
948948 target_points ,
949949 target_points ,
950- target_points ,
951950 ),
952951 one = True ,
953952 )
@@ -1028,7 +1027,7 @@ def get_od_readings_filtered_per_unit(pioreactor_unit: str, experiment: str) ->
10281027 WHERE experiment=? AND pioreactor_unit=? AND timestamp > ?
10291028 ), stats AS (
10301029 SELECT pioreactor_unit,
1031- CASE WHEN ? > 0 THEN MAX(1, CAST(( COUNT(*) + ? - 1) / ? AS INT)) ELSE 1 END AS step
1030+ COUNT(*) AS total
10321031 FROM filtered
10331032 GROUP BY pioreactor_unit
10341033 )
@@ -1038,7 +1037,7 @@ def get_od_readings_filtered_per_unit(pioreactor_unit: str, experiment: str) ->
10381037 json_group_array(json_object('x', timestamp, 'y', y)) AS series_data
10391038 FROM filtered
10401039 JOIN stats USING (pioreactor_unit)
1041- WHERE (abs(random()) % step) = 0
1040+ WHERE total <= ? OR (abs(random()) % total) < ?
10421041 GROUP BY pioreactor_unit
10431042 );
10441043 """ ,
@@ -1048,7 +1047,6 @@ def get_od_readings_filtered_per_unit(pioreactor_unit: str, experiment: str) ->
10481047 cutoff_timestamp ,
10491048 target_points ,
10501049 target_points ,
1051- target_points ,
10521050 ),
10531051 one = True ,
10541052 )
@@ -1079,7 +1077,7 @@ def get_od_readings_per_unit(pioreactor_unit: str, experiment: str) -> ResponseR
10791077 ), stats AS (
10801078 SELECT pioreactor_unit,
10811079 channel,
1082- CASE WHEN ? > 0 THEN MAX(1, CAST(( COUNT(*) + ? - 1) / ? AS INT)) ELSE 1 END AS step
1080+ COUNT(*) AS total
10831081 FROM filtered
10841082 GROUP BY pioreactor_unit, channel
10851083 )
@@ -1089,11 +1087,11 @@ def get_od_readings_per_unit(pioreactor_unit: str, experiment: str) -> ResponseR
10891087 json_group_array(json_object('x', timestamp, 'y', y)) AS series_data
10901088 FROM filtered
10911089 JOIN stats USING (pioreactor_unit, channel)
1092- WHERE (abs(random()) % step) = 0
1090+ WHERE total <= ? OR (abs(random()) % total) < ?
10931091 GROUP BY pioreactor_unit, channel
10941092 );
10951093 """ ,
1096- (experiment , pioreactor_unit , cutoff_timestamp , target_points , target_points , target_points ),
1094+ (experiment , pioreactor_unit , cutoff_timestamp , target_points , target_points ),
10971095 one = True ,
10981096 )
10991097
@@ -1126,7 +1124,7 @@ def get_od_raw_readings_per_unit(pioreactor_unit: str, experiment: str) -> Respo
11261124 ), stats AS (
11271125 SELECT pioreactor_unit,
11281126 channel,
1129- CASE WHEN ? > 0 THEN MAX(1, CAST(( COUNT(*) + ? - 1) / ? AS INT)) ELSE 1 END AS step
1127+ COUNT(*) AS total
11301128 FROM filtered
11311129 GROUP BY pioreactor_unit, channel
11321130 )
@@ -1136,11 +1134,11 @@ def get_od_raw_readings_per_unit(pioreactor_unit: str, experiment: str) -> Respo
11361134 json_group_array(json_object('x', timestamp, 'y', y)) AS series_data
11371135 FROM filtered
11381136 JOIN stats USING (pioreactor_unit, channel)
1139- WHERE (abs(random()) % step) = 0
1137+ WHERE total <= ? OR (abs(random()) % total) < ?
11401138 GROUP BY pioreactor_unit, channel
11411139 );
11421140 """ ,
1143- (experiment , pioreactor_unit , cutoff_timestamp , target_points , target_points , target_points ),
1141+ (experiment , pioreactor_unit , cutoff_timestamp , target_points , target_points ),
11441142 one = True ,
11451143 )
11461144
0 commit comments