enzostvs HF staff commited on
Commit
266b7fc
β€’
1 Parent(s): 7ddbc0b

fix scrapping

Browse files
src/lib/components/models/Card.svelte CHANGED
@@ -59,7 +59,7 @@
59
  {/if}
60
  </div>
61
  <div class="flex items-center justify-between w-full gap-4 py-1">
62
- <p class="text-white font-semibold text-base mb-1 break-all">{card?.id}</p>
63
  <div class="flex items-center justify-end gap-3">
64
  <div class="text-white text-sm flex items-center justify-end gap-1.5">
65
  <Icon icon="solar:heart-bold" class="w-5 h-5 text-red-500" />
 
59
  {/if}
60
  </div>
61
  <div class="flex items-center justify-between w-full gap-4 py-1">
62
+ <p class="text-white font-semibold text-base mb-1 break-all truncate">{card?.id}</p>
63
  <div class="flex items-center justify-end gap-3">
64
  <div class="text-white text-sm flex items-center justify-end gap-1.5">
65
  <Icon icon="solar:heart-bold" class="w-5 h-5 text-red-500" />
src/routes/api/scrap-models/+server.ts CHANGED
@@ -1,7 +1,7 @@
1
  /** @type {import('./$types').RequestHandler} */
2
 
3
  import { json } from '@sveltejs/kit';
4
- import moment from 'moment';
5
  import prisma from '$lib/prisma';
6
 
7
  export async function POST({ request }) {
@@ -19,14 +19,13 @@ export async function POST({ request }) {
19
  let index = 0;
20
  let model_saved = 0;
21
 
 
 
22
  for (const model of new_models) {
23
  if (index % 50 === 0) {
24
  await new Promise(resolve => setTimeout(resolve, 2000));
25
  }
26
  index++
27
- if (moment(model.createdAt).isBefore(moment().subtract(1, "hour"))) {
28
- continue;
29
- }
30
 
31
  const hasImages = model?.siblings?.filter((sibling: Record<string, string>) => sibling?.rfilename.endsWith(".png") || sibling?.rfilename.endsWith(".jpeg") || sibling?.rfilename.endsWith(".jpg"))
32
  if (hasImages.length > 0) {
@@ -50,6 +49,15 @@ export async function POST({ request }) {
50
  else model.image = `https://huggingface.co/${model.id}/resolve/main/${image.replace("./", "")}`
51
  }
52
  }
 
 
 
 
 
 
 
 
 
53
 
54
  await prisma.model.create({
55
  data: {
 
1
  /** @type {import('./$types').RequestHandler} */
2
 
3
  import { json } from '@sveltejs/kit';
4
+ // import moment from 'moment';
5
  import prisma from '$lib/prisma';
6
 
7
  export async function POST({ request }) {
 
19
  let index = 0;
20
  let model_saved = 0;
21
 
22
+ console.log(new_models)
23
+
24
  for (const model of new_models) {
25
  if (index % 50 === 0) {
26
  await new Promise(resolve => setTimeout(resolve, 2000));
27
  }
28
  index++
 
 
 
29
 
30
  const hasImages = model?.siblings?.filter((sibling: Record<string, string>) => sibling?.rfilename.endsWith(".png") || sibling?.rfilename.endsWith(".jpeg") || sibling?.rfilename.endsWith(".jpg"))
31
  if (hasImages.length > 0) {
 
49
  else model.image = `https://huggingface.co/${model.id}/resolve/main/${image.replace("./", "")}`
50
  }
51
  }
52
+ const existing_model = await prisma.model.findUnique({
53
+ where: {
54
+ id: model.id
55
+ }
56
+ })
57
+
58
+ if (existing_model) {
59
+ continue;
60
+ }
61
 
62
  await prisma.model.create({
63
  data: {