Example #1
0
from NotchReports import getCollectionsByOrg
from NotchReports.GrowthReports import new_companies

report_config = new_companies.age_in_seconds('new_contact_days', 16400)
get_contacts = getCollectionsByOrg.mongo_connection("notch_sales_clients_test",
                                                    "leads", 16400)

print(new_companies.get_count(get_contacts))
Example #2
0

#Get growth records
def age_in_seconds(column_name, org_id):
    query = "SELECT {} FROM notch_crm.reports_configuration where orgid ={};".format(
        column_name, org_id)
    new_company_definition = mySqlConnection.read_query(
        mySqlConnection.connection, query)
    new_company_definition = new_company_definition[0][0]
    return new_company_definition * 86400


report_config = age_in_seconds("new_company_days", 16400)

#Get companies records from Mongo
company_collection = getCollectionsByOrg.mongo_connection(
    "notch_sales_clients_test", "companies", 16400)


#Get New company count
def get_count(collection):
    count = 0
    for each in collection:
        date_created = each['createdAt']
        date_created = date_created / 1000
        date_created = datetime.fromtimestamp(
            date_created)  # Convert float to a a datetime object in timestamp

        date_now = datetime.now()
        day = date_now - date_created
        day2 = day.total_seconds()
        if day2 <= report_config:
Example #3
0
#owner = 16364
#teamId = 16405
#orgId = 16400
#periodCount:
#'isExpired': False,
#'isSuspended': False,
#'isTerminated': False,
#endDate
#createdOn
#print subs created by aderonke in 2021
#ownerName: "Adex Adex"
#clientID: 14 - living yield
#{'orgId':16400, 'owner':16364, 'createdOn': {$gte: 1577833200000, $lte: 1609369200000}}

# fetch all subscription reports for an org
sub_list = getCollectionsByOrg.mongo_connection("notch_sales_clients_test",
                                                "subscriptions", 16400)
org_txns = getTransactions.orgTxns
sub_txn_count = 0

sub_txn_list = []
for each in org_txns:
    if each['itemType'] == 'subscription':
        sub_txn_list.append(each)
        sub_txn_count += 1
        #print(each['equivalents']['USD'])

#transaction: each['itemId'] or id
#each['equivalents']['USD']
#sub : each['id]
#SUB-16400-0000044
from pymongo import MongoClient
from NotchReports import getCollectionsByOrg

orgTxns = getCollectionsByOrg.mongo_connection("notch_sales_clients_test",
                                               "transactions", 16400)
from NotchReports import getCollectionsByOrg
from NotchReports.GrowthReports import new_companies
from _datetime import datetime

report_config = new_companies.age_in_seconds('new_invoice_days', 16400)
get_invoices = getCollectionsByOrg.mongo_connection("notch_sales_clients_test",
                                                    "invoices", 16400)

#CAVEAT: invoices report uses createdON instead of created at which everybody else uses


def get_count(collection):
    count = 0
    for each in collection:
        date_created = each['createdOn']
        date_created = date_created / 1000
        date_created = datetime.fromtimestamp(
            date_created)  # Convert float to a a datetime object in timestamp

        date_now = datetime.now()
        day = date_now - date_created
        day2 = day.total_seconds()
        if day2 <= report_config:
            count += 1
        else:
            pass
    return 'The number of items that are new are {}'.format(count)


print(get_count(get_invoices))