Metadata-Version: 2.1
Name: matchdb
Version: 0.1.0
Summary: Suggesting people to connect with based on shared interests
Home-page: https://github.com/batmanscode/MatchDB
Author: batmanscode
Author-email: 
License: Apache Software License 2.0
Keywords: nbdev jupyter notebook python
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: License :: OSI Approved :: Apache Software License
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: deta (==1.1.0)
Requires-Dist: pandas (==1.2.5)
Requires-Dist: ulid-py (==1.1.0)
Provides-Extra: dev

Welcome to MatchDB
================

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

*This is a light wrapper around deta.space’s serverless database, Base.*

**MatchDB is a database of people and their interests. Use it to manage
profiles and connect people who share interests.**

The main motivation was to help to connect people in large Slack/Discord
servers in the remote working community.

## Install

``` sh
pip install matchdb
```

``` sh
# to get the latest version
pip install git+https://github.com/batmanscode/MatchDB.git
```

``` sh
# install from source
git clone https://github.com/batmanscode/MatchDB.git
```

## How to use

**Here’s a brief quickstart guide. Please read the [complete
documentation](https://batmanscode.github.io/MatchDB/pymatch.html) to
see everything you can do!**

First, let’s create a new project on deta.space and save your project
key to the environment variable `"DETA_PROJECT_KEY"`

I’ve already created an environment variable but you can add it like
this if you haven’t:

``` python
# import os

# os.environ["DETA_PROJECT_KEY"] = "..."
```

``` python
from matchdb.matchdb import *
```

Next, create a name for your database. This will be visible in your
project on deta.space.

I’ll define it globally here since I’ll be using just one database but
you can create as many as you like!

``` python
DATABASE = "users"
```

### Adding users

Let’s add two users

``` python
add_interests(user_id=1111,
              group_id=2222,
              interests=['MMA', 'memes', 'Uk', 'tea'],
              database_name=DATABASE
             )
```

``` python
find_user(1111, DATABASE)
```

    [{'date': '14-02-2023 06:00',
      'group_id': 2222,
      'interests': ['uk', 'memes', 'tea', 'mma'],
      'key': '01GS7ASNBN7BMKCFPTCV45VWBT',
      'user_id': 1111}]

``` python
add_interests(user_id=3333,
              group_id=2222,
              interests=['anime', 'memes', 'ireland', 'coffee'],
              database_name=DATABASE
             )
```

``` python
find_user(3333, DATABASE)
```

    [{'date': '14-02-2023 06:00',
      'group_id': 2222,
      'interests': ['ireland', 'anime', 'memes', 'coffee'],
      'key': '01GS7ASNGBHHPK4YMBEHN1REEZ',
      'user_id': 3333}]

### Match

``` python
match_list = match_interests(1111, DATABASE)
```

This will show evreyone who has common interests with useer `1111`,
including themselves!

``` python
match_list
```

    [{'group_id': 2222,
      'user_id': 1111,
      'common interests': ['uk', 'memes', 'tea', 'mma'],
      'common interests count': 4},
     {'group_id': 2222,
      'user_id': 3333,
      'common interests': ['memes'],
      'common interests count': 1}]

You can exclude the user you are finding matches for like this:

``` python
user = 1111

match_list = match_interests(1111, DATABASE)
```

``` python
# for other ways to do this see here:
# https://www.geeksforgeeks.org/python-removing-dictionary-from-list-of-dictionaries/
match_list = [item for item in match_list if not (item["user_id"]==user)]
```

``` python
match_list
```

    [{'group_id': 2222,
      'user_id': 3333,
      'common interests': ['memes'],
      'common interests count': 1}]

### Get your whole database

``` python
database_to_dataframe(DATABASE)
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>date</th>
      <th>group_id</th>
      <th>interests</th>
      <th>key</th>
      <th>user_id</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>14-02-2023 06:00</td>
      <td>2222</td>
      <td>[uk, memes, tea, mma]</td>
      <td>01GS7ASNBN7BMKCFPTCV45VWBT</td>
      <td>1111</td>
    </tr>
    <tr>
      <th>1</th>
      <td>14-02-2023 06:00</td>
      <td>2222</td>
      <td>[ireland, anime, memes, coffee]</td>
      <td>01GS7ASNGBHHPK4YMBEHN1REEZ</td>
      <td>3333</td>
    </tr>
  </tbody>
</table>
</div>

### Count unique interests

``` python
interestcount_to_dataframe(DATABASE)
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>interests</th>
      <th>count</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>memes</td>
      <td>2</td>
    </tr>
    <tr>
      <th>1</th>
      <td>ireland</td>
      <td>1</td>
    </tr>
    <tr>
      <th>2</th>
      <td>anime</td>
      <td>1</td>
    </tr>
    <tr>
      <th>3</th>
      <td>tea</td>
      <td>1</td>
    </tr>
    <tr>
      <th>4</th>
      <td>coffee</td>
      <td>1</td>
    </tr>
    <tr>
      <th>5</th>
      <td>uk</td>
      <td>1</td>
    </tr>
    <tr>
      <th>6</th>
      <td>mma</td>
      <td>1</td>
    </tr>
  </tbody>
</table>
</div>

## How to contribute

1.  Fork
2.  Install (more on this below)
3.  Make changes in `./notebooks`

In the terminal:

4.  [`nbdev_preview`](https://nbdev.fast.ai/tutorials/tutorial.html#preview-your-docs)
    to preview docs
5.  [`nbdev_prepare`](https://nbdev.fast.ai/tutorials/tutorial.html#prepare-your-changes)
    (very important)

And finally:

6.  Pull request!

Please go though [nbdev](https://nbdev.fast.ai/) docs. Their [end-to-end
tutorial](https://nbdev.fast.ai/tutorials/tutorial.html) will show you
most of what you need to know.

### Installing for development

#### Codespaces/VSCode

Everything you need will be installed when you open Codespaces/VSCode;
specified in `.devcontainer/`

Notes for Codespaces:

- Currently Jupyter notebook doesn’t work on Codespaces for an unknown
  reason, or at least I can’t, so you’ll have to use JupyterLab
- Open with
  `jupyter lab --NotebookApp.allow_origin='*' --NotebookApp.ip='0.0.0.0'`
- For more info on using see
  https://code.visualstudio.com/docs/datascience/notebooks-web

#### Local

You’ll need to install Jupyter and
[nbdev](https://nbdev.fast.ai/tutorials/tutorial.html) at minimum. You
can do that with the following terminal commands:

``` sh
pip install notebook
pip install nbdev
nbdev_install_quarto
nbdev_install_hooks
```

For convenience, you can install all these and optional Jupyter
extensions with:

``` sh
cd MatchDB
bash ./.devcontainer/postCreateCommand.sh
```

Then install MatchDB in editable mode with
`pip install MatchDB/requirements.txt`


