<commit_before>import json
import pymongo
import praw

from pymongo import MongoClient

client = MongoClient()
db = client.reddit
posts = db.data

print "AAAAA"

def save(obj):
    toInsert = {}
    toInsert["created_utc"] = obj.created_utc
    toInsert["subreddit"] = str(obj.subreddit)
    if type(obj) is praw.objects.Submission:
        toInsert["text"] = obj.title
        print "Saving a thread"
    else:
        toInsert["text"] = obj.body
        print "Saving a comment"
    posts.insert_one(toInsert)

def get(obj):
    subreddit = obj["subreddit"]
    from_time = int(obj["from_time"])
    to_time = int(obj["to_time"])
    keyword = obj["keyword"]  
    
    return posts.find({"subreddit": subreddit,
                       "created_utc": {"$gte": from_time, "$lte": to_time}})<commit_msg>db: Add id field<commit_after>import json
import pymongo
import praw

from pymongo import MongoClient

client = MongoClient()
db = client.reddit
posts = db.data

print "AAAAA"

def save(obj):
    toInsert = {}
    toInsert["id"] = obj.id
    toInsert["created_utc"] = obj.created_utc
    toInsert["subreddit"] = str(obj.subreddit)
    if type(obj) is praw.objects.Submission:
        toInsert["text"] = obj.title
        print "Saving a thread"
    else:
        toInsert["text"] = obj.body
        print "Saving a comment"
    posts.insert_one(toInsert)

def get(obj):
    subreddit = obj["subreddit"]
    from_time = int(obj["from_time"])
    to_time = int(obj["to_time"])
    keyword = obj["keyword"]  
    
    return posts.find({"subreddit": subreddit,
                       "created_utc": {"$gte": from_time, "$lte": to_time}})
{'fraction_non_alphanumeric': 0.13500305436774587, 'fraction_numerical': 0.0, 'mean_word_length': 3.095, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3656610', 'n_tokens_mistral': 552, 'n_tokens_neox': 561, 'n_words': 126}