Back

[SOLVED] Query.between in Python DateTime broken

  • 0
  • Self Hosted
ZachHandley
26 Sep, 2023, 18:18

The REST API for Between in python seems to not be working, I tried first storing my date as a DateTime, but that didn't work, so I switched it to a string and tried using ISOFormat but that errors out too, here's the code and error

TypeScript
    def get_articles(self, days_tolerance: int = int(days_to_report)):
        """
        Gets articles from the Appwrite Database for today that we haven't vectorized yet
        """
        now = self.utils.get_now()
        min_published_date = now - timedelta(days=days_tolerance)
        print(f"Getting articles from {min_published_date} to {now}")
        start = min_published_date.isoformat()
        end = now.isoformat()
        between = now - timedelta(days=days_tolerance / 2)
        print(
            f"Testing DateTime Between with ISO Strings: {between.isoformat()} is between {min_published_date.isoformat()} and {now.isoformat()}: {between.isoformat() > min_published_date.isoformat() and between.isoformat() < now.isoformat()}"
        )
        articles = self.db.list_documents(
            APPWRITE_DB,
            "articles",
            [
                Query.between(
                    "date",
                    json.dumps(start),
                    json.dumps(end),
                ),
                Query.equal("used", False),
            ],
        ).get("documents")
        print(f"Got articles: {articles}")
        if len(articles) < 5:
            search_response = self.utils.search("Crypto news today")
            print(f"New articles found: {search_response}")
        return self.db.list_documents(
            APPWRITE_DB, "articles", [Query.between()]
        )

and the error attached

TL;DR
Title: [SOLVED] Issue with Query.between in Python DateTime Messages: The REST API for the Query.between method in Python DateTime seems to be broken. The date was first stored as a DateTime, but that didn't work, so it was switched to a string and tried with ISOFormat, which also resulted in errors. Below is the code and error received. Solution: The issue has been identified as a known problem. Visit this link <https://github.com/appwrite/appwrite/issues/5650> for more information.
Drake
27 Sep, 2023, 01:00
ZachHandley
27 Sep, 2023, 02:20

oh

ZachHandley
27 Sep, 2023, 02:20

cool

ZachHandley
29 Sep, 2023, 04:46

?solved

Drake
29 Sep, 2023, 06:08

Y'know, you can update the post title too

ZachHandley
29 Sep, 2023, 06:14

[SOLVED] Query.between in Python DateTime broken

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more