increase page size
parent
65ab5819ac
commit
a75753d0c5
|
@ -11,7 +11,7 @@ import ErrorPage from 'next/error'
|
|||
import PaginationItem from '@mui/material/PaginationItem'
|
||||
import PhotoInterface from '../../types/photo'
|
||||
|
||||
|
||||
const IMAGES_ON_PAGE = 100
|
||||
const useStyles = makeStyles()(() => ({
|
||||
flex_center: {
|
||||
display: "flex",
|
||||
|
@ -65,13 +65,12 @@ export default function LastAddedPage(props: LastAddedPageProps) {
|
|||
}
|
||||
|
||||
export const getStaticProps: GetStaticProps = async (context) => {
|
||||
const images_on_page = 30
|
||||
const photos = []
|
||||
if (typeof context.params?.page === "string") {
|
||||
const page = parseInt(context.params.page)
|
||||
const total_num_of_images = await db_ops.image_ops.get_number_of_images_returned_by_search_query({})
|
||||
if (page >= 1 && page <= Math.ceil(total_num_of_images / images_on_page)) {
|
||||
const images = await db_ops.image_ops.batch_find_images({}, images_on_page * (page - 1), images_on_page)
|
||||
if (page >= 1 && page <= Math.ceil(total_num_of_images / IMAGES_ON_PAGE)) {
|
||||
const images = await db_ops.image_ops.batch_find_images({}, IMAGES_ON_PAGE * (page - 1), IMAGES_ON_PAGE)
|
||||
for (const image of images) {
|
||||
photos.push({
|
||||
src: `/thumbnails/${image.id}.jpg`,
|
||||
|
@ -86,7 +85,7 @@ export const getStaticProps: GetStaticProps = async (context) => {
|
|||
props: {
|
||||
photos: photos,
|
||||
current_page: page,
|
||||
max_page: Math.ceil(total_num_of_images / images_on_page)
|
||||
max_page: Math.ceil(total_num_of_images / IMAGES_ON_PAGE)
|
||||
},
|
||||
revalidate: 1 * 60 //1 min
|
||||
}
|
||||
|
@ -100,9 +99,8 @@ export const getStaticProps: GetStaticProps = async (context) => {
|
|||
|
||||
export const getStaticPaths: GetStaticPaths = async () => {
|
||||
const total_num_of_images = await db_ops.image_ops.get_number_of_images_returned_by_search_query({})
|
||||
const images_on_page = 30
|
||||
const paths = []
|
||||
for (let i = 1; i <= Math.ceil(total_num_of_images / images_on_page); i++) {
|
||||
for (let i = 1; i <= Math.ceil(total_num_of_images / IMAGES_ON_PAGE); i++) {
|
||||
paths.push({ params: { page: i.toString() } })
|
||||
}
|
||||
return {
|
||||
|
|
|
@ -20,7 +20,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
|
|||
const photos = []
|
||||
if (typeof context.params?.id === "string") {
|
||||
const image_id = context.params.id
|
||||
const x = await db_ops.image_ops.get_images_with_similar_tags(parseInt(image_id), 30)
|
||||
const x = await db_ops.image_ops.get_images_with_similar_tags(parseInt(image_id), 100)
|
||||
const similar_images = x.map((el) => {
|
||||
return {
|
||||
id: el["_id"].id,
|
||||
|
|
|
@ -81,7 +81,7 @@ async function reverse_search(image: Buffer,find_duplicate = false) {
|
|||
|
||||
async function image_text_features_get_similar_images_by_id(image_id: number) {
|
||||
try {
|
||||
const res = await axios.post(`${config.ambience_microservice_url}/image_text_features_get_similar_images_by_id`, { image_id: image_id,k:20 })
|
||||
const res = await axios.post(`${config.ambience_microservice_url}/image_text_features_get_similar_images_by_id`, { image_id: image_id,k:100 })
|
||||
return res.data.map((el:any)=>el["image_id"])
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
|
@ -90,7 +90,7 @@ async function image_text_features_get_similar_images_by_id(image_id: number) {
|
|||
|
||||
async function image_text_features_get_similar_images_by_text(query: string) {
|
||||
try {
|
||||
const res = await axios.post(`${config.ambience_microservice_url}/image_text_features_get_similar_images_by_text`, { text: query,k:20 })
|
||||
const res = await axios.post(`${config.ambience_microservice_url}/image_text_features_get_similar_images_by_text`, { text: query, k:100 })
|
||||
return res.data.map((el:any)=>el["image_id"])
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
|
@ -99,7 +99,7 @@ async function image_text_features_get_similar_images_by_text(query: string) {
|
|||
|
||||
async function color_get_similar_images_by_id(image_id: number) {
|
||||
try {
|
||||
const res = await axios.post(`${config.ambience_microservice_url}/color_get_similar_images_by_id`, { image_id: image_id,k:20 })
|
||||
const res = await axios.post(`${config.ambience_microservice_url}/color_get_similar_images_by_id`, { image_id: image_id, k:100 })
|
||||
return res.data.map((el:any)=>el["image_id"])
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
|
@ -215,8 +215,8 @@ async function import_image(image_buffer: Buffer, tags: string[] = [], source_ur
|
|||
}
|
||||
if (!bypass_checks && !tags.includes("bypass_dup_check")) {
|
||||
const res = await reverse_search(image_buffer,true)
|
||||
if (res["local_features_res"] !== undefined) {
|
||||
return `Similar image is already in the db. Image ids = ${JSON.stringify(res["local_features_res"])} `
|
||||
if (res["duplicate"] !== undefined) {
|
||||
return `Similar image is already in the db. Image ids = ${JSON.stringify(res["duplicate"])} `
|
||||
}
|
||||
}
|
||||
const mime_type = (await fromBuffer(image_buffer))?.mime
|
||||
|
|
Loading…
Reference in New Issue