added correct sorting of quotes in the list; set up a testing environment

This commit is contained in:
odweta
2026-04-02 19:58:41 +02:00
parent c9d39a7193
commit 51ce826de6
3 changed files with 11 additions and 5 deletions
+2
View File
@@ -3,6 +3,7 @@ package main
import ( import (
"net/http" "net/http"
"os" "os"
"fmt"
"github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5"
) )
@@ -25,5 +26,6 @@ func main() {
port = "8080" port = "8080"
} }
fmt.Println("started and listening on localhost:" + port)
http.ListenAndServe(":"+port, r) http.ListenAndServe(":"+port, r)
} }
+6 -1
View File
@@ -18,7 +18,7 @@ class QuoteProvider extends ChangeNotifier {
List<Quote> get filteredQuotes { List<Quote> get filteredQuotes {
final query = filterController.text.toLowerCase(); final query = filterController.text.toLowerCase();
return _quotes.where((quote) { final filtered = _quotes.where((quote) {
switch (filterBy) { switch (filterBy) {
case 0: case 0:
return quote.author.toLowerCase().contains(query); return quote.author.toLowerCase().contains(query);
@@ -28,6 +28,11 @@ class QuoteProvider extends ChangeNotifier {
return true; return true;
} }
}).toList(); }).toList();
// sort descending
filtered.sort((a, b) => b.id.compareTo(a.id));
return filtered;
} }
final QuoteRepository repo = QuoteRepository(); final QuoteRepository repo = QuoteRepository();
@@ -1,13 +1,12 @@
// talks to the DB itself
// TODO: implement the real one
import 'dart:convert'; import 'dart:convert';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:frontend/model/quote.dart'; import 'package:frontend/model/quote.dart';
class QuoteRepository { class QuoteRepository {
static final String _apiBaseUrl = 'https://hlaskovnik-reimagined-latest.onrender.com'; //static final String _realApiBaseUrl = 'https://hlaskovnik-reimagined-latest.onrender.com';
static final String _testApiBaseUrl = 'http://localhost:8080';
static final String _apiBaseUrl = _testApiBaseUrl;
static final String _apiKey = "2ogD5kc4sw3JVZoouQSV0w3LGRjSj5IjVFnAnk7IRCIK0ktONCeoOYinbNLSIHuU"; static final String _apiKey = "2ogD5kc4sw3JVZoouQSV0w3LGRjSj5IjVFnAnk7IRCIK0ktONCeoOYinbNLSIHuU";
static final String _quotesEndpoint = '/quotes'; static final String _quotesEndpoint = '/quotes';