<commit_before>from framework.log import log
import giveaminute.idea as mIdea

class Project():
    def __init__(self, db, projectId):
        self.id = projectId
        self.db = db
        self.data = self.populateProjectData()
        
    def populateProjectData(self):
        sql = """
select p.project_id 
    ,p.title
    ,p.description
    ,p.keywords
    ,p.image_id
    ,p.is_active
    ,p.created_datetime
    ,p.updated_datetime
    ,l.location_id
    ,l.name as location_name
    ,u.user_id as owner_user_id
    ,u.first_name as owner_first_name
    ,u.last_name as owner_last_name
from project p
left join location l on l.location_id = p.location_id
left join project__user pu on pu.project_id = p.project_id
left join user u on u.user_id = pu.user_id
where p.project_id = $id;"""
        
        try:
            data = list(self.db.query(sql, {'id':self.id}))
            
            if len(data) > 0:
                return data[0]
            else:
                return None
        except Exception, e:
            log.info("*** couldn't get project info")
            log.error(e)
            return None            
    
    # dummy data    
    def getFullDictionary(self):
        members = self.getMembers()
        endorsements = self.getEndorsements()
        links = self.getLinks()
        projectResources = self.getResources()
        goals = self.getGoals()
        messages = []
        relatedIdeas = self.getRelatedIdeas()
    
        data = dict(project_id = self.id,
                    editable = True,
                    info = dict(title = self.data.title,
                                owner = smallUser(self.data.owner_user_id, self.data.owner_first_name, self.data.owner_last_name),
                                mission = self.data.description,
                                keywords = (self.data.keywords.split() if self.data.keywords else []),
                                endorsements = dict(items = endorsements),
                                location = dict(location_id = self.data.location_id,
                                                name = self.data.location_name,
                                                position = {}),
                                members = dict(items = members),
                                resources = dict(links = dict(items = links),
                                                organizations = dict(items = projectResources)),
                                goals = dict(items = goals),
                                messages = dict(n_returned = 10,
                                                offset = 0,
                                                total = 30,
                                                items = [dict(message_id = 87634,
                                                             message_type = "join", 
                                                             owner = dict(u_id = 39,<commit_msg>lat/lon in project data<commit_after>from framework.log import log
import giveaminute.idea as mIdea

class Project():
    def __init__(self, db, projectId):
        self.id = projectId
        self.db = db
        self.data = self.populateProjectData()
        
    def populateProjectData(self):
        sql = """
select p.project_id 
    ,p.title
    ,p.description
    ,p.keywords
    ,p.image_id
    ,p.is_active
    ,p.created_datetime
    ,p.updated_datetime
    ,l.location_id
    ,l.name as location_name
    ,l.lat as location_lat
    ,l.lon as location_lon
    ,u.user_id as owner_user_id
    ,u.first_name as owner_first_name
    ,u.last_name as owner_last_name
from project p
left join location l on l.location_id = p.location_id
left join project__user pu on pu.project_id = p.project_id
left join user u on u.user_id = pu.user_id
where p.project_id = $id;"""
        
        try:
            data = list(self.db.query(sql, {'id':self.id}))
            
            if len(data) > 0:
                return data[0]
            else:
                return None
        except Exception, e:
            log.info("*** couldn't get project info")
            log.error(e)
            return None            
    
    # dummy data    
    def getFullDictionary(self):
        members = self.getMembers()
        endorsements = self.getEndorsements()
        links = self.getLinks()
        projectResources = self.getResources()
        goals = self.getGoals()
        messages = []
        relatedIdeas = self.getRelatedIdeas()
    
        data = dict(project_id = self.id,
                    editable = True,
                    info = dict(title = self.data.title,
                                owner = smallUser(self.data.owner_user_id, self.data.owner_first_name, self.data.owner_last_name),
                                mission = self.data.description,
                                keywords = (self.data.keywords.split() if self.data.keywords else []),
                                endorsements = dict(items = endorsements),
                                location = dict(location_id = self.data.location_id,
                                                name = self.data.location_name,
                                                position = dict(lat = str(self.data.location_lat), lng = str(self.data.location_lon))),
                                members = dict(items = members),
                                resources = dict(links = dict(items = links),
                                                organizations = dict(items = projectResources)),
                                goals = dict(items = goals),
                                messages = dict(n_returned = 10,
                                                offset = 0,
                                                total = 30,
                                                items = [dict(message_id = 87634,
                                                             message_type = "join", 
                                                             owner = dict(u_id = 39,
{'fraction_non_alphanumeric': 0.08300264550264551, 'fraction_numerical': 0.004629629629629629, 'mean_word_length': 1.2060539752005834, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3489900', 'n_tokens_mistral': 1534, 'n_tokens_neox': 1471, 'n_words': 348}