Example #1
0
 def retrieve(self, tagname, monthyear):
     query = Tag.query(Tag.monthyear == monthyear, ancestor=Tag.get_tag_parent_key(tagname))
     tagmodels = query.fetch(1)
     if len(tagmodels) == 0:
         tag = Tag(parent=Tag.get_tag_parent_key(tagname))
         tag.name = tagname
         tag.monthyear = monthyear
     else:
         tag = tagmodels[0]
     return tag
Example #2
0
 def get(self):
     # query = db.GqlQuery('SELECT * FROM Tag')
     query = Tag.query()
     tags = query.fetch(5000)
     jsonData = dict()
     tagnames = []
     for tag in tags:
         if tag == "":
             continue
         if tag.name not in tagnames:
             tagnames.append(tag.name)
     jsonData["source"] = tagnames
     self.response.out.write(simplejson.dumps(jsonData))
Example #3
0
    def get_last_twelve_months_tag_expenses(self):
        last_year = date_helper.get_last_year_date()
        logging.info("last year = %d" % last_year.year)
        month_year = last_year.year * 12 + last_year.month
        logging.info("month year = %d" % month_year)
        self.compute_labels(last_year)
        q = Tag.query(ancestor=Tag.get_tag_parent_key(self.category))
        tags = q.fetch(1000)
        amounts = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        for tag in tags:
            if tag.amount is not None:
                index = tag.monthyear - month_year
                if index not in range(0, 12):
                    continue
                logging.info("tag=%s amount=%f index=%d" % (tag.name, tag.amount, index))
                amounts[index] += tag.amount
                self.totalamount += tag.amount

        self.compute_max_amount(amounts)