From db4e80256f8e5f2300e77b91052fc3a7ab99bb4f Mon Sep 17 00:00:00 2001 From: kgolubic Date: Mon, 28 Aug 2023 18:05:04 +0200 Subject: [PATCH] Create new pages --- .../available-algorithms/date.mdx | 136 ++++++++++++++++++ .../available-algorithms/label.mdx | 58 ++++++++ .../available-algorithms/text.mdx | 53 +++++++ pages/release-notes.mdx | 6 +- 4 files changed, 250 insertions(+), 3 deletions(-) create mode 100644 pages/advanced-algorithms/available-algorithms/date.mdx create mode 100644 pages/advanced-algorithms/available-algorithms/label.mdx create mode 100644 pages/advanced-algorithms/available-algorithms/text.mdx diff --git a/pages/advanced-algorithms/available-algorithms/date.mdx b/pages/advanced-algorithms/available-algorithms/date.mdx new file mode 100644 index 000000000..da983a23b --- /dev/null +++ b/pages/advanced-algorithms/available-algorithms/date.mdx @@ -0,0 +1,136 @@ +import { Steps } from 'nextra/components' + +# date + +export const Highlight = ({children, color}) => ( + + {children} + +); + +The `date` module provides various utilities to handle date and time operations within the Cypher Query Language. These functions can be used in conjunction with other Cypher expressions to handle date-related tasks such as formatting, parsing, comparisons, and arithmetic, thus enhancing the capabilities of Memgraph for managing time-based data. + +[![docs-source](https://img.shields.io/badge/source-date-FB6E00?logo=github&style=for-the-badge)](https://github.com/memgraph/mage/tree/main/python/date.py) + +| Trait | Value | +| ------------------- | ----------------------------------------------------- | +| **Module type** | **algorithm** | +| **Implementation** | **C++** | +| **Graph direction** | **directed**/**undirected** | +| **Edge weights** | **weighted**/**unweighted** | +| **Parallelism** | **sequential** | + +### Procedures + +### `format(time, unit, format, timezone)` + +Returns a string representation of time value using the specified unit, specified format, and specified time zone. + +#### Input: + +- `time: int` ➡ time passed since the Unix epoch. +- `unit: str (default="ms")` ➡ unit of the given time. +- `format: str (default="%Y-%m-%d %H:%M:%S %Z")` ➡ pattern to be formatted to. +- `timezone: str (default="UTC")` ➡ timezone to be used. + +:::info + +The unit parameter supports the following values: +- "ms" for milliseconds +- "s" for seconds +- "m" for minutes +- "h" for hours +- "d" for days + +::: + +:::info + +The format parameter supports values defined under [Python strftime format codes](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes). + +::: + +:::info + +The timezone parameter can be specified with the database TZ identifier (text) name, as listed for [timezones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). + +::: + +#### Output: + +- `formatted: str` ➡ received time in the specified format. + +#### Usage: + +```cypher +CALL date.format(74976, "h", "%Y/%m/%d %H:%M:%S %Z", "Mexico/BajaNorte") +YIELD formatted RETURN formatted; +``` + +```plaintext ++-------------------------------+ +| formatted | ++-------------------------------+ +| "1978/07/21 17:00:00 PDT" | ++-------------------------------+ +``` + + +### `parse(time, unit, format, timezone)` + +Parses the date string using the specified format and specified timezone into the specified time unit. + +#### Input: + +- `time: str` ➡ a datetime. +- `unit: str (default="ms")` ➡ unit to be parsed to. +- `format: str (default="%Y-%m-%d %H:%M:%S")` ➡ format of the given DateTime. +- `timezone: str (default="UTC")` ➡ timezone to be used. + +:::info + +The unit parameter supports the following values: +- "ms" for milliseconds +- "s" for seconds +- "m" for minutes +- "h" for hours +- "d" for days + +::: + +:::info + +The format parameter supports values defined under [Python strftime format codes](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes). + +::: + +:::info + +The timezone parameter can be specified with the database TZ identifier (text) name, as listed for [timezones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). + +::: + +#### Output: + +- `parsed: int` ➡ number of time units that have elapsed since the Unix epoch. + +#### Usage: + +```cypher +CALL date.parse("2023/08/03 14:30:00", "h", "%Y/%m/%d %H:%M:%S", "Europe/Zagreb") +YIELD parsed RETURN parsed; +``` + +```plaintext ++---------------------+ +| parsed | ++---------------------+ +| 469740 | ++---------------------+ +``` \ No newline at end of file diff --git a/pages/advanced-algorithms/available-algorithms/label.mdx b/pages/advanced-algorithms/available-algorithms/label.mdx new file mode 100644 index 000000000..b1a1a949b --- /dev/null +++ b/pages/advanced-algorithms/available-algorithms/label.mdx @@ -0,0 +1,58 @@ +import { Steps } from 'nextra/components' + +# label + +export const Highlight = ({children, color}) => ( + + {children} + +); + +Labels are used to categorize nodes, and the `label` module provides an array of utilities for working with labels in a Memgraph database. + + +[![docs-source](https://img.shields.io/badge/source-label-FB6E00?logo=github&style=for-the-badge)](https://github.com/memgraph/mage/tree/main/cpp/label_module) + +| Trait | Value | +| ------------------- | ----------------------------------------------------- | +| **Module type** | **algorithm** | +| **Implementation** | **C++** | +| **Graph direction** | **directed**/**undirected** | +| **Edge weights** | **weighted**/**unweighted** | +| **Parallelism** | **sequential** | + +### Procedures + +### `exists(node, label)` + +Checks whether a specified label exists within the provided node. + +#### Input: + +- `node: Any` ➡ node whose labels are to be checked. +- `label: string` ➡ name of the label whose existence is to be confirmed. + +#### Output: + +- `exists: bool` ➡ whether or not provided node has a specified label. + +#### Usage: + +```cypher +CREATE (:Student {name: 'Ana'}); +MATCH (s:Student {name: 'Ana'}) CALL label.exists(s, "Teacher") YIELD exists RETURN exists; +``` + +```plaintext ++----------------------------+ +| exists | ++----------------------------+ +| False | ++----------------------------+ +``` diff --git a/pages/advanced-algorithms/available-algorithms/text.mdx b/pages/advanced-algorithms/available-algorithms/text.mdx new file mode 100644 index 000000000..aa2d9f070 --- /dev/null +++ b/pages/advanced-algorithms/available-algorithms/text.mdx @@ -0,0 +1,53 @@ +import { Steps } from 'nextra/components' + +# text + +export const Highlight = ({children, color}) => ( + + {children} + +); + +The `text` module offers a toolkit for manipulating strings. + +[![docs-source](https://img.shields.io/badge/source-text-FB6E00?logo=github&style=for-the-badge)](https://github.com/memgraph/mage/tree/main/cpp/text_module) + +| Trait | Value | +| ------------------- | ----------------------------------------------------- | +| **Module type** | **algorithm** | +| **Implementation** | **C++** | +| **Parallelism** | **sequential** | + +### Procedures + +### `join(strings, delimiter)` + +Joins all the strings into a single one with the given delimiter between them. +#### Input: + +- `strings: List[string]` ➡ list of strings to be joined. +- `delimiter: string` ➡ string to be inserted between the given strings. + +#### Output: + +- `string: string` ➡ the joined string. + +#### Usage: + +```cypher +CALL text.join(["idora", " ", "ivan", "", "matija"], ",") YIELD string RETURN string; +``` + +```plaintext ++----------------------------+ +| string | ++----------------------------+ +| "idora, ,ivan,,matija" | ++----------------------------+ +``` \ No newline at end of file diff --git a/pages/release-notes.mdx b/pages/release-notes.mdx index 47403d509..9c9a96bf6 100644 --- a/pages/release-notes.mdx +++ b/pages/release-notes.mdx @@ -6,12 +6,12 @@ import { Callout } from 'nextra/components' ### Features and improvements -- You can use the [`label` module](/query-modules/cpp/label.md) to check whether +- You can use the [`label` module](/advanced-algorithms/available-algorithms/label.md) to check whether a node has the given label. [#304](https://github.com/memgraph/mage/pull/304) - Time zones don’t have to be difficult to work with. The [`date` - module](/query-modules/python/date.md) provides utilities for date and time + module](/advanced-algorithms/available-algorithms/date.md) provides utilities for date and time operations. [#291](https://github.com/memgraph/mage/pull/291) -- The [`text` module](/query-modules/python/text.md) simplifies string +- The [`text` module](/advanced-algorithms/available-algorithms/text.md) simplifies string concatenation and supports custom delimiters. [#287](https://github.com/memgraph/mage/pull/287)