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);
6 6
7if (empty($elements[0])) { 7if (empty($elements[0])) {
8 $html_output = get_stories( 8 $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"',
10 'Top' 10 'Top'
11 ); 11 );
12 echo_html( 12 echo_html(
@@ -19,7 +19,7 @@ if (empty($elements[0])) {
19 switch (array_shift($elements)) { 19 switch (array_shift($elements)) {
20 case 'top': 20 case 'top':
21 $html_output = get_stories( 21 $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"',
23 'Top' 23 'Top'
24 ); 24 );
25 echo_html( 25 echo_html(
@@ -32,7 +32,7 @@ if (empty($elements[0])) {
32 32
33 case 'best': 33 case 'best':
34 $html_output = get_stories( 34 $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"',
36 'Best' 36 'Best'
37 ); 37 );
38 echo_html( 38 echo_html(
@@ -45,7 +45,7 @@ if (empty($elements[0])) {
45 45
46 case 'new': 46 case 'new':
47 $html_output = get_stories( 47 $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"',
49 'New' 49 'New'
50 ); 50 );
51 echo_html( 51 echo_html(
@@ -58,7 +58,7 @@ if (empty($elements[0])) {
58 58
59 case 'ask': 59 case 'ask':
60 $html_output = get_stories( 60 $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"',
62 'Ask' 62 'Ask'
63 ); 63 );
64 echo_html( 64 echo_html(
@@ -71,7 +71,7 @@ if (empty($elements[0])) {
71 71
72 case 'show': 72 case 'show':
73 $html_output = get_stories( 73 $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"',
75 'Show' 75 'Show'
76 ); 76 );
77 echo_html( 77 echo_html(
@@ -84,7 +84,7 @@ if (empty($elements[0])) {
84 84
85 case 'job': 85 case 'job':
86 $html_output = get_stories( 86 $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"',
88 'Job' 88 'Job'
89 ); 89 );
90 echo_html( 90 echo_html(