update api overview

This commit is contained in:
Drake Marino 2024-06-13 16:51:36 -05:00
parent a7f8ff495d
commit 1c229e236f
2 changed files with 11 additions and 4 deletions

View File

@ -158,7 +158,7 @@ void main() async {
JobType.values.asNameMap().keys; JobType.values.asNameMap().keys;
// List<Map<String, List<Map<String, dynamic>>>> this is the real type lol // List<Map<String, List<Map<String, dynamic>>>> this is the real type lol
List<dynamic> output = []; Map<String, dynamic> output = {};
for (int i = 0; i < filters.length; i++) { for (int i = 0; i < filters.length; i++) {
var postgresResult = (await postgres.query(''' var postgresResult = (await postgres.query('''
@ -176,7 +176,7 @@ void main() async {
'''))[0][0]; '''))[0][0];
if (postgresResult != null) { if (postgresResult != null) {
output.add({filters.elementAt(i): postgresResult}); output.addAll({filters.elementAt(i): postgresResult});
} }
} }

View File

@ -38,13 +38,20 @@ Future fetchBusinessDataOverview() async {
var decodedResponse = json.decode(response.body); var decodedResponse = json.decode(response.body);
Map<JobType, List<Business>> groupedBusinesses = {}; Map<JobType, List<Business>> groupedBusinesses = {};
for (int i = 0; i < decodedResponse.length; i++) { for (String stringType in decodedResponse.keys) {
groupedBusinesses.addAll({ groupedBusinesses.addAll({
JobType.values.byName(decodedResponse[i]): JobType.values.byName(decodedResponse[stringType]):
decodedResponse.map((json) => Business.fromJson(json)).toList() decodedResponse.map((json) => Business.fromJson(json)).toList()
}); });
} }
// for (JobType type in decodedResponse.keys) {
// groupedBusinesses.addAll({
// JobType.values.byName(decodedResponse[i]):
// decodedResponse.map((json) => Business.fromJson(json)).toList()
// });
// }
print(groupedBusinesses);
return groupedBusinesses; return groupedBusinesses;
} else { } else {
return 'Error ${response.statusCode}! Please try again later!'; return 'Error ${response.statusCode}! Please try again later!';