<commit_before>from utils import *
from DB import ActiveRecord, db
from Sprint import Sprint
# from inspect import getmembers

class Group(ActiveRecord):
	sprint = ActiveRecord.idObjLink(Sprint, 'sprintid')

	def __init__(self, sprintid, name, seq = None, deletable = True, id = None):
		ActiveRecord.__init__(self)
		self.id = id
		self.sprintid = sprintid
		self.name = name
		self.seq = seq if seq else maxOr(group.seq for group in self.sprint.getGroups())+1
		self.deletable = to_bool(deletable)

	def getTasks(self):
		return filter(lambda t: t.group and t.group == self, self.sprint.getTasks())

	def save(self):
		if not self.id:
			# Shift everything after this sequence
			db().update("UPDATE groups SET seq = seq + 1 WHERE seq >= ?", self.seq)
		return ActiveRecord.save(self)

	def __str__(self):
		return self.safe.name<commit_msg>Added move() and delete()<commit_after>from utils import *
from DB import ActiveRecord, db
from Sprint import Sprint
# from inspect import getmembers

class Group(ActiveRecord):
	sprint = ActiveRecord.idObjLink(Sprint, 'sprintid')

	def __init__(self, sprintid, name, seq = None, deletable = True, id = None):
		ActiveRecord.__init__(self)
		self.id = id
		self.sprintid = sprintid
		self.name = name
		self.seq = seq if seq else maxOr(group.seq for group in self.sprint.getGroups())+1
		self.deletable = to_bool(deletable)

	def getTasks(self):
		return filter(lambda t: t.group and t.group == self, self.sprint.getTasks())

	def save(self):
		if not self.id:
			# Shift everything after this sequence
			db().update("UPDATE groups SET seq = seq + 1 WHERE seq >= ?", self.seq)
		return ActiveRecord.save(self)

	def move(self, newSeq):
		# Remove group from the list
		db().update("UPDATE groups SET seq = seq - 1 WHERE seq > ?", self.seq)

		# Insert it at the new spot
		if newSeq:
			self.seq = newSeq
			db().update("UPDATE groups SET seq = seq + 1 WHERE seq > ?", self.seq)

	def delete(self):
		self.move(None)
		return ActiveRecord.delete(self)

	def __str__(self):
		return self.safe.name
{'fraction_non_alphanumeric': 0.11470588235294117, 'fraction_numerical': 0.0029411764705882353, 'mean_word_length': 4.089775561097257, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2505745', 'n_tokens_mistral': 717, 'n_tokens_neox': 659, 'n_words': 213}