[recent datasets][xs]: only need first 3 datasets.

This commit is contained in:
anuveyatsu
2020-06-24 13:02:33 +06:00
parent 19f1d4b408
commit 5e62325c91
3 changed files with 9 additions and 5 deletions

View File

@@ -4,8 +4,8 @@ import { useQuery } from '@apollo/react-hooks';
import gql from 'graphql-tag'; import gql from 'graphql-tag';
export const QUERY = gql` export const QUERY = gql`
query search($q: String, $sort: String) { query search($q: String, $sort: String, $rows: Int) {
search(q: $q, sort: $sort) search(q: $q, sort: $sort, rows: $rows)
@rest(type: "Search", path: "package_search?{args}") { @rest(type: "Search", path: "package_search?{args}") {
result { result {
results { results {
@@ -24,7 +24,10 @@ export const QUERY = gql`
function Recent() { function Recent() {
const { loading, error, data } = useQuery(QUERY, { const { loading, error, data } = useQuery(QUERY, {
variables: { sort: 'metadata_created desc' }, variables: {
sort: 'metadata_created desc',
rows: 3,
},
// Setting this value to true will make the component rerender when // Setting this value to true will make the component rerender when
// the "networkStatus" changes, so we are able to know if it is fetching // the "networkStatus" changes, so we are able to know if it is fetching
// more data // more data

View File

@@ -91,7 +91,7 @@ module.exports.initMocks = function () {
}, },
}) })
// 3. Call for recent packages. // 3. Call for recent packages.
.get('/package_search?sort=metadata_created%20desc') .get('/package_search?sort=metadata_created%20desc&rows=3')
.reply(200, { .reply(200, {
success: true, success: true,
result: { result: {

View File

@@ -5,7 +5,7 @@ import Nav from '../components/home/Nav';
import Recent, { QUERY } from '../components/home/Recent'; import Recent, { QUERY } from '../components/home/Recent';
import Form from '../components/search/Form'; import Form from '../components/search/Form';
function Home({ datapackages }) { function Home() {
return ( return (
<div className="container mx-auto"> <div className="container mx-auto">
<Head> <Head>
@@ -42,6 +42,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
query: QUERY, query: QUERY,
variables: { variables: {
sort: 'metadata_created desc', sort: 'metadata_created desc',
rows: 3,
}, },
}); });