Commit 56fe0065e0

56fe0065e094d3d75d46c335c10383ca07d87829

parent: af59d12f91

Unsigned

cmc <hello@cleberg.net> · 2023-06-01 02:49 UTC

reduce API result load

Layout: unified · split

index.php +7 −7
@@ -6,7 +6,7 @@ $elements = explode('/', $path);
66
77if (empty($elements[0])) {
88 $html_output = get_stories(
9 'https://hacker-news.firebaseio.com/v0/topstories.json?limitToFirst=30&orderBy="$key"',
9 'https://hacker-news.firebaseio.com/v0/topstories.json?limitToFirst=10&orderBy="$key"',
1010 'Top'
1111 );
1212 echo_html(
@@ -19,7 +19,7 @@ if (empty($elements[0])) {
1919 switch (array_shift($elements)) {
2020 case 'top':
2121 $html_output = get_stories(
22 'https://hacker-news.firebaseio.com/v0/topstories.json?limitToFirst=30&orderBy="$key"',
22 'https://hacker-news.firebaseio.com/v0/topstories.json?limitToFirst=10&orderBy="$key"',
2323 'Top'
2424 );
2525 echo_html(
@@ -32,7 +32,7 @@ if (empty($elements[0])) {
3232
3333 case 'best':
3434 $html_output = get_stories(
35 'https://hacker-news.firebaseio.com/v0/beststories.json?limitToFirst=30&orderBy="$key"',
35 'https://hacker-news.firebaseio.com/v0/beststories.json?limitToFirst=10&orderBy="$key"',
3636 'Best'
3737 );
3838 echo_html(
@@ -45,7 +45,7 @@ if (empty($elements[0])) {
4545
4646 case 'new':
4747 $html_output = get_stories(
48 'https://hacker-news.firebaseio.com/v0/newstories.json?limitToFirst=30&orderBy="$key"',
48 'https://hacker-news.firebaseio.com/v0/newstories.json?limitToFirst=10&orderBy="$key"',
4949 'New'
5050 );
5151 echo_html(
@@ -58,7 +58,7 @@ if (empty($elements[0])) {
5858
5959 case 'ask':
6060 $html_output = get_stories(
61 'https://hacker-news.firebaseio.com/v0/askstories.json?limitToFirst=30&orderBy="$key"',
61 'https://hacker-news.firebaseio.com/v0/askstories.json?limitToFirst=10&orderBy="$key"',
6262 'Ask'
6363 );
6464 echo_html(
@@ -71,7 +71,7 @@ if (empty($elements[0])) {
7171
7272 case 'show':
7373 $html_output = get_stories(
74 'https://hacker-news.firebaseio.com/v0/showstories.json?limitToFirst=30&orderBy="$key"',
74 'https://hacker-news.firebaseio.com/v0/showstories.json?limitToFirst=10&orderBy="$key"',
7575 'Show'
7676 );
7777 echo_html(
@@ -84,7 +84,7 @@ if (empty($elements[0])) {
8484
8585 case 'job':
8686 $html_output = get_stories(
87 'https://hacker-news.firebaseio.com/v0/jobstories.json?limitToFirst=30&orderBy="$key"',
87 'https://hacker-news.firebaseio.com/v0/jobstories.json?limitToFirst=10&orderBy="$key"',
8888 'Job'
8989 );
9090 echo_html(