Skip to content

authorsFilter, videosFilter, linksFilter filters do not work #20

@darwin403

Description

@darwin403

This commit was supposed to implement the functionality for authorsFilter, videosFilter, linksFilter:

- `QueryArticles` class. Added filters `authorsFilter`, `videosFilter`, `linksFilter`

But when cross-referencing with the python sdk it seems the flag seems to be different: hasAuthorsFilter, hasVideosFilter, hasLinksFilter, etc. as referenced here:
https://github.com/EventRegistry/event-registry-python/blob/bf3ce144fa61cc195840591bae5ca88b31ca9139/eventregistry/QueryArticles.py#L192

This implementation of the python sdk works. But using the same flags in the node.js implementation fails. Can you please fix this and update and release a newer version to npm registery asap?

Here is a simple example to reproduce this:

import dayjs from "dayjs"
import {
  QueryArticles,
  RequestArticlesInfo,
  ReturnInfo,
  ArticleInfoFlags,
  EventRegistry,
} from "eventregistry"

const er = new EventRegistry({ apiKey: API_KEY})

async function main() {
  const query = new QueryArticles({
    conceptUri: "http://en.wikipedia.org/wiki/In_vitro_fertilisation",
    dateStart: dayjs().subtract(1, "day").format("YYYY-MM-DD"),
    dateEnd: dayjs().format("YYYY-MM-DD"),
    authorsFilter: "keepOnlyIfHasAuthors", // DOES NOT WORK
    hasAuthorsFilter: "keepOnlyIfHasAuthors", // DOES NOT WORK
  })

  query.setRequestedResult(
    new RequestArticlesInfo({
      page: 1,
      count: 100,
      returnInfo: new ReturnInfo({
        articleInfo: new ArticleInfoFlags({ body: false }),
      }),
    })
  )

  const response = await er.execQuery(query)
  const articles = response.articles.results

  const withAuthors = articles.filter((a: any) => a.authors?.length > 0)
  const withoutAuthors = articles.filter((a: any) => !a.authors?.length)

  console.log("=== Articles ===\n")
  for (const article of articles) {
    const authors = article.authors?.length
      ? article.authors.map((a: any) => a.name).join(", ")
      : "No authors"
    console.log(`${article.uri}${authors}`)
  }

  console.log("\n=== Summary ===")
  console.log(`With authors:    ${withAuthors.length}`)
  console.log(`Without authors: ${withoutAuthors.length}`)
  console.log(`Total:           ${articles.length}`)
}

main()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions